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]

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


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


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