Define __start/__stop symbols when there is only a dynamic def
Mon Jan 29 23:28:00 GMT 2018
On Mon, Jan 29, 2018 at 3:14 PM, H.J. Lu <firstname.lastname@example.org> wrote:
> On Mon, Jan 29, 2018 at 2:58 PM, Michael Matz <email@example.com> wrote:
>> On Mon, 29 Jan 2018, H.J. Lu wrote:
>>> > Yes, that's it. (the associated lib.c needs to have a regular ref
>>> > symbol to __start___symbol and that lib needs to have something else
>>> > than "6" in its __verbose section, in order to test the exact
>>> > situation of pacemaker). With the patch from Alan ./app will have
>>> > __start___verbose in its symbol table, but not yet in the dynamic
>>> > symbol table. So with only Alans patch -E would be necessary. With
>>> > the addition of the bfd_elf_link_record_dynamic_symbol() call to
>>> > bfd_elf_define_start_stop the above testcase will start working as is
>>> > even without -E.
>>> I don't think Alan's patch nor yours are correct. Here is mine with
>>> your testcase. OK for master?
>> In which way is the combination not correct? I.e. make a testcase that
>> doesn't work with our stuff but with yours.
>> (Note, in order for the semantics to be the same as before 2.29, these
>> symbols must not be created if there's neither a ref_regular ref, nor a
>> dynamic definition in any of the shared libs on the link cmdline).
> I asked specially if the testcase is correct:
> There is no reference to __start___verbose from executable nor
> from dynamic object.
> BTW, your patch:
> may make .startof symbols dynamic.
And your patch doesn't work for:
[hjl@gnu-6 orphan-4]$ cat app.c
extern int __start___verbose;
extern int __stop___verbose;
int bar (void)
static int my_var __attribute__((section("__verbose"), used)) = 6;
ptr = (int*) dlsym(RTLD_DEFAULT, "__start___verbose");
if (!ptr || *ptr != 6)
if (bar () != 0)
printf("main: wrong __start___verbose\n");
[hjl@gnu-6 orphan-4]$ make
cc -g -O2 -c -o app.o app.c
cc -B./ -Wl,--gc-sections -o app app.o -ldl -Wl,-R,.
main: wrong __start___verbose
make: *** [Makefile:9: all] Error 2
More information about the Binutils