[lld] r257023 - [ELF] Add AMDGPU support

Rui Ueyama via llvm-commits llvm-commits at lists.llvm.org
Tue Jan 19 13:03:38 PST 2016


On Mon, Jan 18, 2016 at 9:11 AM, Rafael EspĂ­ndola <
llvm-commits at lists.llvm.org> wrote:

> > +
> > +    // Symbol offsets for AMDGPU need to be the offset in bytes of the
> symbol
> > +    // from the beginning of the section.
> > +    if (Config->EMachine == EM_AMDGPU)
> > +      return SC->getOffset(DR.Sym);
> >      if (DR.Sym.getType() == STT_TLS)
> >        return SC->OutSec->getVA() + SC->getOffset(DR.Sym) -
> >               Out<ELFT>::TlsPhdr->p_vaddr;
> > @@ -1325,7 +1330,11 @@ void SymbolTableSection<ELFT>::writeLoca
> >            continue;
> >          const OutputSectionBase<ELFT> *OutSec = Section->OutSec;
> >          ESym->st_shndx = OutSec->SectionIndex;
> > -        VA += OutSec->getVA() + Section->getOffset(Sym);
> > +        VA = Section->getOffset(Sym);
> > +        // Symbol offsets for AMDGPU need to be the offset in bytes of
> the
> > +        // symbol from the beginning of the section.
> > +        if (Config->EMachine != EM_AMDGPU)
> > +          VA += OutSec->getVA();
> >        }
>
>
> This is a horrible design error. The ELF spec is very explicit:
>
> In executable and shared object files, st_value holds a virtual address.
>
> Is there any hope of fixing this? AMDGPU using ELF is relatively new,
> so I hope so. Some options
>
> * User -r.
> * Change the consumer.
>
> But please do something. The fact that symbols and relocations use
> offsets in .o and addresses in .so and executables is central to ELF.
>

I agree with that. The current definition of st_value field for AMDGPU ELF
files looks pretty odd and not in line with the ELF spec. I'd greatly
appreciate if you do something before it's baked in to the AMDGPU ELF spec
forever.

Cheers,
> Rafael
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160119/d87086c1/attachment.html>


More information about the llvm-commits mailing list