[lld] r252131 - [elf2] Fix R_X86_64_TPOFF32 handling.
Rui Ueyama via llvm-commits
llvm-commits at lists.llvm.org
Thu Nov 5 10:13:41 PST 2015
On Wed, Nov 4, 2015 at 6:00 PM, Michael J. Spencer via llvm-commits <
llvm-commits at lists.llvm.org> wrote:
> Author: mspencer
> Date: Wed Nov 4 20:00:35 2015
> New Revision: 252131
>
> URL: http://llvm.org/viewvc/llvm-project?rev=252131&view=rev
> Log:
> [elf2] Fix R_X86_64_TPOFF32 handling.
>
> For x86-64 the initial executable TLS block is placed directly before the
> thread specific data register so compilers can directly access it via
> R_X86_64_TPOFF32. Generate the correct (negative) offset for this case.
>
> Modified:
> lld/trunk/ELF/OutputSections.h
> lld/trunk/ELF/Target.cpp
> lld/trunk/ELF/Writer.cpp
> lld/trunk/test/elf2/tls.s
>
> Modified: lld/trunk/ELF/OutputSections.h
> URL:
> http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/OutputSections.h?rev=252131&r1=252130&r2=252131&view=diff
>
> ==============================================================================
> --- lld/trunk/ELF/OutputSections.h (original)
> +++ lld/trunk/ELF/OutputSections.h Wed Nov 4 20:00:35 2015
> @@ -372,6 +372,7 @@ template <class ELFT> struct Out {
> static SymbolTableSection<ELFT> *DynSymTab;
> static SymbolTableSection<ELFT> *SymTab;
> static uintX_t TlsInitImageVA;
> + static size_t TlsInitImageAlignedSize;
> };
>
> template <class ELFT> DynamicSection<ELFT> *Out<ELFT>::Dynamic;
> @@ -392,6 +393,7 @@ template <class ELFT> StringTableSection
> template <class ELFT> SymbolTableSection<ELFT> *Out<ELFT>::DynSymTab;
> template <class ELFT> SymbolTableSection<ELFT> *Out<ELFT>::SymTab;
> template <class ELFT> typename Out<ELFT>::uintX_t
> Out<ELFT>::TlsInitImageVA;
> +template <class ELFT> size_t Out<ELFT>::TlsInitImageAlignedSize;
>
> } // namespace elf2
> } // namespace lld
>
> Modified: lld/trunk/ELF/Target.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Target.cpp?rev=252131&r1=252130&r2=252131&view=diff
>
> ==============================================================================
> --- lld/trunk/ELF/Target.cpp (original)
> +++ lld/trunk/ELF/Target.cpp Wed Nov 4 20:00:35 2015
> @@ -340,7 +340,7 @@ void X86_64TargetInfo::relocateOne(uint8
> write32le(Loc, SA);
> break;
> case R_X86_64_TPOFF32:
> - write32le(Loc, SA);
> + write32le(Loc, SA -
> Out<llvm::object::ELF64LE>::TlsInitImageAlignedSize);
> break;
> default:
> error("unrecognized reloc " + Twine(Type));
>
> Modified: lld/trunk/ELF/Writer.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Writer.cpp?rev=252131&r1=252130&r2=252131&view=diff
>
> ==============================================================================
> --- lld/trunk/ELF/Writer.cpp (original)
> +++ lld/trunk/ELF/Writer.cpp Wed Nov 4 20:00:35 2015
> @@ -740,8 +740,11 @@ template <class ELFT> void Writer<ELFT>:
> }
> }
>
> - if (TlsPhdr.p_vaddr)
> + if (TlsPhdr.p_vaddr) {
> Phdrs[++PhdrIdx] = TlsPhdr;
> + Out<ELFT>::TlsInitImageAlignedSize =
> + RoundUpToAlignment(TlsPhdr.p_memsz, TlsPhdr.p_align);
> + }
>
Can you give me the pointer to the spec that says "TLS block end" is an
aligned value this way?
>
> // Add an entry for .dynamic.
> if (isOutputDynamic()) {
>
> Modified: lld/trunk/test/elf2/tls.s
> URL:
> http://llvm.org/viewvc/llvm-project/lld/trunk/test/elf2/tls.s?rev=252131&r1=252130&r2=252131&view=diff
>
> ==============================================================================
> --- lld/trunk/test/elf2/tls.s (original)
> +++ lld/trunk/test/elf2/tls.s Wed Nov 4 20:00:35 2015
> @@ -164,7 +164,7 @@ d:
>
> // DIS: Disassembly of section .text:
> // DIS-NEXT: _start:
> -// DIS-NEXT: 11000: {{.+}} movl %fs:8, %eax
> -// DIS-NEXT: 11008: {{.+}} movl %fs:0, %eax
> -// DIS-NEXT: 11010: {{.+}} movl %fs:12, %eax
> -// DIS-NEXT: 11018: {{.+}} movl %fs:4, %eax
> +// DIS-NEXT: 11000: {{.+}} movl %fs:-8, %eax
> +// DIS-NEXT: 11008: {{.+}} movl %fs:-16, %eax
> +// DIS-NEXT: 11010: {{.+}} movl %fs:-4, %eax
> +// DIS-NEXT: 11018: {{.+}} movl %fs:-12, %eax
>
>
> _______________________________________________
> 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/20151105/22d58131/attachment.html>
More information about the llvm-commits
mailing list