1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-10-21 03:53:04 +02:00
llvm-mirror/lib
Ulrich Weigand 1beb39086c [SystemZ] Sort relocs to avoid code corruption by linker optimization
The SystemZ linkers provide an optimization to transform a general-
or local-dynamic TLS sequence into an initial-exec sequence if possible.
Do do that, the compiler generates a function call to __tls_get_offset,
which is a brasl instruction annotated with *two* relocations:

- a R_390_PLT32DBL to install __tls_get_offset as branch target
- a R_390_TLS_GDCALL / R_390_TLS_LDCALL to inform the linker that
  the TLS optimization should be performed if possible

If the optimization is performed, the brasl is replaced by an ld load
instruction.

However, *both* relocs are processed independently by the linker.
Therefore it is crucial that the R_390_PLT32DBL is processed *first*
(installing the branch target for the brasl) and the R_390_TLS_GDCALL
is processed *second* (replacing the whole brasl with an ld).

If the relocs are swapped, the linker will first replace the brasl
with an ld, and *then* install the __tls_get_offset branch target
offset.  Since ld has a different layout than brasl, this may even
result in a completely different (or invalid) instruction; in any
case, the resulting code is corrupted.

Unfortunately, the way the MC common code sorts relocations causes
these two to *always* end up the wrong way around, resulting in
wrong code generation by the linker and crashes.

This patch overrides the sortRelocs routine to detect this particular
pair of relocs and enforce the required order.

llvm-svn: 255787
2015-12-16 18:12:40 +00:00
..
Analysis Fix typo in r255720 2015-12-16 00:17:34 +00:00
AsmParser Add InaccessibleMemOnly and inaccessibleMemOrArgMemOnly attributes 2015-12-16 16:16:19 +00:00
Bitcode Add InaccessibleMemOnly and inaccessibleMemOrArgMemOnly attributes 2015-12-16 16:16:19 +00:00
CodeGen [Packetizer] Add a check whether an instruction should be packetized now 2015-12-16 16:38:16 +00:00
DebugInfo [llvm-dwp] Retrieve the DWOID from the CU for the cu_index entry 2015-12-04 17:20:04 +00:00
ExecutionEngine [SectionMemoryManager] Make better use of virtual memory 2015-12-16 11:13:23 +00:00
Fuzzer Fuzzer: Fix library dependencies. 2015-12-16 02:14:57 +00:00
IR Add InaccessibleMemOnly and inaccessibleMemOrArgMemOnly attributes 2015-12-16 16:16:19 +00:00
IRReader Return a unique_ptr from getLazyBitcodeModule and parseBitcodeFile. NFC. 2015-06-16 22:27:55 +00:00
LibDriver [Option] Use an ArrayRef to store the Option Infos in OptTable. NFC 2015-10-21 16:30:42 +00:00
LineEditor
Linker Use diagnostic handler in the LLVMContext 2015-12-14 23:17:03 +00:00
LTO Use diagnostic handler in the LLVMContext 2015-12-14 23:17:03 +00:00
MC [X86][inline asm] support even directive 2015-12-13 17:07:23 +00:00
Object Use diagnostic handler in the LLVMContext 2015-12-14 23:17:03 +00:00
Option [Option] Use an ArrayRef to store the Option Infos in OptTable. NFC 2015-10-21 16:30:42 +00:00
Passes [PM] Port StripDeadPrototypes to the new pass manager 2015-10-30 23:28:12 +00:00
ProfileData Initialize all bytes in vp data (msan error) 2015-12-15 21:57:08 +00:00
Support [SectionMemoryManager] Make better use of virtual memory 2015-12-16 11:13:23 +00:00
TableGen [TblGen] ArrayRefize TGParser. No functional change intended. 2015-10-24 12:46:45 +00:00
Target [SystemZ] Sort relocs to avoid code corruption by linker optimization 2015-12-16 18:12:40 +00:00
Transforms [SimplifyCFG] Don't create unnecessary PHIs 2015-12-16 14:12:44 +00:00
CMakeLists.txt LibDriver, llvm-lib: introduce. 2015-06-09 21:50:22 +00:00
LLVMBuild.txt Wrap some long lines in LLVMBuild files. NFC 2015-06-12 18:44:57 +00:00
Makefile LibDriver, llvm-lib: introduce. 2015-06-09 21:50:22 +00:00