[lld] r271852 - Move GlobalDynIndex to SymbolBody.

Rafael EspĂ­ndola via llvm-commits llvm-commits at lists.llvm.org
Sun Jun 5 14:46:12 PDT 2016


With this I can bootstrap lld on linux aarch64 :-)

Cheers,
Rafael




On 5 June 2016 at 15:03, Rafael Espindola via llvm-commits
<llvm-commits at lists.llvm.org> wrote:
> Author: rafael
> Date: Sun Jun  5 14:03:28 2016
> New Revision: 271852
>
> URL: http://llvm.org/viewvc/llvm-project?rev=271852&view=rev
> Log:
> Move GlobalDynIndex to SymbolBody.
>
> With that we can have local symbols with a tls gd index.
>
> Added:
>     lld/trunk/test/ELF/aarch64-tls-static.s
> Modified:
>     lld/trunk/ELF/OutputSections.cpp
>     lld/trunk/ELF/Symbols.h
>
> Modified: lld/trunk/ELF/OutputSections.cpp
> URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/OutputSections.cpp?rev=271852&r1=271851&r2=271852&view=diff
> ==============================================================================
> --- lld/trunk/ELF/OutputSections.cpp (original)
> +++ lld/trunk/ELF/OutputSections.cpp Sun Jun  5 14:03:28 2016
> @@ -145,9 +145,9 @@ template <class ELFT> void GotSection<EL
>  }
>
>  template <class ELFT> bool GotSection<ELFT>::addDynTlsEntry(SymbolBody &Sym) {
> -  if (Sym.symbol()->GlobalDynIndex != -1U)
> +  if (Sym.GlobalDynIndex != -1U)
>      return false;
> -  Sym.symbol()->GlobalDynIndex = Entries.size();
> +  Sym.GlobalDynIndex = Entries.size();
>    // Global Dynamic TLS entries take two GOT slots.
>    Entries.push_back(&Sym);
>    Entries.push_back(nullptr);
> @@ -187,13 +187,13 @@ GotSection<ELFT>::getMipsLocalEntryOffse
>  template <class ELFT>
>  typename GotSection<ELFT>::uintX_t
>  GotSection<ELFT>::getGlobalDynAddr(const SymbolBody &B) const {
> -  return this->getVA() + B.symbol()->GlobalDynIndex * sizeof(uintX_t);
> +  return this->getVA() + B.GlobalDynIndex * sizeof(uintX_t);
>  }
>
>  template <class ELFT>
>  typename GotSection<ELFT>::uintX_t
>  GotSection<ELFT>::getGlobalDynOffset(const SymbolBody &B) const {
> -  return B.symbol()->GlobalDynIndex * sizeof(uintX_t);
> +  return B.GlobalDynIndex * sizeof(uintX_t);
>  }
>
>  template <class ELFT>
>
> Modified: lld/trunk/ELF/Symbols.h
> URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Symbols.h?rev=271852&r1=271851&r2=271852&view=diff
> ==============================================================================
> --- lld/trunk/ELF/Symbols.h (original)
> +++ lld/trunk/ELF/Symbols.h Sun Jun  5 14:03:28 2016
> @@ -91,6 +91,7 @@ public:
>    uint32_t GotPltIndex = -1;
>    uint32_t PltIndex = -1;
>    uint32_t ThunkIndex = -1;
> +  uint32_t GlobalDynIndex = -1;
>    bool isInGot() const { return GotIndex != -1U; }
>    bool isInPlt() const { return PltIndex != -1U; }
>    bool hasThunk() const { return ThunkIndex != -1U; }
> @@ -395,8 +396,6 @@ template <class ELFT> SymbolBody *ElfSym
>  // stored in the Body field of this object as it resolves symbols. Symbol also
>  // holds computed properties of symbol names.
>  struct Symbol {
> -  uint32_t GlobalDynIndex = -1;
> -
>    // Symbol binding. This is on the Symbol to track changes during resolution.
>    // In particular:
>    // An undefined weak is still weak when it resolves to a shared library.
>
> Added: lld/trunk/test/ELF/aarch64-tls-static.s
> URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/aarch64-tls-static.s?rev=271852&view=auto
> ==============================================================================
> --- lld/trunk/test/ELF/aarch64-tls-static.s (added)
> +++ lld/trunk/test/ELF/aarch64-tls-static.s Sun Jun  5 14:03:28 2016
> @@ -0,0 +1,36 @@
> +// RUN: llvm-mc %s -o %t.o -triple aarch64-pc-linux -filetype=obj
> +// RUN: ld.lld %t.o -o %t.so -shared
> +// RUN: llvm-readobj -s %t.so | FileCheck --check-prefix=SEC %s
> +// RUN: llvm-objdump -d %t.so | FileCheck %s
> +
> +foo:
> +        adrp    x0, :tlsdesc:bar
> +        ldr     x1, [x0, :tlsdesc_lo12:bar]
> +        add     x0, x0, :tlsdesc_lo12:bar
> +        .tlsdesccall bar
> +        blr     x1
> +
> +
> +        .section        .tdata,"awT", at progbits
> +bar:
> +        .word   42
> +
> +
> +// SEC:      Name: .got
> +// SEC-NEXT: Type: SHT_PROGBITS
> +// SEC-NEXT: Flags [
> +// SEC-NEXT:   SHF_ALLOC
> +// SEC-NEXT:   SHF_WRITE
> +// SEC-NEXT: ]
> +// SEC-NEXT: Address: 0x2098
> +// SEC-NEXT: Offset: 0x2098
> +// SEC-NEXT: Size: 16
> +
> +// page(0x2098) - page(0x1000) = 4096
> +// 0x98 = 152
> +
> +// CHECK:      foo:
> +// CHECK-NEXT: 1000: {{.*}} adrp x0, #4096
> +// CHECK-NEXT: 1004: {{.*}} ldr  x1, [x0, #152]
> +// CHECK-NEXT: 1008: {{.*}} add  x0, x0, #152
> +// CHECK-NEXT: 100c: {{.*}} blr  x1
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits


More information about the llvm-commits mailing list