This is an archive of the discontinued LLVM Phabricator instance.

[lld] [ELF/AArch64] Fix TLS initial executable relocation
ClosedPublic

Authored by zatrazz on Jun 3 2015, 9:57 AM.

Details

Summary

This patch fixes the TLS initial executable for AArch64. Current
implementation have two issues: 1. do not generate dynamic
R_AARCH64_TLS_TPREL64 relocation for the external module symbols,
and 2. do not export the TLS initial executable symbol in dynamic
symbol table.

The fix follows the MIPS strategy to add a arch-specific AArch64GOTSection
class to keep track of TLS symbols required to be place in dynamic
symbol table. It also overrides the buildDynamicSymbolTable for
ExecutableWrite class for AArch64 to add the symbols.

It also adds some refactoring on AArch64RelocationPass.cpp based on ARM
backend.

Diff Detail

Event Timeline

zatrazz updated this revision to Diff 27048.Jun 3 2015, 9:57 AM
zatrazz retitled this revision from to [lld] [ELF/AArch64] Fix TLS initial executable relocation.
zatrazz updated this object.
zatrazz edited the test plan for this revision. (Show Details)
zatrazz added reviewers: ruiu, shankar.easwaran.
zatrazz added a project: lld.
zatrazz added subscribers: Unknown Object (MLST), lld.
ruiu added inline comments.Jun 3 2015, 10:47 AM
lib/ReaderWriter/ELF/AArch64/AArch64ExecutableWriter.cpp
20

Write "{}" at end of this line.

35

Move this at end of the previous line.

36

Adding { would be better for readability.

lib/ReaderWriter/ELF/AArch64/AArch64RelocationPass.cpp
215

Use isa instead of dyn_cast.

lib/ReaderWriter/ELF/AArch64/AArch64SectionChunks.cpp
19

Fix format.

30

A switch statement with only one case looks a bit weird. Maybe replace with an if?

lib/ReaderWriter/ELF/AArch64/AArch64SectionChunks.h
9

Add newline before this line.

lib/ReaderWriter/ELF/AArch64/AArch64TargetHandler.cpp
24

Format.

lib/ReaderWriter/ELF/AArch64/AArch64TargetHandler.h
28

Debug comment?

denis-protivensky added inline comments.
lib/ReaderWriter/ELF/AArch64/AArch64SectionChunks.cpp
24

dyn_cast may return NULL pointer, so you'd better use if statement or an assert depending on the workflow.

zatrazz accepted this revision.Jun 16 2015, 10:38 AM
zatrazz added a reviewer: zatrazz.
This revision is now accepted and ready to land.Jun 16 2015, 10:38 AM
zatrazz closed this revision.Jun 16 2015, 10:39 AM