[lld] r275236 - Add -m elf32_x86_64.
Rui Ueyama via llvm-commits
llvm-commits at lists.llvm.org
Tue Jul 12 16:28:33 PDT 2016
Author: ruiu
Date: Tue Jul 12 18:28:33 2016
New Revision: 275236
URL: http://llvm.org/viewvc/llvm-project?rev=275236&view=rev
Log:
Add -m elf32_x86_64.
Patch by H.J. Lu.
This patch adds -m elf32_x86_64 to lld. But it doesn't generate working
x32 binaries.
Differential Revision: http://reviews.llvm.org/D22268
Added:
lld/trunk/test/ELF/x86-64-rela.s
Modified:
lld/trunk/ELF/Driver.cpp
lld/trunk/test/ELF/emulation.s
Modified: lld/trunk/ELF/Driver.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Driver.cpp?rev=275236&r1=275235&r2=275236&view=diff
==============================================================================
--- lld/trunk/ELF/Driver.cpp (original)
+++ lld/trunk/ELF/Driver.cpp Tue Jul 12 18:28:33 2016
@@ -62,6 +62,7 @@ static std::pair<ELFKind, uint16_t> pars
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:
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);
Modified: lld/trunk/test/ELF/emulation.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/emulation.s?rev=275236&r1=275235&r2=275236&view=diff
==============================================================================
--- lld/trunk/test/ELF/emulation.s (original)
+++ lld/trunk/test/ELF/emulation.s Tue Jul 12 18:28:33 2016
@@ -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
Added: lld/trunk/test/ELF/x86-64-rela.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/x86-64-rela.s?rev=275236&view=auto
==============================================================================
--- lld/trunk/test/ELF/x86-64-rela.s (added)
+++ lld/trunk/test/ELF/x86-64-rela.s Tue Jul 12 18:28:33 2016
@@ -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 at plt
+
+// CHECK: 0x{{0+}}14 PLTREL{{ +}}RELA
More information about the llvm-commits
mailing list