This is the mail archive of the
mailing list for the binutils project.
Re: protected __start_section and __stop_section symbols
- From: "H.J. Lu" <hjl dot tools at gmail dot com>
- To: Cimbali <me at cimba dot li>
- Cc: Binutils <binutils at sourceware dot org>
- Date: Mon, 5 Feb 2018 13:28:16 -0800
- Subject: Re: protected __start_section and __stop_section symbols
- Authentication-results: sourceware.org; auth=none
- References: <email@example.com>
On Mon, Feb 5, 2018 at 2:21 AM, Cimbali <firstname.lastname@example.org> wrote:
> According to readelf, when I define a section in GCC code with
> __attribute__(("section")) in a shared library, the __start_section and
> __stop_section symbols (which allow me retrieve the start and end of said
> section) are now protected with ld v2.29.1.
> I had some code that relied on having those symbols overruled by a program
> to which the library is linked, that is if the section exists in the program
> then use it from the library, otherwise fall back to the library's section
> (details and reproducible example here:
> https://stackoverflow.com/q/48591224/1387346 ).
> This is no longer possible, but used to work with ld v2.26.1. I could not
> find any decent changelog for ld, nor any mention of this in the man page,
> and cannot figure out if this is a bug or a feature. Why did this change of
> behaviour happen?
> I am aware that the __start_section and __stop_section symbols are barely
> documented to start with, but I'd like to know if there is a way for the
> symbols not to be protected even with newer versions of ld, or if I have to
> use another way of accessing data in a program from a library's constructor.
__start_XXX and __stop_XXX symbols are defined for section XXX within
the executable or share objects. You can create a shared object which
contains section XXX to provide the default __start_XXX and __stop_XXX
if they aren't defined in the executable.