diff options
-rw-r--r-- | lld/ELF/Driver.cpp | 3 | ||||
-rw-r--r-- | lld/test/ELF/emulation.s | 31 | ||||
-rw-r--r-- | lld/test/ELF/x86-64-rela.s | 11 |
3 files changed, 44 insertions, 1 deletions
diff --git a/lld/ELF/Driver.cpp b/lld/ELF/Driver.cpp index fd783ccd6b1..e88a883b16a 100644 --- a/lld/ELF/Driver.cpp +++ b/lld/ELF/Driver.cpp @@ -62,6 +62,7 @@ static std::pair<ELFKind, uint16_t> parseEmulation(StringRef S) { StringSwitch<std::pair<ELFKind, uint16_t>>(S) .Case("aarch64linux", {ELF64LEKind, EM_AARCH64}) .Case("armelf_linux_eabi", {ELF32LEKind, EM_ARM}) + .Case("elf32_x86_64", {ELF32LEKind, EM_X86_64}) .Case("elf32btsmip", {ELF32BEKind, EM_MIPS}) .Case("elf32ltsmip", {ELF32LEKind, EM_MIPS}) .Case("elf32ppc", {ELF32BEKind, EM_PPC}) @@ -512,7 +513,7 @@ template <class ELFT> void LinkerDriver::link(opt::InputArgList &Args) { LinkerScript<ELFT> LS; Script<ELFT>::X = &LS; - Config->Rela = ELFT::Is64Bits; + Config->Rela = ELFT::Is64Bits || Config->EMachine == EM_X86_64; Config->Mips64EL = (Config->EMachine == EM_MIPS && Config->EKind == ELF64LEKind); diff --git a/lld/test/ELF/emulation.s b/lld/test/ELF/emulation.s index f61ca95fecb..7cc764fc6c1 100644 --- a/lld/test/ELF/emulation.s +++ b/lld/test/ELF/emulation.s @@ -29,6 +29,37 @@ # X86-64-NEXT: StringTableSectionIndex: # X86-64-NEXT: } +# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux-gnux32 %s -o %tx32 +# RUN: ld.lld -m elf32_x86_64 %tx32 -o %t2x32 +# RUN: llvm-readobj -file-headers %t2x32 | FileCheck --check-prefix=X32 %s +# RUN: ld.lld %tx32 -o %t3x32 +# RUN: llvm-readobj -file-headers %t3x32 | FileCheck --check-prefix=X32 %s +# X32: ElfHeader { +# X32-NEXT: Ident { +# X32-NEXT: Magic: (7F 45 4C 46) +# X32-NEXT: Class: 32-bit (0x1) +# X32-NEXT: DataEncoding: LittleEndian (0x1) +# X32-NEXT: FileVersion: 1 +# X32-NEXT: OS/ABI: SystemV (0x0) +# X32-NEXT: ABIVersion: 0 +# X32-NEXT: Unused: (00 00 00 00 00 00 00) +# X32-NEXT: } +# X32-NEXT: Type: Executable (0x2) +# X32-NEXT: Machine: EM_X86_64 (0x3E) +# X32-NEXT: Version: 1 +# X32-NEXT: Entry: +# X32-NEXT: ProgramHeaderOffset: 0x34 +# X32-NEXT: SectionHeaderOffset: +# X32-NEXT: Flags [ (0x0) +# X32-NEXT: ] +# X32-NEXT: HeaderSize: 52 +# X32-NEXT: ProgramHeaderEntrySize: 32 +# X32-NEXT: ProgramHeaderCount: +# X32-NEXT: SectionHeaderEntrySize: 40 +# X32-NEXT: SectionHeaderCount: +# X32-NEXT: StringTableSectionIndex: +# X32-NEXT: } + # RUN: llvm-mc -filetype=obj -triple=i686-unknown-linux %s -o %tx86 # RUN: ld.lld -m elf_i386 %tx86 -o %t2x86 # RUN: llvm-readobj -file-headers %t2x86 | FileCheck --check-prefix=X86 %s diff --git a/lld/test/ELF/x86-64-rela.s b/lld/test/ELF/x86-64-rela.s new file mode 100644 index 00000000000..41bdd76de4c --- /dev/null +++ b/lld/test/ELF/x86-64-rela.s @@ -0,0 +1,11 @@ +// REQUIRES: x86 +// RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %s -o %t.o +// RUN: ld.lld %t.o -o %t.so -shared +// RUN: llvm-readobj -dynamic-table %t.so | FileCheck %s +// RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux-gnux32 %s -o %t.o +// RUN: ld.lld %t.o -o %t.so -shared +// RUN: llvm-readobj -dynamic-table %t.so | FileCheck %s + + call foo@plt + +// CHECK: 0x{{0+}}14 PLTREL{{ +}}RELA |