Skip to content

Commit

Permalink
[llvm-objdump] Print file format in lowercase to match GNU output.
Browse files Browse the repository at this point in the history
Summary:
GNU objdump prints the file format in lowercase, e.g. `elf64-x86-64`. llvm-objdump prints `ELF64-x86-64` right now, even though piping that into llvm-objcopy refuses that as a valid arch to use.

As an example of a problem this causes, see: ClangBuiltLinux/linux#779

Reviewers: MaskRay, jhenderson, alexshap

Reviewed By: MaskRay

Subscribers: tpimh, sbc100, grimar, jvesely, nhaehnle, kerbowa, cfe-commits, llvm-commits

Tags: #clang, #llvm

Differential Revision: https://reviews.llvm.org/D74433
  • Loading branch information
rupprecht authored and arichardson committed Apr 1, 2020
2 parents 443c104 + 60a8a50 commit 8fc8522
Show file tree
Hide file tree
Showing 25 changed files with 47 additions and 47 deletions.
6 changes: 3 additions & 3 deletions clang/test/Modules/pch_container.m
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@


// RUN: llvm-objdump --section-headers %t-MachO/DependsOnModule.pcm %t-ELF/DependsOnModule.pcm %t-COFF/DependsOnModule.pcm | FileCheck %s
// CHECK: file format Mach-O 64-bit x86-64
// CHECK: file format mach-o 64-bit x86-64
// CHECK: __clangast {{[0-9a-f]+}} {{[0-9a-f]+}} DATA
// CHECK: file format ELF64-x86-64
// CHECK: file format elf64-x86-64
// CHECK: __clangast {{[0-9a-f]+}} {{[0-9a-f]+}} DATA
// CHECK: file format COFF-x86-64
// CHECK: file format coff-x86-64
// CHECK: clangast {{[0-9a-f]+}} {{[0-9a-f]+}}

// RUN: not llvm-objdump --section-headers %t-raw/DependsOnModule.pcm
Expand Down
2 changes: 1 addition & 1 deletion lld/test/COFF/savetemps.ll
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
; RUN: FileCheck --check-prefix=CHECK-OBJDUMP %s

; CHECK: define i32 @main()
; CHECK-OBJDUMP: file format COFF
; CHECK-OBJDUMP: file format coff

target datalayout = "e-m:w-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-pc-windows-msvc"
Expand Down
2 changes: 1 addition & 1 deletion llvm/test/CodeGen/AArch64/arm64-simplest-elf.ll
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ define void @foo() nounwind {

; Similarly make sure ELF output works and is vaguely sane: aarch64 target
; machine with correct section & symbol names.
; CHECK-ELF: file format ELF64-aarch64
; CHECK-ELF: file format elf64-aarch64

; CHECK-ELF: Disassembly of section .text
; CHECK-ELF-LABEL: foo:
Expand Down
2 changes: 1 addition & 1 deletion llvm/test/CodeGen/ARM/Windows/trivial-gnu-object.ll
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
; RUN: llc -mtriple=thumbv7-windows-gnu -filetype=obj -o - %s | llvm-objdump -d - | FileCheck %s

define void @foo() {
; CHECK: file format COFF-ARM
; CHECK: file format coff-arm

; CHECK-LABEL: foo:
; CHECK: bx lr
Expand Down
2 changes: 1 addition & 1 deletion llvm/test/CodeGen/BPF/reloc-btf-2.ll
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ define dso_local i32 @test() local_unnamed_addr #0 !dbg !14 {
ret i32 %3, !dbg !24
}

; CHECK-RELOC: file format ELF64-BPF
; CHECK-RELOC: file format elf64-bpf
; CHECK-RELOC: RELOCATION RECORDS FOR [.BTF]:
; CHECK-RELOC: R_BPF_NONE .bss
; CHECK-RELOC: R_BPF_NONE g
Expand Down
2 changes: 1 addition & 1 deletion llvm/test/CodeGen/BPF/reloc-btf.ll
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ entry:
ret i32 0, !dbg !11
}

; CHECK-RELOC: file format ELF64-BPF
; CHECK-RELOC: file format elf64-bpf
; CHECK-RELOC: RELOCATION RECORDS FOR [.debug_info]:
; CHECK-RELOC: R_BPF_64_32 .debug_abbrev
; CHECK-RELOC: R_BPF_64_64 .text
Expand Down
2 changes: 1 addition & 1 deletion llvm/test/CodeGen/BPF/reloc.ll
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ define i32 @bpf_prog1(%struct.bpf_context* nocapture %ctx) #0 section "events/ne
; <label>:13 ; preds = %10, %0
ret i32 0

; CHECK-RELOC: file format ELF64-BPF
; CHECK-RELOC: file format elf64-bpf
; CHECK-RELOC: RELOCATION RECORDS FOR [.eh_frame]:
; CHECK-RELOC: R_BPF_64_64 events/net/netif_receive_skb
}
Expand Down
2 changes: 1 addition & 1 deletion llvm/test/Object/AMDGPU/objdump.s
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ BB5:
v_lshlrev_b32_e32 v7, 2, v7
s_endpgm

// CHECK: file format ELF64-amdgpu
// CHECK: file format elf64-amdgpu
// CHECK: Disassembly of section .text:
// CHECK: hello_world:
// CHECK: s_mov_b32 m0, 0x10000 // 000000000100: BEFC00FF 00010000
Expand Down
12 changes: 6 additions & 6 deletions llvm/test/Object/X86/objdump-disassembly-inline-relocations.test
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# RUN: llvm-objdump -d -r %p/../Inputs/trivial-object-test.coff-i386 \
# RUN: | FileCheck %s -check-prefix COFF-i386

# COFF-i386: file format COFF-i386
# COFF-i386: file format coff-i386
# COFF-i386: Disassembly of section .text:
# COFF-i386: 0: 83 ec 0c subl $12, %esp
# COFF-i386: 3: c7 44 24 08 00 00 00 00 movl $0, 8(%esp)
Expand All @@ -18,7 +18,7 @@
# RUN: llvm-objdump -d -r %p/../Inputs/trivial-object-test.coff-x86-64 \
# RUN: | FileCheck %s -check-prefix COFF-x86-64

# COFF-x86-64: file format COFF-x86-64
# COFF-x86-64: file format coff-x86-64
# COFF-x86-64: Disassembly of section .text:
# COFF-x86-64: 0: 48 83 ec 28 subq $40, %rsp
# COFF-x86-64: 4: c7 44 24 24 00 00 00 00 movl $0, 36(%rsp)
Expand All @@ -35,7 +35,7 @@
# RUN: llvm-objdump -d -r %p/../Inputs/trivial-object-test.macho-i386 \
# RUN: | FileCheck %s -check-prefix MACHO-i386

# MACHO-i386: file format Mach-O 32-bit i386
# MACHO-i386: file format mach-o 32-bit i386
# MACHO-i386: Disassembly of section __TEXT,__text:
# MACHO-i386: _main:
# MACHO-i386: 0: 83 ec 0c subl $12, %esp
Expand All @@ -53,7 +53,7 @@
# RUN: llvm-objdump -d -r %p/../Inputs/trivial-object-test.macho-x86-64 \
# RUN: | FileCheck %s -check-prefix MACHO-x86-64

# MACHO-x86-64: file format Mach-O 64-bit x86-64
# MACHO-x86-64: file format mach-o 64-bit x86-64
# MACHO-x86-64: Disassembly of section __TEXT,__text:
# MACHO-x86-64: _main:
# MACHO-x86-64: 0: 48 83 ec 08 subq $8, %rsp
Expand All @@ -72,7 +72,7 @@
# RUN: yaml2obj --docnum=1 %s -o %t.elf-i386
# RUN: llvm-objdump -d -r %t.elf-i386 | FileCheck %s -check-prefix ELF-i386

# ELF-i386: file format ELF32-i386
# ELF-i386: file format elf32-i386
# ELF-i386: Disassembly of section .text:
# ELF-i386: main:
# ELF-i386: 0: 83 ec 0c subl $12, %esp
Expand Down Expand Up @@ -170,7 +170,7 @@ Symbols:
- Name: puts
Binding: STB_GLOBAL

# ELF-x86-64: file format ELF64-x86-64
# ELF-x86-64: file format elf64-x86-64
# ELF-x86-64: Disassembly of section .text:
# ELF-x86-64: main:
# ELF-x86-64: 0: 48 83 ec 08 subq $8, %rsp
Expand Down
2 changes: 1 addition & 1 deletion llvm/test/Object/X86/objdump-label.test
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
RUN: llvm-objdump -d %p/../Inputs/trivial-label-test.elf-x86-64 \
RUN: | FileCheck %s -check-prefix ELF-x86-64

ELF-x86-64: file format ELF64-x86-64
ELF-x86-64: file format elf64-x86-64
ELF-x86-64: Disassembly of section .text:
ELF-x86-64: foo:
ELF-x86-64: 0: 90 nop
Expand Down
8 changes: 4 additions & 4 deletions llvm/test/Object/X86/objdump-trivial-object.test
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# RUN: llvm-objdump -d %p/../Inputs/trivial-object-test.coff-i386 \
# RUN: | FileCheck %s -check-prefix COFF-i386

# COFF-i386: file format COFF-i386
# COFF-i386: file format coff-i386
# COFF-i386: Disassembly of section .text:
# COFF-i386: 0: 83 ec 0c subl $12, %esp
# COFF-i386: 3: c7 44 24 08 00 00 00 00 movl $0, 8(%esp)
Expand All @@ -15,7 +15,7 @@
# RUN: llvm-objdump -d %p/../Inputs/trivial-object-test.coff-x86-64 \
# RUN: | FileCheck %s -check-prefix COFF-x86-64

# COFF-x86-64: file format COFF-x86-64
# COFF-x86-64: file format coff-x86-64
# COFF-x86-64: Disassembly of section .text:
# COFF-x86-64: 0: 48 83 ec 28 subq $40, %rsp
# COFF-x86-64: 4: c7 44 24 24 00 00 00 00 movl $0, 36(%rsp)
Expand All @@ -29,7 +29,7 @@
# RUN: yaml2obj --docnum=1 %s -o %t.elf-i386
# RUN: llvm-objdump -d %t.elf-i386 | FileCheck %s -check-prefix ELF-i386

# ELF-i386: file format ELF32-i386
# ELF-i386: file format elf32-i386
# ELF-i386: Disassembly of section .text:
# ELF-i386: 0: 83 ec 0c subl $12, %esp
# ELF-i386: 3: c7 44 24 08 00 00 00 00 movl $0, 8(%esp)
Expand All @@ -55,7 +55,7 @@ Sections:
# RUN: yaml2obj --docnum=2 %s -o %t.elf-x86-64
# RUN: llvm-objdump -d %t.elf-x86-64 | FileCheck %s -check-prefix ELF-x86-64

# ELF-x86-64: file format ELF64-x86-64
# ELF-x86-64: file format elf64-x86-64
# ELF-x86-64: Disassembly of section .text:
# ELF-x86-64: 0: 48 83 ec 08 subq $8, %rsp
# ELF-x86-64: 4: c7 44 24 04 00 00 00 00 movl $0, 4(%rsp)
Expand Down
2 changes: 1 addition & 1 deletion llvm/test/Object/dynamic-reloc.test
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@ READOBJ-NEXT: ]

RUN: llvm-objdump -r %p/Inputs/dynamic-reloc.so | FileCheck --check-prefix=OBJDUMP %s

OBJDUMP: file format ELF64-x86-64
OBJDUMP: file format elf64-x86-64
OBJDUMP-NOT: RELOCATION
2 changes: 1 addition & 1 deletion llvm/test/Object/objdump-symbol-table.test
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ Symbols:
# RUN: llvm-objdump -t %p/Inputs/trivial-object-test.macho-i386 \
# RUN: | FileCheck %s -check-prefix macho-i386

# macho-i386: trivial-object-test.macho-i386: file format Mach-O 32-bit i386
# macho-i386: trivial-object-test.macho-i386: file format mach-o 32-bit i386
# macho-i386: SYMBOL TABLE:
# macho-i386: 00000000 g F __TEXT,__text _main
# macho-i386: 00000000 *UND* _SomeOtherFunction
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# RUN: yaml2obj %p/Inputs/simple-executable-x86_64.yaml -o %t
# RUN: llvm-objdump -d %t | FileCheck %s

# CHECK: : file format ELF64-x86-64
# CHECK: : file format elf64-x86-64
# CHECK-EMPTY:
# CHECK-EMPTY:
# CHECK-NEXT: Disassembly of section .text:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
# RUN: --implicit-check-not=other

# Match this line so the implicit check-nots don't match the path.
# CHECK: {{^.*}}file format ELF64-x86-64
# CHECK: {{^.*}}file format elf64-x86-64

# CHECK: 0000000000004000 first:
# CHECK: 0000000000004001 second:
Expand Down
2 changes: 1 addition & 1 deletion llvm/test/tools/llvm-objdump/X86/elf-dynamic-relocs.test
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
# RUN: llvm-objdump --dynamic-reloc %t | FileCheck --implicit-check-not=R_X86 %s
# RUN: llvm-objdump -R %t | FileCheck --implicit-check-not=R_X86 %s

# CHECK: file format ELF64-x86-64
# CHECK: file format elf64-x86-64
# CHECK: DYNAMIC RELOCATION RECORDS
# CHECK-NEXT: 0000000000000000 R_X86_64_RELATIVE *ABS*
# CHECK-NEXT: 0000000000000000 R_X86_64_JUMP_SLOT bar
Expand Down
2 changes: 1 addition & 1 deletion llvm/test/tools/llvm-objdump/X86/output-ordering.test
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
## --reloc, so we test them independently.

## File headers (-f)
# CHECK: file format ELF64-x86-64
# CHECK: file format elf64-x86-64
# CHECK: architecture: x86_64
# CHECK: start address: 0x0000000000000000
## Private headers (-p)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ FileHeader:

# CHECK: warning: {{.*}}: failed to disassemble missing function foo

# MULTI: file format ELF64-x86-64
# MULTI: file format elf64-x86-64
# MULTI: warning: {{.*}}: failed to disassemble missing function foo
# MULTI: file format ELF64-x86-64
# MULTI: file format elf64-x86-64
# MULTI: warning: {{.*}}: failed to disassemble missing function foo
6 changes: 3 additions & 3 deletions llvm/test/tools/llvm-objdump/all-headers.test
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
## --section-headers --private-headers --reloc --syms (-afhprt). Test for them
## in the following order which provides GNU objdump compatability.

# CHECK: file format ELF64-x86-64
# CHECK: file format elf64-x86-64
# CHECK-EMPTY:
# CHECK-NEXT: architecture: x86_64
# CHECK-NEXT: start address: 0x0000000000000000
Expand All @@ -25,7 +25,7 @@
# RUN: llvm-ar rcs %t.a %t %t2
# RUN: llvm-objdump --all-headers %t.a | FileCheck %s --check-prefix=ARCHIVE

# ARCHIVE: {{.*}}.a({{.*}}): file format ELF64-x86-64
# ARCHIVE: {{.*}}.a({{.*}}): file format elf64-x86-64
# ARCHIVE: rw-r--r--
# ARCHIVE: architecture: x86_64
# ARCHIVE: start address: 0x0000000000000000
Expand All @@ -34,7 +34,7 @@
# ARCHIVE: Sections:
# ARCHIVE: SYMBOL TABLE:
# ARCHIVE: RELOCATION RECORDS FOR [.text]:
# ARCHIVE: {{.*}}.a({{.*}}2): file format ELF64-x86-64
# ARCHIVE: {{.*}}.a({{.*}}2): file format elf64-x86-64
# ARCHIVE: rw-r--r--
# ARCHIVE: architecture: x86_64
# ARCHIVE: start address: 0x0000000000000000
Expand Down
18 changes: 9 additions & 9 deletions llvm/test/tools/llvm-objdump/archive-headers.test
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
# RUN: llvm-objdump -a %p/Inputs/liblong_filenames.a | FileCheck %s
# RUN: llvm-objdump -archive-headers %p/Inputs/liblong_filenames.a | FileCheck %s

# CHECK: {{.*}}liblong_filenames.a(1.o): file format ELF64-x86-64
# CHECK: {{.*}}liblong_filenames.a(1.o): file format elf64-x86-64
# CHECK: rw-r--r-- 204299/200 1416 {{.*}} 1.o
# CHECK: {{.*}}liblong_filenames.a(2.o): file format ELF64-x86-64
# CHECK: {{.*}}liblong_filenames.a(2.o): file format elf64-x86-64
# CHECK: rw-r--r-- 204299/200 1224 {{.*}} 2.o
# CHECK: {{.*}}liblong_filenames.a(3.o): file format ELF64-x86-64
# CHECK: {{.*}}liblong_filenames.a(3.o): file format elf64-x86-64
# CHECK: rw-r--r-- 204299/200 1312 {{.*}} 3.o
# CHECK: {{.*}}liblong_filenames.a(4.o): file format ELF64-x86-64
# CHECK: {{.*}}liblong_filenames.a(4.o): file format elf64-x86-64
# CHECK: rw-r--r-- 204299/200 957 {{.*}} 4.o
# CHECK: {{.*}}liblong_filenames.a(5.o): file format ELF64-x86-64
# CHECK: {{.*}}liblong_filenames.a(5.o): file format elf64-x86-64
# CHECK: rw-r--r-- 204299/200 951 {{.*}} 5.o
# CHECK: {{.*}}liblong_filenames.a(6.o): file format ELF64-x86-64
# CHECK: {{.*}}liblong_filenames.a(6.o): file format elf64-x86-64
# CHECK: rw-r--r-- 204299/200 951 {{.*}} 6.o
# CHECK: {{.*}}liblong_filenames.a(abcdefghijklmnopqrstuvwxyz1.o): file format ELF64-x86-64
# CHECK: {{.*}}liblong_filenames.a(abcdefghijklmnopqrstuvwxyz1.o): file format elf64-x86-64
# CHECK: rw-r--r-- 204299/200 977 {{.*}} abcdefghijklmnopqrstuvwxyz1.o
# CHECK: {{.*}}liblong_filenames.a(abcdefghijklmnopqrstuvwxyz2.o): file format ELF64-x86-64
# CHECK: {{.*}}liblong_filenames.a(abcdefghijklmnopqrstuvwxyz2.o): file format elf64-x86-64
# CHECK: rw-r--r-- 204299/200 1272 {{.*}} abcdefghijklmnopqrstuvwxyz2.o
# CHECK: {{.*}}liblong_filenames.a(abcdefghijklmnopq.o): file format ELF64-x86-64
# CHECK: {{.*}}liblong_filenames.a(abcdefghijklmnopq.o): file format elf64-x86-64
# CHECK: rw-r--r-- 204299/200 977 {{.*}} abcdefghijklmnopq.o
2 changes: 1 addition & 1 deletion llvm/test/tools/llvm-objdump/file-headers-coff.test
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@ header: !Header
sections:
symbols:

# CHECK: [[FILE]]: file format COFF-i386
# CHECK: [[FILE]]: file format coff-i386
# CHECK: architecture: i386
# CHECK: start address: 0x00000000
4 changes: 2 additions & 2 deletions llvm/test/tools/llvm-objdump/file-headers-elf.test
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@ FileHeader:
Machine: EM_X86_64
Entry: 0x123456789abcde

# ELF64: [[FILE]]: file format ELF64-x86-64
# ELF64: [[FILE]]: file format elf64-x86-64
# ELF64: architecture: x86_64
# ELF64: start address: 0x00123456789abcde

# RUN: yaml2obj --docnum=2 %s -o %t-i386
# RUN: llvm-objdump -f %t-i386 | FileCheck -DFILE=%t-i386 %s -check-prefix ELF32
# RUN: llvm-objdump -file-headers %t-i386 | FileCheck %s -DFILE=%t-i386 -check-prefix ELF32

# ELF32: [[FILE]]: file format ELF32-i386
# ELF32: [[FILE]]: file format elf32-i386
# ELF32: architecture: i386
# ELF32: start address: 0x12345678

Expand Down
2 changes: 1 addition & 1 deletion llvm/test/tools/llvm-objdump/non-archive-object.test
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# RUN: llvm-objdump -a %t | FileCheck %s

# If this test has not crashed, then this test passed.
# CHECK: file format ELF64-x86-64
# CHECK: file format elf64-x86-64

!ELF
FileHeader:
Expand Down
2 changes: 1 addition & 1 deletion llvm/test/tools/llvm-objdump/relocations-in-nonreloc.test
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
# RUN: yaml2obj --docnum=3 %s -o %t3
# RUN: llvm-objdump -r %t3 | FileCheck %s -DFILE=%t3 --check-prefixes=FMT,REL --implicit-check-not={{.}}

# FMT: [[FILE]]: file format ELF64-x86-64
# FMT: [[FILE]]: file format elf64-x86-64

# REL: RELOCATION RECORDS FOR []:
# REL-NEXT: OFFSET TYPE VALUE
Expand Down
2 changes: 1 addition & 1 deletion llvm/tools/llvm-objdump/llvm-objdump.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2330,7 +2330,7 @@ static void dumpObject(ObjectFile *O, const Archive *A = nullptr,
outs() << A->getFileName() << "(" << O->getFileName() << ")";
else
outs() << O->getFileName();
outs() << ":\tfile format " << O->getFileFormatName() << "\n\n";
outs() << ":\tfile format " << O->getFileFormatName().lower() << "\n\n";
}

if (StartAddress.getNumOccurrences() || StopAddress.getNumOccurrences())
Expand Down

0 comments on commit 8fc8522

Please sign in to comment.