This is the mail archive of the binutils@sources.redhat.com mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

looking for non-loaded, non-writable, non-allocated elf segment


what i'm trying to do is embed some configuration data that describes
my program in the actual binary itself so that i have less "things" i
need to keep track of.  what seemed best to me was to stuff the data
into a non-loadable, non-allocated, and also read-only (although i
supposed that's moot if it's not loaded or allocated) elf segment via,
eg:

static const char config[]
#ifdef __ELF__
	__attribute__((section(".netbsd.config")))
#endif /* __ELF__ */
	__attribute__((__unused__)) = "...";

running objdump on my binary shows at this point shows me this:

% objdump -h netbsd 
...
Sections:
Idx Name          Size      VMA       LMA       File off  Algn
...
  6 .netbsd.config 0000b140  00000000  00000000  002bca40  2**5
                  CONTENTS, ALLOC, LOAD, READONLY, DATA

which isn't exactly what i was looking for.  after a little random
poking around, i happened upon this syntax:

	__attribute__((section(".netbsd.config#")))

which changes the attributes of the given section to "CONTENTS,
READONLY" which is exactly what i was looking for, however, after
skimming through gas to see if that's the "correct" behavior, i have
reached the conclusion that it might perhaps be a happy bug.  that
__attribute__() turns into this assembly

	.section	.netbsd.config#,"a",@progbits

so it seems that the ,"a",@progbits piece of the .section is just
being ignored.  it also seems that the "solaris" format as described
starting at line 557 in binutils-2.11.2/gas/config/obj-elf.c is not
properly supported.  that is to say, valid values seem to have no
effect, and invalid values cause no warnings or errors to be emitted.

it seems that the # is acting as a comment delimiter and i'm getting
what i want as a happy side effect.  is there a (better) way to
*explicitly* set what i want?  how likely is it that the current
behavior will change at some later point?

-- 
|-----< "CODE WARRIOR" >-----|
codewarrior@daemon.org             * "ah!  i see you have the internet
twofsonet@graffiti.com (Andrew Brown)                that goes *ping*!"
andrew@crossbar.com       * "information is power -- share the wealth."


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]