mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Patrick Mansfield <patmans@us.ibm.com>
To: linux-kernel@vger.kernel.org
Subject: getting text strings into __initdata for char *foo = "data"
Date: Wed, 20 Nov 2002 14:43:43 -0800	[thread overview]
Message-ID: <20021120144343.A23601@eng2.beaverton.ibm.com> (raw)

Hi -

Is there a way to get char * initialized data to go into the init
data section?

For example, in the following I want init_foobar and its associated
text strings to go into the init data section, not just the pointers
in init_foobar:

[patman@elm3a50 bleed-2.5]$ more initdata.c
#include <linux/init.h>

/*
 * This only puts the pointer in .init.data.
 */
char *init_foobar[] __initdata = { 
        "AAAAtextAAAAtextAAAAtext-morea",
        "AAAA",
        "AAAA",
};

/*
 * Following is OK, but wastes some space (on disk) and needs one extra byte
 * for the '\0'. Worse, the second entry below is not '\0' terminated and gets
 * no compilation warning :(
 */
char init_foobar2[][31] __initdata = { 
        "BBBBtextBBBBtextBBBBtext-morea",
        "BBBBtextBBBBtextBBBBtext-morebc",
        "BBBB",
        "BBBB",
};

char *regular_foobar[] = {
        "CCCCtextCCCCtextCCCCtext-morea",
        "CCCCtextCCCCtextCCCCtext-moreb",
        "CCCC",
};


[patman@elm3a50 bleed-2.5]$ objdump -s initdata.o 

initdata.o:     file format elf32-i386

Contents of section .text:
Contents of section .data:
 0000 40000000 20000000 05000000           @... .......    
Contents of section .note:
 0000 08000000 00000000 01000000 30312e30  ............01.0
 0010 31000000                             1...            
Contents of section .init.data:
 0000 00000000 00000000 00000000 42424242  ............BBBB
 0010 74657874 42424242 74657874 42424242  textBBBBtextBBBB
 0020 74657874 2d6d6f72 65610042 42424274  text-morea.BBBBt
 0030 65787442 42424274 65787442 42424274  extBBBBtextBBBBt
 0040 6578742d 6d6f7265 62634242 42420000  ext-morebcBBBB..
 0050 00000000 00000000 00000000 00000000  ................
 0060 00000000 00000000 00424242 42000000  .........BBBB...
 0070 00000000 00000000 00000000 00000000  ................
 0080 00000000 00000000                    ........        
Contents of section .rodata.str1.1:
 0000 41414141 00434343 4300               AAAA.CCCC.      
Contents of section .rodata.str1.32:
 0000 41414141 74657874 41414141 74657874  AAAAtextAAAAtext
 0010 41414141 74657874 2d6d6f72 65610000  AAAAtext-morea..
 0020 43434343 74657874 43434343 74657874  CCCCtextCCCCtext
 0030 43434343 74657874 2d6d6f72 65620000  CCCCtext-moreb..
 0040 43434343 74657874 43434343 74657874  CCCCtextCCCCtext
 0050 43434343 74657874 2d6d6f72 656100    CCCCtext-morea. 
Contents of section .comment:
 0000 00474343 3a202847 4e552920 322e3936  .GCC: (GNU) 2.96
 0010 20323030 30303733 31202852 65642048   20000731 (Red H
 0020 6174204c 696e7578 20372e31 20322e39  at Linux 7.1 2.9
 0030 362d3938 2900                        6-98).          


-- Patrick Mansfield

             reply	other threads:[~2002-11-20 22:36 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-11-20 22:43 Patrick Mansfield [this message]
2002-11-20 23:43 ` Richard B. Johnson
2002-11-21  5:48 ` Keith Owens

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20021120144343.A23601@eng2.beaverton.ibm.com \
    --to=patmans@us.ibm.com \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®