This is the mail archive of the 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: [PATCH] Add a record_link_assignments hook to ldemul

On Thu, Apr 28, 2016 at 05:59:55PM -0700, H.J. Lu wrote:
> On Thu, Apr 28, 2016 at 4:38 PM, Alan Modra <> wrote:
> > On Thu, Apr 28, 2016 at 02:01:47PM -0700, H.J. Lu wrote:
> >> +      /* Symbol is defined.  Check if it is also defined in a regular
> >> +      input file only when it is currently defined in a dynamic
> >> +      object, since otherwise, it can't be a __start_<name> nor
> >> +      __stop_<name> symbol.  */
> >> +      if (!h->def_dynamic)
> >>       return NULL;
> > [snip]
> >> +         if (s != NULL)
> >> +           {
> >> +             h->root.u.undef.section = s;
> >> +             break;
> >> +           }
> >
> > You can't set u.undef here on a defined symbol.  That's just too ugly,
> > even if you later set it to undefined.  Better to force it
> > bfd_link_hash_undefined here.
> Like this?

No, I meant that if you want to make use of the u.undef.section cache,
then set it to undefined first.  If you don't intend to set
u.undef.section then set to undefined later.

> > This is getting quite messy, and I'm wondering if we even need
> > _bfd_elf_is_start_stop, except for gc-sections code.

Note that when I wrote _bfd_elf_is_start_stop I thought it might come
in useful in check_relocs, to prevent __start_* and __stop_* from
being seen as dynamic.  Now that you're running both
find_statement_assignment and lang_do_assignments before check_relocs,
doing anything special with _bfd_elf_is_start_stop should not be

find_statement_assignment has given the bfd backend a look at symbols,
and you've processed the PROVIDE (__start_sec = .) linker script
statements in lang_do_assignments.  So it ought to be possible to make
__start_sec a def_regular normal symbol by that point.  As I said
before, I'd expect that to work better if find_statement_assignment
ran before lang_do_assignments.  That allows
bfd_elf_record_link_assignment to force def_dynamic symbols to
bfd_link_hash_undefined so that ldexp.c code handling PROVIDE doesn't
need to know ELF specific details.

However, you said that doing it that way didn't work.  What didn't
work, and what needs to change in bfd_elf_record_link_assignment to
make it work?

Alan Modra
Australia Development Lab, IBM

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