Skip to content

Commit 536ba63

Browse files
committed
[Object] Change ELFObjectFile<ELFT>::getFileFormatName() to use BFD names
Follow-up for D74433 What the function returns are almost standard BFD names, except that "ELF" is in uppercase instead of lowercase. This patch changes "ELF" to "elf" and changes ARM/AArch64 to use their BFD names. MIPS and PPC64 have endianness differences as well, but this patch does not intend to address them. Advantages: * llvm-objdump: the "file format " line matches GNU objdump on ARM/AArch64 objects * "file format " line can be extracted and fed into llvm-objcopy -O literally. (ClangBuiltLinux/linux#779 has such a use case) Affected tools: llvm-readobj, llvm-objdump, llvm-dwarfdump, MCJIT (internal implementation detail, not exposed) Reviewed By: jhenderson Differential Revision: https://reviews.llvm.org/D76046
1 parent 185b413 commit 536ba63

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+98
-98
lines changed

lld/test/ELF/basic-ppc.s

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
li 3,1
1010
sc
1111

12-
// CHECK: Format: ELF32-ppc
12+
// CHECK: Format: elf32-powerpc
1313
// CHECK-NEXT: Arch: powerpc
1414
// CHECK-NEXT: AddressSize: 32bit
1515
// CHECK-NEXT: LoadName:

lld/test/ELF/basic-ppc64.s

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
li 3,55
1515
sc
1616

17-
// CHECK:Format: ELF64-ppc64
17+
// CHECK: Format: elf64-powerpc
1818
// LE-NEXT: Arch: powerpc64le
1919
// BE-NEXT: Arch: powerpc64{{$}}
2020
// CHECK-NEXT: AddressSize: 64bit

lld/test/ELF/format-binary.test

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,10 +60,10 @@
6060
# RUN: ld.lld -b binary %t.binary -T %t.script -o %t.out
6161
# RUN: llvm-readobj %t.out -sections -section-data -symbols | FileCheck -check-prefix=X86-64 %s
6262

63-
# X86-64: Format: ELF64-x86-64
63+
# X86-64: Format: elf64-x86-64
6464

6565
# RUN: echo 'OUTPUT_FORMAT("elf64-x86-64")' > %t.script
6666
# RUN: ld.lld -b binary %t.binary -T %t.script -o %t.out
6767
# RUN: llvm-readobj %t.out -sections -section-data -symbols | FileCheck -check-prefix=X86-64-in-quotes %s
6868

69-
# X86-64-in-quotes: Format: ELF64-x86-64
69+
# X86-64-in-quotes: Format: elf64-x86-64

lld/test/ELF/gnu-hash-table.s

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@
6868
# EMPTY-NEXT: Values: []
6969
# EMPTY-NEXT: }
7070

71-
# I386: Format: ELF32-i386
71+
# I386: Format: elf32-i386
7272
# I386: Arch: i386
7373
# I386: AddressSize: 32bit
7474
# I386: Sections [
@@ -127,7 +127,7 @@
127127
# I386-NEXT: Values: [0xB8860BA, 0xB887389]
128128
# I386-NEXT: }
129129

130-
# X86_64: Format: ELF64-x86-64
130+
# X86_64: Format: elf64-x86-64
131131
# X86_64: Arch: x86_64
132132
# X86_64: AddressSize: 64bit
133133
# X86_64: Sections [
@@ -187,7 +187,7 @@
187187
# X86_64-NEXT: Values: [0xB8860BA, 0xB887389]
188188
# X86_64-NEXT: }
189189

190-
# PPC64: Format: ELF64-ppc64
190+
# PPC64: Format: elf64-powerpc
191191
# PPC64: Arch: powerpc64
192192
# PPC64: AddressSize: 64bit
193193
# PPC64: Sections [

lld/test/ELF/linkerscript/linker-script-in-search-path.s

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
# RUN: echo 'OUTPUT("%t.out")' > %t.dir/script
88
# RUN: ld.lld -T%t.dir/script %t.o
99
# RUN: llvm-readobj %t.out | FileCheck %s
10-
# CHECK: Format: ELF64-x86-64
10+
# CHECK: Format: elf64-x86-64
1111

1212
# If the linker script specified with -T is missing we should emit an error
1313
# RUN: not ld.lld -Tscript %t.o 2>&1 | FileCheck %s -check-prefix ERROR

lld/test/ELF/lto/lto-start.ll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
; RUN: ld.lld %t.o -o %t2
44
; RUN: llvm-readobj --symbols %t2 | FileCheck %s
55

6-
; CHECK: Format: ELF64-x86-64
6+
; CHECK: Format: elf64-x86-64
77
; CHECK-NEXT: Arch: x86_64
88
; CHECK-NEXT: AddressSize: 64bit
99

lld/test/ELF/lto/obj-path.ll

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,10 @@
1616
; CHECK-NEXT: T g
1717

1818
; NM1: T f
19-
; ELF1: Format: ELF64-x86-64
19+
; ELF1: Format: elf64-x86-64
2020

2121
; NM2: T g
22-
; ELF2: Format: ELF64-x86-64
22+
; ELF2: Format: elf64-x86-64
2323

2424
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
2525
target triple = "x86_64-unknown-linux-gnu"

lld/test/ELF/lto/thinlto-debug-fission.ll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
; RUN: ld.lld --plugin-opt=dwo_dir=%t.dir -shared %t1.o -o /dev/null
88
; RUN: llvm-readobj -h %t.dir/0.dwo | FileCheck %s
99

10-
; CHECK: Format: ELF64-x86-64
10+
; CHECK: Format: elf64-x86-64
1111

1212
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
1313
target triple = "x86_64-unknown-linux-gnu"

lld/test/ELF/lto/thinlto-obj-path.ll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
; RUN: ld.lld -thinlto-index-only -lto-obj-path=%t4.o -shared %t1.o %t2.o -o /dev/null
1515
; RUN: llvm-readobj -h %t4.o | FileCheck %s
1616

17-
; CHECK: Format: ELF64-x86-64
17+
; CHECK: Format: elf64-x86-64
1818

1919
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
2020
target triple = "x86_64-unknown-linux-gnu"

lld/test/ELF/relocatable-empty-archive.s

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
# RUN: ld.lld -m elf_x86_64 %t.a -o %t -r
55
# RUN: llvm-readobj --file-headers %t | FileCheck %s
66

7-
# CHECK: Format: ELF64-x86-64
7+
# CHECK: Format: elf64-x86-64
88
# CHECK: Arch: x86_64
99
# CHECK: AddressSize: 64bit
1010
# CHECK: Type: Relocatable

lld/test/ELF/relocatable.s

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@
7575
# CHECKTEXT-NEXT: 40: c7 04 25 00 00 00 00 08 00 00 00 movl $8, 0
7676
# CHECKTEXT-NEXT: 4b: c7 04 25 00 00 00 00 09 00 00 00 movl $9, 0
7777

78-
# CHECKEXE: Format: ELF64-x86-64
78+
# CHECKEXE: Format: elf64-x86-64
7979
# CHECKEXE-NEXT: Arch: x86_64
8080
# CHECKEXE-NEXT: AddressSize: 64bit
8181
# CHECKEXE-NEXT: LoadName:

llvm/include/llvm/Object/ELFObjectFile.h

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1060,59 +1060,59 @@ StringRef ELFObjectFile<ELFT>::getFileFormatName() const {
10601060
case ELF::ELFCLASS32:
10611061
switch (EF.getHeader()->e_machine) {
10621062
case ELF::EM_386:
1063-
return "ELF32-i386";
1063+
return "elf32-i386";
10641064
case ELF::EM_IAMCU:
1065-
return "ELF32-iamcu";
1065+
return "elf32-iamcu";
10661066
case ELF::EM_X86_64:
1067-
return "ELF32-x86-64";
1067+
return "elf32-x86-64";
10681068
case ELF::EM_ARM:
1069-
return (IsLittleEndian ? "ELF32-arm-little" : "ELF32-arm-big");
1069+
return (IsLittleEndian ? "elf32-littlearm" : "elf32-bigarm");
10701070
case ELF::EM_AVR:
1071-
return "ELF32-avr";
1071+
return "elf32-avr";
10721072
case ELF::EM_HEXAGON:
1073-
return "ELF32-hexagon";
1073+
return "elf32-hexagon";
10741074
case ELF::EM_LANAI:
1075-
return "ELF32-lanai";
1075+
return "elf32-lanai";
10761076
case ELF::EM_MIPS:
1077-
return "ELF32-mips";
1077+
return "elf32-mips";
10781078
case ELF::EM_MSP430:
1079-
return "ELF32-msp430";
1079+
return "elf32-msp430";
10801080
case ELF::EM_PPC:
1081-
return "ELF32-ppc";
1081+
return "elf32-powerpc";
10821082
case ELF::EM_RISCV:
1083-
return "ELF32-riscv";
1083+
return "elf32-littleriscv";
10841084
case ELF::EM_SPARC:
10851085
case ELF::EM_SPARC32PLUS:
1086-
return "ELF32-sparc";
1086+
return "elf32-sparc";
10871087
case ELF::EM_AMDGPU:
1088-
return "ELF32-amdgpu";
1088+
return "elf32-amdgpu";
10891089
default:
1090-
return "ELF32-unknown";
1090+
return "elf32-unknown";
10911091
}
10921092
case ELF::ELFCLASS64:
10931093
switch (EF.getHeader()->e_machine) {
10941094
case ELF::EM_386:
1095-
return "ELF64-i386";
1095+
return "elf64-i386";
10961096
case ELF::EM_X86_64:
1097-
return "ELF64-x86-64";
1097+
return "elf64-x86-64";
10981098
case ELF::EM_AARCH64:
1099-
return (IsLittleEndian ? "ELF64-aarch64-little" : "ELF64-aarch64-big");
1099+
return (IsLittleEndian ? "elf64-littleaarch64" : "elf64-bigaarch64");
11001100
case ELF::EM_PPC64:
1101-
return "ELF64-ppc64";
1101+
return "elf64-powerpc";
11021102
case ELF::EM_RISCV:
1103-
return "ELF64-riscv";
1103+
return "elf64-littleriscv";
11041104
case ELF::EM_S390:
1105-
return "ELF64-s390";
1105+
return "elf64-s390";
11061106
case ELF::EM_SPARCV9:
1107-
return "ELF64-sparc";
1107+
return "elf64-sparc";
11081108
case ELF::EM_MIPS:
1109-
return "ELF64-mips";
1109+
return "elf64-mips";
11101110
case ELF::EM_AMDGPU:
1111-
return "ELF64-amdgpu";
1111+
return "elf64-amdgpu";
11121112
case ELF::EM_BPF:
1113-
return "ELF64-BPF";
1113+
return "elf64-bpf";
11141114
default:
1115-
return "ELF64-unknown";
1115+
return "elf64-unknown";
11161116
}
11171117
default:
11181118
// FIXME: Proper error handling.

llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldELF.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -554,7 +554,7 @@ void RuntimeDyldELF::setMipsABI(const ObjectFile &Obj) {
554554
IsMipsO32ABI = AbiVariant & ELF::EF_MIPS_ABI_O32;
555555
IsMipsN32ABI = AbiVariant & ELF::EF_MIPS_ABI2;
556556
}
557-
IsMipsN64ABI = Obj.getFileFormatName().equals("ELF64-mips");
557+
IsMipsN64ABI = Obj.getFileFormatName().equals("elf64-mips");
558558
}
559559

560560
// Return the .TOC. section and offset.

llvm/test/CodeGen/AArch64/arm64-simplest-elf.ll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ define void @foo() nounwind {
1111

1212
; Similarly make sure ELF output works and is vaguely sane: aarch64 target
1313
; machine with correct section & symbol names.
14-
; CHECK-ELF: file format elf64-aarch64
14+
; CHECK-ELF: file format elf64-littleaarch64
1515

1616
; CHECK-ELF: Disassembly of section .text
1717
; CHECK-ELF-LABEL: <foo>:

llvm/test/CodeGen/AMDGPU/elf.ll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
; Test that we don't try to produce a COFF file on windows
99
; RUN: llc < %s -mtriple=amdgcn-pc-mingw -verify-machineinstrs -filetype=obj | llvm-readobj -S --symbols --file-headers - | FileCheck --check-prefix=ELF %s
1010

11-
; ELF: Format: ELF64-amdgpu
11+
; ELF: Format: elf64-amdgpu
1212
; ELF: OS/ABI: SystemV (0x0)
1313
; ELF: Machine: EM_AMDGPU (0xE0)
1414
; ELF: Name: .AMDGPU.config

llvm/test/CodeGen/AMDGPU/elf.r600.ll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
; RUN: llc < %s -march=r600 -mcpu=redwood -filetype=obj | llvm-readobj -S - | FileCheck --check-prefix=ELF %s
22
; RUN: llc < %s -march=r600 -mcpu=redwood -o - | FileCheck --check-prefix=CONFIG %s
33

4-
; ELF: Format: ELF32-amdgpu
4+
; ELF: Format: elf32-amdgpu
55
; ELF: Name: .AMDGPU.config
66

77
; CONFIG: .section .AMDGPU.config

llvm/test/DebugInfo/AArch64/big-endian-dump.ll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
; RUN: llc -O0 -filetype=obj -mtriple=aarch64_be-none-linux < %s | llvm-dwarfdump - | FileCheck %s
22

3-
; CHECK: file format ELF64-aarch64-big
3+
; CHECK: file format elf64-bigaarch64
44

55
target datalayout = "E-m:e-i64:64-i128:128-n32:64-S128"
66

llvm/test/DebugInfo/AArch64/little-endian-dump.ll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
; RUN: llc -O0 -filetype=obj -mtriple=aarch64-none-linux < %s | llvm-dwarfdump - | FileCheck %s
22

3-
; CHECK: file format ELF64-aarch64-little
3+
; CHECK: file format elf64-littleaarch64
44

55
target datalayout = "e-m:e-i64:64-i128:128-n32:64-S128"
66

llvm/test/DebugInfo/ARM/big-endian-dump.ll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
; RUN: llc -O0 -filetype=obj -mtriple=armeb-none-linux < %s | llvm-dwarfdump - | FileCheck %s
22

3-
; CHECK: file format ELF32-arm-big
3+
; CHECK: file format elf32-bigarm
44

55
target datalayout = "E-m:e-p:32:32-i64:64-v128:64:128-n32-S64"
66

llvm/test/DebugInfo/ARM/little-endian-dump.ll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
; RUN: llc -O0 -filetype=obj -mtriple=arm-none-linux < %s | llvm-dwarfdump - | FileCheck %s
22

3-
; CHECK: file format ELF32-arm-little
3+
; CHECK: file format elf32-littlearm
44

55
target datalayout = "e-m:e-p:32:32-i64:64-v128:64:128-n32-S64"
66

llvm/test/DebugInfo/Sparc/gnu-window-save.ll

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
; Check for DW_CFA_GNU_Window_save in debug_frame. Also, Ensure that relocations
55
; are performed correctly in debug_info.
66

7-
; SPARC64: file format ELF64-sparc
7+
; SPARC64: file format elf64-sparc
88

99
; SPARC64: .debug_info
1010
; SPARC64: DW_TAG_compile_unit
@@ -20,7 +20,7 @@
2020
; SPARC64-NEXT: DW_CFA_register
2121

2222

23-
; SPARC32: file format ELF32-sparc
23+
; SPARC32: file format elf32-sparc
2424

2525
; SPARC32: .debug_info
2626
; SPARC32: DW_TAG_compile_unit

llvm/test/MC/ARM/dwarf-asm-no-code.s

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
a:
99
.long 42
1010

11-
// DWARF: ELF32-arm-little
11+
// DWARF: elf32-littlearm
1212
// DWARF-NOT: contents:
1313
// DWARF: .debug_line contents:
1414

llvm/test/MC/AVR/dwarf-asm-no-code.s

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
a:
99
.long 42
1010

11-
// DWARF: ELF32-avr
11+
// DWARF: elf32-avr
1212
// DWARF-NOT: contents:
1313
// DWARF: .debug_line contents:
1414

llvm/test/MC/AsmParser/non-english-characters.s

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# RUN: llvm-mc -triple i386-linux-gnu -filetype=obj -o %t \
22
# RUN: %S/Inputs/non-english-characters-comments.s
33
# RUN: llvm-readobj %t | FileCheck %s
4-
# CHECK: Format: ELF32-i386
4+
# CHECK: Format: elf32-i386
55

66
# RUN: not llvm-mc -triple i386-linux-gnu -filetype=obj -o %t \
77
# RUN: %S/Inputs/non-english-characters-section-name.s 2>&1 | \

llvm/test/MC/ELF/empty.s

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
// Check that we can create ELF files for darwin/windows, even though
66
// it is not the default file format.
77

8-
// DARWIN: Format: ELF64-x86-64
9-
// WINDOWS: Format: ELF64-x86-64
8+
// DARWIN: Format: elf64-x86-64
9+
// WINDOWS: Format: elf64-x86-64
1010
// DARWIN-NEXT: Arch: x86_64
1111
// WINDOWS-NEXT: Arch: x86_64
1212

llvm/test/MC/ELF/relocation-386.s

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
// Test that we produce the correct relocation types and that the relocations
55
// correctly point to the section or the symbol.
66

7-
// IAMCU: Format: ELF32-iamcu
8-
// I386: Format: ELF32-i386
7+
// IAMCU: Format: elf32-iamcu
8+
// I386: Format: elf32-i386
99
// CHECK: Relocations [
1010
// CHECK-NEXT: Section {{.*}} .rel.text {
1111
// CHECK-NEXT: 0x2 R_386_GOTOFF .Lfoo 0x0

llvm/test/MC/Hexagon/basic.ll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
;; RUN: llc -mtriple=hexagon-unknown-elf -filetype=obj %s -o - \
22
;; RUN: | llvm-readobj -h -r | FileCheck -check-prefix=OBJ %s
33

4-
; OBJ: Format: ELF32-hexagon
4+
; OBJ: Format: elf32-hexagon
55
; OBJ: Arch: hexagon
66
; OBJ: AddressSize: 32bit
77
; OBJ: Machine: EM_HEXAGON (0xA4)

llvm/test/MC/RISCV/elf-header.s

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
# RUN: llvm-mc %s -filetype=obj -triple=riscv64 | llvm-readobj -h \
44
# RUN: | FileCheck -check-prefix=RV64 %s
55

6-
# RV32: Format: ELF32-riscv
6+
# RV32: Format: elf32-littleriscv
77
# RV32: Arch: riscv32
88
# RV32: AddressSize: 32bit
99
# RV32: ElfHeader {
@@ -22,7 +22,7 @@
2222
# RV32: ]
2323
# RV32: }
2424

25-
# RV64: Format: ELF64-riscv
25+
# RV64: Format: elf64-littleriscv
2626
# RV64: Arch: riscv64
2727
# RV64: AddressSize: 64bit
2828
# RV64: ElfHeader {

llvm/test/MC/Sparc/sparc-relocations.s

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
! RUN: llvm-mc %s -arch=sparcv9 -show-encoding | FileCheck %s
22
! RUN: llvm-mc %s -arch=sparcv9 -filetype=obj | llvm-readobj -r | FileCheck %s --check-prefix=CHECK-OBJ
33

4-
! CHECK-OBJ: Format: ELF64-sparc
4+
! CHECK-OBJ: Format: elf64-sparc
55
! CHECK-OBJ: Relocations [
66
! CHECK-OBJ: 0x{{[0-9,A-F]+}} R_SPARC_WDISP30 foo
77
! CHECK-OBJ: 0x{{[0-9,A-F]+}} R_SPARC_LO10 sym

llvm/test/Object/AMDGPU/elf32-unknown.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# RUN: yaml2obj %s -o %t.o
22
# RUN: llvm-readobj -S --file-headers %t.o | FileCheck %s
33

4-
# CHECK: Format: ELF32-amdgpu
4+
# CHECK: Format: elf32-amdgpu
55

66
--- !ELF
77
FileHeader:

llvm/test/Object/AMDGPU/elf64-unknown.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# RUN: yaml2obj %s -o %t.o
22
# RUN: llvm-readobj -S --file-headers %t.o | FileCheck %s
33

4-
# CHECK: Format: ELF64-amdgpu
4+
# CHECK: Format: elf64-amdgpu
55

66
--- !ELF
77
FileHeader:

0 commit comments

Comments
 (0)