[PATCH] D18056: Compute value of local symbol with getVA.

Rafael EspĂ­ndola via llvm-commits llvm-commits at lists.llvm.org
Thu Mar 10 12:27:29 PST 2016


On 10 March 2016 at 15:19, Rui Ueyama <ruiu at google.com> wrote:
> ruiu added a comment.
>
> This is very similar to a change that I have locally.
>
>
> ================
> Comment at: ELF/Symbols.cpp:79-82
> @@ +78,6 @@
> +
> +    // PPC64 has a special relocation representing the TOC base pointer
> +    // that does not have a corresponding symbol.
> +    if (Config->EMachine == EM_PPC64 && !SC)
> +      return getPPC64TocBase();
> +
> ----------------
> This covers a special case, and I don't think absence of the input section always means that we want TocBase. Can you move this InputSectionBase::relocate like this?
>
>     // PPC64 has a special relocation representing the TOC base pointer
>     // that does not have a corresponding symbol.
>     if (Config->EMachine == EM_PPC64 && RI.getType(false) == R_PPC64_TOC) {
>       uintX_t SymVA = getPPC64TocBase() + A;
>       Target->relocateOne(BufLoc, BufEnd, Type, AddrLoc, SymVA, 0);
>       continue;
>     }

Will do.

> ================
> Comment at: ELF/Symbols.cpp:95-98
> @@ +94,6 @@
> +             Out<ELFT>::TlsPhdr->p_vaddr;
> +    if (Sym.getType() == STT_SECTION) {
> +      Offset += Addend;
> +      Addend = 0;
> +    }
> +    return SC->OutSec->getVA() + SC->getOffset(Offset);
> ----------------
> In this case Addend is taken into consideration.
>
> ================
> Comment at: ELF/Symbols.cpp:108
> @@ +107,3 @@
> +SymbolBody::getVA(typename ELFFile<ELFT>::uintX_t Addend) const {
> +  return getSymVA<ELFT>(*this, Addend) + Addend;
> +}
> ----------------
> ... and adding an addend again? Is this correct?
>

It is, since it is set to 0. STT_SECTIONS symbols are an annoying
special case since you need to use the addend before figuring out
where that position was mapped to the output.

Cheers,
Rafael


More information about the llvm-commits mailing list