This is the mail archive of the
binutils@sources.redhat.com
mailing list for the binutils project.
RE: Bfd/binutils inconsistency re: *UND* and *ABS* and relocs against dummy (STT_NOTYPE) symbol entries in elf symbol tables!?
- From: "Dave Korn" <dk at artimi dot com>
- To: <binutils at sources dot redhat dot com>
- Date: Wed, 3 Mar 2004 16:16:59 -0000
- Subject: RE: Bfd/binutils inconsistency re: *UND* and *ABS* and relocs against dummy (STT_NOTYPE) symbol entries in elf symbol tables!?
> -----Original Message-----
> From: Ian Lance Taylor
> > - XXXX_relocate_section gets really confused by this whole
> > situation, because it's generally written like this:
> >
> > [...loop across all relocs....]
> > r_symndx = ELF32_R_SYM (rel->r_info);
> > if (r_symndx < symtab_hdr->sh_info)
> > {
> > sym = local_syms + r_symndx;
> > sec = local_sections[r_symndx];
> > sym_name = bfd_elf_local_sym_name (input_bfd, sym);
> >
> > relocation = _bfd_elf_rela_local_sym (output_bfd,
> sym, sec, rel);
> > }
> > [...else find out some other way...]
> >
> > and if ELF32_R_SYM returns zero, sym ends up pointing to the dummy
> > STT_NOTYPE entry and sec to the *UND* section. That's not right.
>
> I agree. I believe sec should wind up being set to bfd_abs_sec_ptr.
>
> Ian
Mmm. But what I'm now wondering is whether I should special case r_symndx
== 0 by replacing the assignment of sec (in XXX_relocate_section) like this:
> > sec = r_symndx ? local_sections[r_symndx] : bfd_abs_sec_ptr;
or whether I should find the code that sets up the local_sections and
local_syms arrays, and make sure it sets entry zero to the ABS rather than
UND section.
The second way of doing it seems more correct to me: since the dummy
symbol actually represents an absolute zero, the local_sections[0] entry
corresponding to the local_syms[0] entry for it should point to ABS, not
UND, because that's what section the symbol is actually in. It's misleading
to claim the zero symbol is undefined: it isn't.
However, it also seems to me that there might be other bits of code which
expect local_sections[0] to point to UND despite the zero symbol not
actually being undefined, and changing this might inadvertently break them.
So the safety-first approach leads me to consider just using the ternary
expression above.
Anyone else have an opinion on which approach is a better idea ?
cheers,
DaveK
--
Can't think of a witty .sigline today....