diff options
author | George Rimar <grimar@accesssoftek.com> | 2017-01-25 13:36:49 +0000 |
---|---|---|
committer | George Rimar <grimar@accesssoftek.com> | 2017-01-25 13:36:49 +0000 |
commit | f242ffa09581e22dfd3207223ca4e4d3e9327bff (patch) | |
tree | 20c041c7996d055aca9ed2cd47e83aaf1b93c373 | |
parent | a56833b0e7cd47b2ad1ea9b8b25615fa8d81d5fd (diff) | |
download | bcm5719-llvm-f242ffa09581e22dfd3207223ca4e4d3e9327bff.tar.gz bcm5719-llvm-f242ffa09581e22dfd3207223ca4e4d3e9327bff.zip |
[ELF] - Implemented support for R_386_PC8/R_386_8 relocations.
These relocations are used in linux kernel.
Differential revision: https://reviews.llvm.org/D28094
llvm-svn: 293054
-rw-r--r-- | lld/ELF/Target.cpp | 13 | ||||
-rw-r--r-- | lld/test/ELF/Inputs/i386-pc8.s | 2 | ||||
-rw-r--r-- | lld/test/ELF/i386-pc8.s | 13 | ||||
-rw-r--r-- | lld/test/ELF/unknown-reloc.s | 14 |
4 files changed, 26 insertions, 16 deletions
diff --git a/lld/ELF/Target.cpp b/lld/ELF/Target.cpp index d91112d1a4f..b56926a961c 100644 --- a/lld/ELF/Target.cpp +++ b/lld/ELF/Target.cpp @@ -358,6 +358,7 @@ X86TargetInfo::X86TargetInfo() { RelExpr X86TargetInfo::getRelExpr(uint32_t Type, const SymbolBody &S) const { switch (Type) { + case R_386_8: case R_386_16: case R_386_32: case R_386_TLS_LDO_32: @@ -368,6 +369,7 @@ RelExpr X86TargetInfo::getRelExpr(uint32_t Type, const SymbolBody &S) const { return R_TLSLD; case R_386_PLT32: return R_PLT_PC; + case R_386_PC8: case R_386_PC16: case R_386_PC32: return R_PC; @@ -488,6 +490,9 @@ uint64_t X86TargetInfo::getImplicitAddend(const uint8_t *Buf, switch (Type) { default: return 0; + case R_386_8: + case R_386_PC8: + return *Buf; case R_386_16: case R_386_PC16: return read16le(Buf); @@ -507,8 +512,12 @@ void X86TargetInfo::relocateOne(uint8_t *Loc, uint32_t Type, uint64_t Val) const { checkInt<32>(Loc, Val, Type); - // R_386_PC16 and R_386_16 are not part of the current i386 psABI. They are - // used by 16-bit x86 objects, like boot loaders. + // R_386_PC16/R_386_16/R_386_PC8/R_386_8 are not part of the current i386 + // psABI. They are used by 16-bit x86 objects, like boot loaders. + if (Type == R_386_8 || Type == R_386_PC8) { + *Loc = (uint8_t)Val; + return; + } if (Type == R_386_16 || Type == R_386_PC16) { write16le(Loc, Val); return; diff --git a/lld/test/ELF/Inputs/i386-pc8.s b/lld/test/ELF/Inputs/i386-pc8.s new file mode 100644 index 00000000000..370ba33aaf7 --- /dev/null +++ b/lld/test/ELF/Inputs/i386-pc8.s @@ -0,0 +1,2 @@ +.global und +und: diff --git a/lld/test/ELF/i386-pc8.s b/lld/test/ELF/i386-pc8.s new file mode 100644 index 00000000000..d864b888de3 --- /dev/null +++ b/lld/test/ELF/i386-pc8.s @@ -0,0 +1,13 @@ +# REQUIRES: x86 +# RUN: llvm-mc -filetype=obj -triple=i386-pc-linux-gnu %s -o %t1.o +# RUN: llvm-mc -filetype=obj -triple=i386-pc-linux-gnu %S/Inputs/i386-pc8.s -o %t2.o +# RUN: ld.lld %t1.o %t2.o -o %t.out +# RUN: llvm-objdump -s -section=.text %t.out | FileCheck %s + +# CHECK: Contents of section .text: +# CHECK-NEXT: 11000 15253748 + +.byte und-.+0x11 +.byte und-.+0x22 +.byte und+0x33 +.byte und+0x44 diff --git a/lld/test/ELF/unknown-reloc.s b/lld/test/ELF/unknown-reloc.s deleted file mode 100644 index b674a3bbc65..00000000000 --- a/lld/test/ELF/unknown-reloc.s +++ /dev/null @@ -1,14 +0,0 @@ -# REQUIRES: x86 -# RUN: llvm-mc -filetype=obj -triple=i386-pc-linux-gnu %s -o %t1.o -# RUN: llvm-mc -filetype=obj -triple=i386-pc-linux-gnu %S/Inputs/unknown-reloc.s -o %t2.o -# RUN: not ld.lld %t1.o %t2.o -o %t.out 2>&1 | FileCheck %s - -# CHECK: do not know how to handle relocation 'R_386_PC8' (23) -# CHECK: do not know how to handle relocation 'R_386_8' (22) - -.text -.global foo -foo: - -.byte und-foo -.byte foo |