mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* getting text strings into __initdata for char *foo = "data"
@ 2002-11-20 22:43 Patrick Mansfield
  2002-11-20 23:43 ` Richard B. Johnson
  2002-11-21  5:48 ` Keith Owens
  0 siblings, 2 replies; 3+ messages in thread
From: Patrick Mansfield @ 2002-11-20 22:43 UTC (permalink / raw)
  To: linux-kernel

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

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2002-11-21  5:41 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-11-20 22:43 getting text strings into __initdata for char *foo = "data" Patrick Mansfield
2002-11-20 23:43 ` Richard B. Johnson
2002-11-21  5:48 ` Keith Owens

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®