Skip to content

Commit 1152134

Browse files
committed
Merging r353968:
------------------------------------------------------------------------ r353968 | ruiu | 2019-02-13 19:51:15 +0100 (Wed, 13 Feb 2019) | 10 lines Recover elf32-bigmips and elf32-powerpc support in LLD This fixes a 7.0 -> 8.0 regression when parsing OUTPUT_FORMAT("elf32-powerpc"); or elf32-bigmips directive in ldscripts as well as an unknown emulation error when lld is invoked by clang due to missed elf32ppclinux case. Patch by vit9696 Differential Revision: https://reviews.llvm.org/D58005 ------------------------------------------------------------------------ llvm-svn: 354016
1 parent c957a99 commit 1152134

File tree

4 files changed

+43
-2
lines changed

4 files changed

+43
-2
lines changed

lld/ELF/Driver.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ static std::tuple<ELFKind, uint16_t, uint8_t> parseEmulation(StringRef Emul) {
130130
.Cases("elf32btsmip", "elf32btsmipn32", {ELF32BEKind, EM_MIPS})
131131
.Cases("elf32ltsmip", "elf32ltsmipn32", {ELF32LEKind, EM_MIPS})
132132
.Case("elf32lriscv", {ELF32LEKind, EM_RISCV})
133-
.Case("elf32ppc", {ELF32BEKind, EM_PPC})
133+
.Cases("elf32ppc", "elf32ppclinux", {ELF32BEKind, EM_PPC})
134134
.Case("elf64btsmip", {ELF64BEKind, EM_MIPS})
135135
.Case("elf64ltsmip", {ELF64LEKind, EM_MIPS})
136136
.Case("elf64lriscv", {ELF64LEKind, EM_RISCV})

lld/ELF/ScriptParser.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -392,10 +392,11 @@ static std::pair<ELFKind, uint16_t> parseBfdName(StringRef S) {
392392
.Case("elf32-x86-64", {ELF32LEKind, EM_X86_64})
393393
.Case("elf64-aarch64", {ELF64LEKind, EM_AARCH64})
394394
.Case("elf64-littleaarch64", {ELF64LEKind, EM_AARCH64})
395+
.Case("elf32-powerpc", {ELF32BEKind, EM_PPC})
395396
.Case("elf64-powerpc", {ELF64BEKind, EM_PPC64})
396397
.Case("elf64-powerpcle", {ELF64LEKind, EM_PPC64})
397398
.Case("elf64-x86-64", {ELF64LEKind, EM_X86_64})
398-
.Case("elf32-tradbigmips", {ELF32BEKind, EM_MIPS})
399+
.Cases("elf32-tradbigmips", "elf32-bigmips", {ELF32BEKind, EM_MIPS})
399400
.Case("elf32-ntradbigmips", {ELF32BEKind, EM_MIPS})
400401
.Case("elf32-tradlittlemips", {ELF32LEKind, EM_MIPS})
401402
.Case("elf32-ntradlittlemips", {ELF32LEKind, EM_MIPS})

lld/test/ELF/emulation-mips.s

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@
77
# RUN: echo 'OUTPUT_FORMAT(elf32-tradbigmips)' > %tmips.script
88
# RUN: ld.lld %tmips.script -e _start %tmips -o %t4mips
99
# RUN: llvm-readobj -file-headers %t4mips | FileCheck --check-prefix=MIPS %s
10+
# RUN: echo 'OUTPUT_FORMAT(elf32-bigmips)' > %tmips2.script
11+
# RUN: ld.lld %tmips2.script -e _start %tmips -o %t5mips
12+
# RUN: llvm-readobj -file-headers %t5mips | FileCheck --check-prefix=MIPS %s
1013
# MIPS: ElfHeader {
1114
# MIPS-NEXT: Ident {
1215
# MIPS-NEXT: Magic: (7F 45 4C 46)

lld/test/ELF/emulation-ppc.s

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,5 +103,42 @@
103103
# PPC64LE-NEXT: StringTableSectionIndex:
104104
# PPC64LE-NEXT: }
105105

106+
# RUN: llvm-mc -filetype=obj -triple=powerpc-unknown-linux %s -o %tppc32
107+
# RUN: ld.lld -m elf32ppc %tppc32 -o %t2ppc32
108+
# RUN: llvm-readobj -file-headers %t2ppc32 | FileCheck --check-prefix=PPC32 %s
109+
# RUN: ld.lld %tppc32 -o %t3ppc32
110+
# RUN: llvm-readobj -file-headers %t3ppc32 | FileCheck --check-prefix=PPC32 %s
111+
# RUN: echo 'OUTPUT_FORMAT(elf32-powerpc)' > %tppc32.script
112+
# RUN: ld.lld %tppc32.script %tppc32 -o %t4ppc32
113+
# RUN: llvm-readobj -file-headers %t4ppc32 | FileCheck --check-prefix=PPC32 %s
114+
# RUN: ld.lld -m elf32ppclinux %tppc32 -o %t5ppc32
115+
# RUN: llvm-readobj -file-headers %t5ppc32 | FileCheck --check-prefix=PPC32 %s
116+
117+
# PPC32: ElfHeader {
118+
# PPC32-NEXT: Ident {
119+
# PPC32-NEXT: Magic: (7F 45 4C 46)
120+
# PPC32-NEXT: Class: 32-bit (0x1)
121+
# PPC32-NEXT: DataEncoding: BigEndian (0x2)
122+
# PPC32-NEXT: FileVersion: 1
123+
# PPC32-NEXT: OS/ABI: SystemV (0x0)
124+
# PPC32-NEXT: ABIVersion: 0
125+
# PPC32-NEXT: Unused: (00 00 00 00 00 00 00)
126+
# PPC32-NEXT: }
127+
# PPC32-NEXT: Type: Executable (0x2)
128+
# PPC32-NEXT: Machine: EM_PPC (0x14)
129+
# PPC32-NEXT: Version: 1
130+
# PPC32-NEXT: Entry:
131+
# PPC32-NEXT: ProgramHeaderOffset: 0x34
132+
# PPC32-NEXT: SectionHeaderOffset:
133+
# PPC32-NEXT: Flags [ (0x0)
134+
# PPC32-NEXT: ]
135+
# PPC32-NEXT: HeaderSize: 52
136+
# PPC32-NEXT: ProgramHeaderEntrySize: 32
137+
# PPC32-NEXT: ProgramHeaderCount:
138+
# PPC32-NEXT: SectionHeaderEntrySize: 40
139+
# PPC32-NEXT: SectionHeaderCount:
140+
# PPC32-NEXT: StringTableSectionIndex:
141+
# PPC32-NEXT: }
142+
106143
.globl _start
107144
_start:

0 commit comments

Comments
 (0)