[llvm-branch-commits] [lld] r352853 - Merging r352606:

Hans Wennborg via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Fri Feb 1 02:48:08 PST 2019


Author: hans
Date: Fri Feb  1 02:48:08 2019
New Revision: 352853

URL: http://llvm.org/viewvc/llvm-project?rev=352853&view=rev
Log:
Merging r352606:
------------------------------------------------------------------------
r352606 | dim | 2019-01-30 07:31:52 +0100 (Wed, 30 Jan 2019) | 27 lines

Recognize FreeBSD specific BFD names in OUTPUT_FORMAT

Summary:
After rLLD344952 ("Add OUTPUT_FORMAT linker script directive support"),
using BFD names such as `elf64-x86-64-freebsd` the `OUTPUT_FORMAT`
linker script command does not work anymore, resulting in errors like:

```
ld: error: /home/dim/src/clang800-import/stand/efi/loader/arch/amd64/ldscript.amd64:2: unknown output format name: elf64-x86-64-freebsd
>>> OUTPUT_FORMAT("elf64-x86-64-freebsd", "elf64-x86-64-freebsd", "elf64-x86-64-freebsd")
>>>               ^
```

To fix this, recognize a `-freebsd` suffix in BFD names, and also set
`Configuration::OSABI` to `ELFOSABI_FREEBSD` for those cases.

Add and/or update several test cases to check for the correct results of
these new `OUTPUT_FORMAT` arguments.

Reviewers: ruiu, atanasyan, grimar, hokein, emaste, espindola

Reviewed By: ruiu

Subscribers: nemanjai, javed.absar, arichardson, krytarowski, kristof.beyls, kbarton, llvm-commits

Differential Revision: https://reviews.llvm.org/D57283

------------------------------------------------------------------------

Modified:
    lld/branches/release_80/   (props changed)
    lld/branches/release_80/ELF/ScriptParser.cpp
    lld/branches/release_80/test/ELF/emulation-aarch64.s
    lld/branches/release_80/test/ELF/emulation-ppc.s
    lld/branches/release_80/test/ELF/emulation-x86.s

Propchange: lld/branches/release_80/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Fri Feb  1 02:48:08 2019
@@ -1 +1 @@
-/lld/trunk:351326,351335,351898-351899,352068,352082,352257,352302,352407,352413,352435,352459,352482
+/lld/trunk:351326,351335,351898-351899,352068,352082,352257,352302,352407,352413,352435,352459,352482,352606

Modified: lld/branches/release_80/ELF/ScriptParser.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/branches/release_80/ELF/ScriptParser.cpp?rev=352853&r1=352852&r2=352853&view=diff
==============================================================================
--- lld/branches/release_80/ELF/ScriptParser.cpp (original)
+++ lld/branches/release_80/ELF/ScriptParser.cpp Fri Feb  1 02:48:08 2019
@@ -390,6 +390,7 @@ static std::pair<ELFKind, uint16_t> pars
       .Case("elf32-iamcu", {ELF32LEKind, EM_IAMCU})
       .Case("elf32-littlearm", {ELF32LEKind, EM_ARM})
       .Case("elf32-x86-64", {ELF32LEKind, EM_X86_64})
+      .Case("elf64-aarch64", {ELF64LEKind, EM_AARCH64})
       .Case("elf64-littleaarch64", {ELF64LEKind, EM_AARCH64})
       .Case("elf64-powerpc", {ELF64BEKind, EM_PPC64})
       .Case("elf64-powerpcle", {ELF64LEKind, EM_PPC64})
@@ -408,11 +409,14 @@ static std::pair<ELFKind, uint16_t> pars
 void ScriptParser::readOutputFormat() {
   expect("(");
 
-  StringRef S = unquote(next());
+  StringRef Name = unquote(next());
+  StringRef S = Name;
+  if (S.consume_back("-freebsd"))
+    Config->OSABI = ELFOSABI_FREEBSD;
 
   std::tie(Config->EKind, Config->EMachine) = parseBfdName(S);
   if (Config->EMachine == EM_NONE)
-    setError("unknown output format name: " + S);
+    setError("unknown output format name: " + Name);
   if (S == "elf32-ntradlittlemips" || S == "elf32-ntradbigmips")
     Config->MipsN32Abi = true;
 

Modified: lld/branches/release_80/test/ELF/emulation-aarch64.s
URL: http://llvm.org/viewvc/llvm-project/lld/branches/release_80/test/ELF/emulation-aarch64.s?rev=352853&r1=352852&r2=352853&view=diff
==============================================================================
--- lld/branches/release_80/test/ELF/emulation-aarch64.s (original)
+++ lld/branches/release_80/test/ELF/emulation-aarch64.s Fri Feb  1 02:48:08 2019
@@ -30,5 +30,28 @@
 # AARCH64-NEXT:   Flags [ (0x0)
 # AARCH64-NEXT:   ]
 
+# RUN: llvm-mc -filetype=obj -triple=aarch64-unknown-freebsd %s -o %taarch64fbsd
+# RUN: echo 'OUTPUT_FORMAT(elf64-aarch64-freebsd)' > %taarch64fbsd.script
+# RUN: ld.lld %taarch64fbsd.script %taarch64fbsd -o %t2aarch64fbsd
+# RUN: llvm-readobj -file-headers %t2aarch64fbsd | FileCheck --check-prefix=AARCH64-FBSD %s
+# AARCH64-FBSD:      ElfHeader {
+# AARCH64-FBSD-NEXT:   Ident {
+# AARCH64-FBSD-NEXT:     Magic: (7F 45 4C 46)
+# AARCH64-FBSD-NEXT:     Class: 64-bit (0x2)
+# AARCH64-FBSD-NEXT:     DataEncoding: LittleEndian (0x1)
+# AARCH64-FBSD-NEXT:     FileVersion: 1
+# AARCH64-FBSD-NEXT:     OS/ABI: FreeBSD (0x9)
+# AARCH64-FBSD-NEXT:     ABIVersion: 0
+# AARCH64-FBSD-NEXT:     Unused: (00 00 00 00 00 00 00)
+# AARCH64-FBSD-NEXT:   }
+# AARCH64-FBSD-NEXT:   Type: Executable (0x2)
+# AARCH64-FBSD-NEXT:   Machine: EM_AARCH64 (0xB7)
+# AARCH64-FBSD-NEXT:   Version: 1
+# AARCH64-FBSD-NEXT:   Entry:
+# AARCH64-FBSD-NEXT:   ProgramHeaderOffset: 0x40
+# AARCH64-FBSD-NEXT:   SectionHeaderOffset:
+# AARCH64-FBSD-NEXT:   Flags [ (0x0)
+# AARCH64-FBSD-NEXT:   ]
+
 .globl _start
 _start:

Modified: lld/branches/release_80/test/ELF/emulation-ppc.s
URL: http://llvm.org/viewvc/llvm-project/lld/branches/release_80/test/ELF/emulation-ppc.s?rev=352853&r1=352852&r2=352853&view=diff
==============================================================================
--- lld/branches/release_80/test/ELF/emulation-ppc.s (original)
+++ lld/branches/release_80/test/ELF/emulation-ppc.s Fri Feb  1 02:48:08 2019
@@ -35,6 +35,38 @@
 # PPC64-NEXT:   StringTableSectionIndex:
 # PPC64-NEXT: }
 
+# RUN: llvm-mc -filetype=obj -triple=powerpc64-unknown-freebsd %s -o %tppc64fbsd
+# RUN: echo 'OUTPUT_FORMAT(elf64-powerpc-freebsd)' > %tppc64fbsd.script
+# RUN: ld.lld %tppc64fbsd.script  %tppc64fbsd -o %t2ppc64fbsd
+# RUN: llvm-readobj -file-headers %t2ppc64fbsd | FileCheck --check-prefix=PPC64-FBSD %s
+
+# PPC64-FBSD:      ElfHeader {
+# PPC64-FBSD-NEXT:   Ident {
+# PPC64-FBSD-NEXT:     Magic: (7F 45 4C 46)
+# PPC64-FBSD-NEXT:     Class: 64-bit (0x2)
+# PPC64-FBSD-NEXT:     DataEncoding: BigEndian (0x2)
+# PPC64-FBSD-NEXT:     FileVersion: 1
+# PPC64-FBSD-NEXT:     OS/ABI: FreeBSD (0x9)
+# PPC64-FBSD-NEXT:     ABIVersion: 0
+# PPC64-FBSD-NEXT:     Unused: (00 00 00 00 00 00 00)
+# PPC64-FBSD-NEXT:   }
+# PPC64-FBSD-NEXT:   Type: Executable (0x2)
+# PPC64-FBSD-NEXT:   Machine: EM_PPC64 (0x15)
+# PPC64-FBSD-NEXT:   Version: 1
+# PPC64-FBSD-NEXT:   Entry:
+# PPC64-FBSD-NEXT:   ProgramHeaderOffset: 0x40
+# PPC64-FBSD-NEXT:   SectionHeaderOffset:
+# PPC64-FBSD-NEXT:   Flags [ (0x2)
+# PPC64-FBSD-NEXT:     0x2
+# PPC64-FBSD-NEXT:   ]
+# PPC64-FBSD-NEXT:   HeaderSize: 64
+# PPC64-FBSD-NEXT:   ProgramHeaderEntrySize: 56
+# PPC64-FBSD-NEXT:   ProgramHeaderCount:
+# PPC64-FBSD-NEXT:   SectionHeaderEntrySize: 64
+# PPC64-FBSD-NEXT:   SectionHeaderCount:
+# PPC64-FBSD-NEXT:   StringTableSectionIndex:
+# PPC64-FBSD-NEXT: }
+
 # RUN: llvm-mc -filetype=obj -triple=powerpc64le-unknown-linux %s -o %tppc64le
 # RUN: ld.lld -m elf64lppc %tppc64le -o %t2ppc64le
 # RUN: llvm-readobj -file-headers %t2ppc64le | FileCheck --check-prefix=PPC64LE %s

Modified: lld/branches/release_80/test/ELF/emulation-x86.s
URL: http://llvm.org/viewvc/llvm-project/lld/branches/release_80/test/ELF/emulation-x86.s?rev=352853&r1=352852&r2=352853&view=diff
==============================================================================
--- lld/branches/release_80/test/ELF/emulation-x86.s (original)
+++ lld/branches/release_80/test/ELF/emulation-x86.s Fri Feb  1 02:48:08 2019
@@ -7,6 +7,9 @@
 # RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t.sysv
 # RUN: ld.lld -m elf_amd64_fbsd %t.sysv -o %t.freebsd
 # RUN: llvm-readobj -file-headers %t.freebsd | FileCheck --check-prefix=AMD64 %s
+# RUN: echo 'OUTPUT_FORMAT(elf64-x86-64-freebsd)' > %t4x64.script
+# RUN: ld.lld %t4x64.script %tx64 -o %t4x64
+# RUN: llvm-readobj -file-headers %t4x64 | FileCheck --check-prefix=AMD64 %s
 # AMD64:      ElfHeader {
 # AMD64-NEXT:   Ident {
 # AMD64-NEXT:     Magic: (7F 45 4C 46)
@@ -137,10 +140,13 @@
 # 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 -m elf_i386_fbsd %tx86fbsd -o %t2x86fbsd
+# RUN: llvm-readobj -file-headers %t2x86fbsd | FileCheck --check-prefix=X86FBSD %s
 # RUN: ld.lld %tx86fbsd -o %t3x86fbsd
 # RUN: llvm-readobj -file-headers %t3x86fbsd | FileCheck --check-prefix=X86FBSD %s
+# RUN: echo 'OUTPUT_FORMAT(elf32-i386-freebsd)' > %t4x86fbsd.script
+# RUN: ld.lld %t4x86fbsd.script %tx86fbsd -o %t4x86fbsd
+# RUN: llvm-readobj -file-headers %t4x86fbsd | FileCheck --check-prefix=X86FBSD %s
 # X86FBSD:      ElfHeader {
 # X86FBSD-NEXT:   Ident {
 # X86FBSD-NEXT:     Magic: (7F 45 4C 46)




More information about the llvm-branch-commits mailing list