summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lld/ELF/Writer.cpp4
-rw-r--r--lld/test/elf2/relocations.test31
2 files changed, 35 insertions, 0 deletions
diff --git a/lld/ELF/Writer.cpp b/lld/ELF/Writer.cpp
index 0dc4f60ad17..e173aac8ecf 100644
--- a/lld/ELF/Writer.cpp
+++ b/lld/ELF/Writer.cpp
@@ -271,8 +271,12 @@ template <class ELFT> void OutputSection<ELFT>::writeTo(uint8_t *Buf) {
SymVA + (RI.r_addend - (P + Offset)));
break;
case llvm::ELF::R_X86_64_32:
+ case llvm::ELF::R_X86_64_32S:
support::endian::write32le(Location, SymVA + RI.r_addend);
break;
+ case llvm::ELF::R_X86_64_64:
+ support::endian::write64le(Location, SymVA + RI.r_addend);
+ break;
default:
llvm::errs() << Twine("unrecognized reloc ") + Twine(Type) << '\n';
break;
diff --git a/lld/test/elf2/relocations.test b/lld/test/elf2/relocations.test
new file mode 100644
index 00000000000..db3d7d00d28
--- /dev/null
+++ b/lld/test/elf2/relocations.test
@@ -0,0 +1,31 @@
+# RUN: yaml2obj -format elf %s -o %t
+# RUN: lld -flavor gnu2 %t -o %tout
+# RUN: llvm-objdump -s %tout | FileCheck %s
+
+FileHeader:
+ Class: ELFCLASS64
+ Data: ELFDATA2LSB
+ Type: ET_REL
+ Machine: EM_X86_64
+Sections:
+ - Name: .text
+ Type: SHT_PROGBITS
+ Size: 512
+ - Name: .rela.text
+ Type: SHT_RELA
+ Info: .text
+ Relocations:
+ - Offset: 0x0000000000000000
+ Symbol: _start
+ Type: R_X86_64_32S
+ - Offset: 0x0000000000000004
+ Symbol: _start
+ Type: R_X86_64_64
+
+Symbols:
+ Global:
+ - Name: _start
+ Section: .text
+ Value: 0x42
+
+# CHECK: 0000 42000000 42000000 00000000 00000000
OpenPOWER on IntegriCloud