looking for non-loaded, non-writable, non-allocated elf segment
Ian Lance Taylor
ian@airs.com
Tue Jan 1 10:03:00 GMT 2002
Andrew Brown <atatat@atatdot.net> writes:
> 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.
I would say that you are looking for a new gcc feature: if a variable
marked unused is placed in a special section, gcc should not request
that the section be allocatable. This is not a binutils issue.
Your workaround depends upon the particular implementation used by
both gcc and gas. It may continue to work in future releases, but you
should not expect it. It may work for other targets, but you should
not expect that either.
Ian
More information about the Binutils
mailing list