Figuring out start and end of sections

Ian Lance Taylor iant@google.com
Wed Apr 14 00:24:00 GMT 2010


Felipe Balbi <me@felipebalbi.com> writes:

> is there any way to figure out where a section starts and ends ?
>
> I added a specific section to my program using
> __attribute__((section "<section name>")) and now I want to figure out
> where that section starts so I can iterate over it and call the function
> pointers I'm adding to it.
>
> Do I need a specific linker script to achieve that or does the default
> scripts give me possibility to find that out ?

If you are using the GNU linker, or gold, and you make the section
name a valid C identifier, then the linker will automatically define
symbols __start_SECNAME and __stop_SECNAME which you can use.

Ian



More information about the Gcc-help mailing list