From e2b7677c9eeaad6ea23fcd02fefed44efe8771d2 Mon Sep 17 00:00:00 2001 From: Ed Maste Date: Thu, 31 Mar 2016 20:26:30 +0000 Subject: [PATCH] lld: accept and ignore _fbsd suffix in emulation name Differential Revision: http://reviews.llvm.org/D18661 llvm-svn: 265044 --- lld/ELF/Driver.cpp | 6 ++++-- lld/test/ELF/emulation.s | 31 +++++++++++++++++++++++++++++++ 2 files changed, 35 insertions(+), 2 deletions(-) diff --git a/lld/ELF/Driver.cpp b/lld/ELF/Driver.cpp index 9ec302e..eaa27ee 100644 --- a/lld/ELF/Driver.cpp +++ b/lld/ELF/Driver.cpp @@ -46,13 +46,15 @@ bool elf::link(ArrayRef Args, raw_ostream &Error) { } static std::pair parseEmulation(StringRef S) { + if (S.endswith("_fbsd")) + S = S.drop_back(5); if (S == "elf32btsmip") return {ELF32BEKind, EM_MIPS}; if (S == "elf32ltsmip") return {ELF32LEKind, EM_MIPS}; - if (S == "elf32ppc" || S == "elf32ppc_fbsd") + if (S == "elf32ppc") return {ELF32BEKind, EM_PPC}; - if (S == "elf64ppc" || S == "elf64ppc_fbsd") + if (S == "elf64ppc") return {ELF64BEKind, EM_PPC64}; if (S == "elf_i386") return {ELF32LEKind, EM_386}; diff --git a/lld/test/ELF/emulation.s b/lld/test/ELF/emulation.s index a8a8f39..941deca 100644 --- a/lld/test/ELF/emulation.s +++ b/lld/test/ELF/emulation.s @@ -60,6 +60,37 @@ # X86-NEXT: StringTableSectionIndex: # X86-NEXT: } +# RUN: llvm-mc -filetype=obj -triple=i686-unknown-freebsd %s -o %tx86fbsd +# RUN: ld.lld -m elf_i386_fbsd %tx86fbsd -o %t2x86_fbsd +# RUN: llvm-readobj -file-headers %t2x86_fbsd | FileCheck --check-prefix=X86FBSD %s +# RUN: ld.lld %tx86fbsd -o %t3x86fbsd +# RUN: llvm-readobj -file-headers %t3x86fbsd | FileCheck --check-prefix=X86FBSD %s +# X86FBSD: ElfHeader { +# X86FBSD-NEXT: Ident { +# X86FBSD-NEXT: Magic: (7F 45 4C 46) +# X86FBSD-NEXT: Class: 32-bit (0x1) +# X86FBSD-NEXT: DataEncoding: LittleEndian (0x1) +# X86FBSD-NEXT: FileVersion: 1 +# X86FBSD-NEXT: OS/ABI: FreeBSD (0x9) +# X86FBSD-NEXT: ABIVersion: 0 +# X86FBSD-NEXT: Unused: (00 00 00 00 00 00 00) +# X86FBSD-NEXT: } +# X86FBSD-NEXT: Type: Executable (0x2) +# X86FBSD-NEXT: Machine: EM_386 (0x3) +# X86FBSD-NEXT: Version: 1 +# X86FBSD-NEXT: Entry: +# X86FBSD-NEXT: ProgramHeaderOffset: 0x34 +# X86FBSD-NEXT: SectionHeaderOffset: +# X86FBSD-NEXT: Flags [ (0x0) +# X86FBSD-NEXT: ] +# X86FBSD-NEXT: HeaderSize: 52 +# X86FBSD-NEXT: ProgramHeaderEntrySize: 32 +# X86FBSD-NEXT: ProgramHeaderCount: +# X86FBSD-NEXT: SectionHeaderEntrySize: 40 +# X86FBSD-NEXT: SectionHeaderCount: +# X86FBSD-NEXT: StringTableSectionIndex: +# X86FBSD-NEXT: } + # RUN: llvm-mc -filetype=obj -triple=powerpc64-unknown-linux %s -o %tppc64 # RUN: ld.lld -m elf64ppc %tppc64 -o %t2ppc64 # RUN: llvm-readobj -file-headers %t2ppc64 | FileCheck --check-prefix=PPC64 %s -- 2.7.4