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

llvm-svn: 275236
This commit is contained in:
Rui Ueyama 2016-07-12 23:28:33 +00:00
parent 46626e1f04
commit 1e52f25d46
3 changed files with 44 additions and 1 deletions

View File

@ -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);

View File

@ -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

View File

@ -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