[llvm] 56fa498 - [llvm-objdump] Add testing for --print-imm-hex, --headers, --section-headers and --private-headers
via llvm-commits
llvm-commits at lists.llvm.org
Tue Jun 29 09:06:10 PDT 2021
Author: gbreynoo
Date: 2021-06-29T17:03:21+01:00
New Revision: 56fa49878b71a1d92b9a93b586cff26829abe157
URL: https://github.com/llvm/llvm-project/commit/56fa49878b71a1d92b9a93b586cff26829abe157
DIFF: https://github.com/llvm/llvm-project/commit/56fa49878b71a1d92b9a93b586cff26829abe157.diff
LOG: [llvm-objdump] Add testing for --print-imm-hex, --headers, --section-headers and --private-headers
llvm-objdump had some missing coverage that is fixed by this change:
- A test specifically for --print-imm-hex, and coverage of --no-print-imm-hex
- section-headers.test checks the aliases --headers or --section-headers
- A test for the use of --private-headers for ELF that checks the output
- A test for ELF program headers
Differential Revision: https://reviews.llvm.org/D103974
Added:
llvm/test/tools/llvm-objdump/ELF/private-headers.test
llvm/test/tools/llvm-objdump/ELF/program-headers.test
llvm/test/tools/llvm-objdump/X86/print-imm-hex.s
Modified:
llvm/test/tools/llvm-objdump/section-headers.test
Removed:
################################################################################
diff --git a/llvm/test/tools/llvm-objdump/ELF/private-headers.test b/llvm/test/tools/llvm-objdump/ELF/private-headers.test
new file mode 100644
index 000000000000..bf18f5810c57
--- /dev/null
+++ b/llvm/test/tools/llvm-objdump/ELF/private-headers.test
@@ -0,0 +1,65 @@
+## Check that with ELF input --private-headers outputs the program header,
+## dynamic section and version definitions.
+# RUN: yaml2obj %s -o %t
+# RUN: llvm-objdump --private-headers %t | FileCheck %s
+
+# CHECK: Program Header:
+# CHECK-NEXT: LOAD off 0x00000000000000b0 vaddr 0x0000000000001000 paddr 0x0000000000001000 align 2**0
+# CHECK-NEXT: filesz 0x000000000000003d memsz 0x000000000000003d flags ---
+# CHECK-NEXT: DYNAMIC off 0x00000000000000cd vaddr 0x000000000000101d paddr 0x000000000000101d align 2**0
+# CHECK-NEXT: filesz 0x0000000000000020 memsz 0x0000000000000020 flags ---
+# CHECK: Dynamic Section:
+# CHECK-NEXT: NEEDED bar
+# CHECK: Version definitions:
+# CHECK-NEXT: 1 0x01 0x075bcd15 foo
+# CHECK-NEXT: 2 0x02 0x3ade68b1 VERSION_1
+# CHECK-NEXT: VERSION_2
+
+--- !ELF
+FileHeader:
+ Class: ELFCLASS64
+ Data: ELFDATA2LSB
+ Type: ET_EXEC
+ Machine: EM_X86_64
+Sections:
+ - Name: .dynstr
+ Type: SHT_STRTAB
+ Address: 0x1000
+ Content: "0062617200666F6F0056455253494F4E5F320056455253494F4E5F3100"
+ # Content is: bar, foo, VERSION_2, VERSION_1
+ - Name: .dynamic
+ Type: SHT_DYNAMIC
+ Flags: [ SHF_ALLOC ]
+ Entries:
+ - Tag: DT_NEEDED
+ Value: 0x1
+ - Tag: DT_NULL
+ Value: 0x0
+ - Name: .gnu.version_d
+ Type: SHT_GNU_verdef
+ Entries:
+ - Version: 1
+ Flags: 1
+ VersionNdx: 1
+ Hash: 123456789
+ Names:
+ - foo
+ - Version: 1
+ Flags: 2
+ VersionNdx: 2
+ Hash: 987654321
+ Names:
+ - VERSION_1
+ - VERSION_2
+ProgramHeaders:
+ - Type: PT_LOAD
+ VAddr: 0x1000
+ FirstSec: .dynstr
+ LastSec: .dynamic
+ - Type: PT_DYNAMIC
+ VAddr: 0x101D
+ FirstSec: .dynamic
+ LastSec: .dynamic
+DynamicSymbols:
+ - Name: bar
+ Binding: STB_GLOBAL
diff --git a/llvm/test/tools/llvm-objdump/ELF/program-headers.test b/llvm/test/tools/llvm-objdump/ELF/program-headers.test
new file mode 100644
index 000000000000..4c61e974d6db
--- /dev/null
+++ b/llvm/test/tools/llvm-objdump/ELF/program-headers.test
@@ -0,0 +1,324 @@
+## Check that program headers are output correctly
+
+# RUN: yaml2obj --docnum=1 -DBITS=32 -DMACHINE=EM_386 %s -o %t32.elf
+# RUN: llvm-objdump --private-headers %t32.elf | FileCheck %s --check-prefixes=ELF32
+
+# ELF32: Program Header:
+# ELF32-NEXT: PHDR off 0x00000314 vaddr 0x00001000 paddr 0x00001000 align 2**0
+# ELF32-NEXT: filesz 0x00000003 memsz 0x00000003 flags -w-
+# ELF32-NEXT: PHDR off 0x00000317 vaddr 0x00002000 paddr 0x00002000 align 2**0
+# ELF32-NEXT: filesz 0x00000007 memsz 0x00000007 flags --x
+# ELF32-NEXT: UNKNOWN off 0x00000317 vaddr 0x00002000 paddr 0x00002000 align 2**0
+# ELF32-NEXT: filesz 0x00000007 memsz 0x00000007 flags --x
+# ELF32-NEXT: DYNAMIC off 0x00000324 vaddr 0x00006000 paddr 0x00006000 align 2**0
+# ELF32-NEXT: filesz 0x00000010 memsz 0x00000010 flags rwx
+# ELF32-NEXT: INTERP off 0x0000031e vaddr 0x00003000 paddr 0x00003000 align 2**0
+# ELF32-NEXT: filesz 0x00000004 memsz 0x00000004 flags rw-
+# ELF32-NEXT: NOTE off 0x00000314 vaddr 0x00001000 paddr 0x00001000 align 2**0
+# ELF32-NEXT: filesz 0x00000003 memsz 0x00000003 flags ---
+# ELF32-NEXT: UNKNOWN off 0x00000314 vaddr 0x00001000 paddr 0x00001000 align 2**0
+# ELF32-NEXT: filesz 0x00000001 memsz 0x00000001 flags ---
+# ELF32-NEXT: TLS off 0x00000322 vaddr 0x00004000 paddr 0x00004000 align 2**0
+# ELF32-NEXT: filesz 0x00000001 memsz 0x00000001 flags ---
+# ELF32-NEXT: UNKNOWN off 0x00000314 vaddr 0x00001000 paddr 0x00001000 align 2**0
+# ELF32-NEXT: filesz 0x00000003 memsz 0x00000003 flags ---
+# ELF32-NEXT:EH_FRAME off 0x00000314 vaddr 0x00001000 paddr 0x00001000 align 2**0
+# ELF32-NEXT: filesz 0x00000003 memsz 0x00000003 flags ---
+# ELF32-NEXT: UNKNOWN off 0x00000314 vaddr 0x00001000 paddr 0x00001000 align 2**0
+# ELF32-NEXT: filesz 0x00000003 memsz 0x00000003 flags ---
+# ELF32-NEXT: STACK off 0x00000314 vaddr 0x00001000 paddr 0x00001000 align 2**0
+# ELF32-NEXT: filesz 0x00000003 memsz 0x00000003 flags ---
+# ELF32-NEXT: RELRO off 0x00000314 vaddr 0x00001000 paddr 0x00001000 align 2**0
+# ELF32-NEXT: filesz 0x00000003 memsz 0x00000003 flags ---
+# ELF32-NEXT:PROPERTY off 0x00000314 vaddr 0x00001000 paddr 0x00001000 align 2**0
+# ELF32-NEXT: filesz 0x00000003 memsz 0x00000003 flags ---
+# ELF32-NEXT: OPENBSD_RANDOMIZE off 0x00000314 vaddr 0x00001000 paddr 0x00001000 align 2**0
+# ELF32-NEXT: filesz 0x00000003 memsz 0x00000003 flags ---
+# ELF32-NEXT: OPENBSD_WXNEEDED off 0x00000314 vaddr 0x00001000 paddr 0x00001000 align 2**0
+# ELF32-NEXT: filesz 0x00000003 memsz 0x00000003 flags ---
+# ELF32-NEXT: OPENBSD_BOOTDATA off 0x00000314 vaddr 0x00001000 paddr 0x00001000 align 2**0
+# ELF32-NEXT: filesz 0x00000003 memsz 0x00000003 flags ---
+# ELF32-NEXT: UNKNOWN off 0x00000314 vaddr 0x00001000 paddr 0x00001000 align 2**0
+# ELF32-NEXT: filesz 0x00000003 memsz 0x00000003 flags ---
+# ELF32-NEXT: UNKNOWN off 0x00000314 vaddr 0x00001000 paddr 0x00001000 align 2**0
+# ELF32-NEXT: filesz 0x00000003 memsz 0x00000003 flags ---
+# ELF32-NEXT: UNKNOWN off 0x00000314 vaddr 0x00001000 paddr 0x00001000 align 2**0
+# ELF32-NEXT: filesz 0x00000003 memsz 0x00000003 flags ---
+# ELF32-NEXT: UNKNOWN off 0x00000314 vaddr 0x00001000 paddr 0x00001000 align 2**0
+# ELF32-NEXT: filesz 0x00000003 memsz 0x00000003 flags ---
+# ELF32-NEXT: UNKNOWN off 0x00000314 vaddr 0x00001000 paddr 0x00001000 align 2**0
+# ELF32-NEXT: filesz 0x00000003 memsz 0x00000003 flags ---
+# ELF32-NEXT: UNKNOWN off 0x00000314 vaddr 0x00001000 paddr 0x00001000 align 2**0
+# ELF32-NEXT: filesz 0x00000003 memsz 0x00000003 flags ---
+# ELF32-EMPTY:
+
+# RUN: yaml2obj --docnum=1 -DBITS=64 -DMACHINE=EM_X86_64 %s -o %t64.elf
+# RUN: llvm-objdump --private-headers %t64.elf | FileCheck %s --check-prefixes=ELF64
+
+# ELF64: Program Header:
+# ELF64-NEXT: PHDR off 0x0000000000000548 vaddr 0x0000000000001000 paddr 0x0000000000001000 align 2**0
+# ELF64-NEXT: filesz 0x0000000000000003 memsz 0x0000000000000003 flags -w-
+# ELF64-NEXT: PHDR off 0x000000000000054b vaddr 0x0000000000002000 paddr 0x0000000000002000 align 2**0
+# ELF64-NEXT: filesz 0x0000000000000007 memsz 0x0000000000000007 flags --x
+# ELF64-NEXT: UNKNOWN off 0x000000000000054b vaddr 0x0000000000002000 paddr 0x0000000000002000 align 2**0
+# ELF64-NEXT: filesz 0x0000000000000007 memsz 0x0000000000000007 flags --x
+# ELF64-NEXT: DYNAMIC off 0x0000000000000558 vaddr 0x0000000000006000 paddr 0x0000000000006000 align 2**0
+# ELF64-NEXT: filesz 0x0000000000000020 memsz 0x0000000000000020 flags rwx
+# ELF64-NEXT: INTERP off 0x0000000000000552 vaddr 0x0000000000003000 paddr 0x0000000000003000 align 2**0
+# ELF64-NEXT: filesz 0x0000000000000004 memsz 0x0000000000000004 flags rw-
+# ELF64-NEXT: NOTE off 0x0000000000000548 vaddr 0x0000000000001000 paddr 0x0000000000001000 align 2**0
+# ELF64-NEXT: filesz 0x0000000000000003 memsz 0x0000000000000003 flags ---
+# ELF64-NEXT: UNKNOWN off 0x0000000000000548 vaddr 0x0000000000001000 paddr 0x0000000000001000 align 2**0
+# ELF64-NEXT: filesz 0x0000000000000001 memsz 0x0000000000000001 flags ---
+# ELF64-NEXT: TLS off 0x0000000000000556 vaddr 0x0000000000004000 paddr 0x0000000000004000 align 2**0
+# ELF64-NEXT: filesz 0x0000000000000001 memsz 0x0000000000000001 flags ---
+# ELF64-NEXT: UNKNOWN off 0x0000000000000548 vaddr 0x0000000000001000 paddr 0x0000000000001000 align 2**0
+# ELF64-NEXT: filesz 0x0000000000000003 memsz 0x0000000000000003 flags ---
+# ELF64-NEXT:EH_FRAME off 0x0000000000000548 vaddr 0x0000000000001000 paddr 0x0000000000001000 align 2**0
+# ELF64-NEXT: filesz 0x0000000000000003 memsz 0x0000000000000003 flags ---
+# ELF64-NEXT: UNKNOWN off 0x0000000000000548 vaddr 0x0000000000001000 paddr 0x0000000000001000 align 2**0
+# ELF64-NEXT: filesz 0x0000000000000003 memsz 0x0000000000000003 flags ---
+# ELF64-NEXT: STACK off 0x0000000000000548 vaddr 0x0000000000001000 paddr 0x0000000000001000 align 2**0
+# ELF64-NEXT: filesz 0x0000000000000003 memsz 0x0000000000000003 flags ---
+# ELF64-NEXT: RELRO off 0x0000000000000548 vaddr 0x0000000000001000 paddr 0x0000000000001000 align 2**0
+# ELF64-NEXT: filesz 0x0000000000000003 memsz 0x0000000000000003 flags ---
+# ELF64-NEXT: PROPERTY off 0x0000000000000548 vaddr 0x0000000000001000 paddr 0x0000000000001000 align 2**0
+# ELF64-NEXT: filesz 0x0000000000000003 memsz 0x0000000000000003 flags ---
+# ELF64-NEXT: OPENBSD_RANDOMIZE off 0x0000000000000548 vaddr 0x0000000000001000 paddr 0x0000000000001000 align 2**0
+# ELF64-NEXT: filesz 0x0000000000000003 memsz 0x0000000000000003 flags ---
+# ELF64-NEXT: OPENBSD_WXNEEDED off 0x0000000000000548 vaddr 0x0000000000001000 paddr 0x0000000000001000 align 2**0
+# ELF64-NEXT: filesz 0x0000000000000003 memsz 0x0000000000000003 flags ---
+# ELF64-NEXT: OPENBSD_BOOTDATA off 0x0000000000000548 vaddr 0x0000000000001000 paddr 0x0000000000001000 align 2**0
+# ELF64-NEXT: filesz 0x0000000000000003 memsz 0x0000000000000003 flags ---
+# ELF64-NEXT: UNKNOWN off 0x0000000000000548 vaddr 0x0000000000001000 paddr 0x0000000000001000 align 2**0
+# ELF64-NEXT: filesz 0x0000000000000003 memsz 0x0000000000000003 flags ---
+# ELF64-NEXT: UNKNOWN off 0x0000000000000548 vaddr 0x0000000000001000 paddr 0x0000000000001000 align 2**0
+# ELF64-NEXT: filesz 0x0000000000000003 memsz 0x0000000000000003 flags ---
+# ELF64-NEXT: UNKNOWN off 0x0000000000000548 vaddr 0x0000000000001000 paddr 0x0000000000001000 align 2**0
+# ELF64-NEXT: filesz 0x0000000000000003 memsz 0x0000000000000003 flags ---
+# ELF64-NEXT: UNKNOWN off 0x0000000000000548 vaddr 0x0000000000001000 paddr 0x0000000000001000 align 2**0
+# ELF64-NEXT: filesz 0x0000000000000003 memsz 0x0000000000000003 flags ---
+# ELF64-NEXT: UNKNOWN off 0x0000000000000548 vaddr 0x0000000000001000 paddr 0x0000000000001000 align 2**0
+# ELF64-NEXT: filesz 0x0000000000000003 memsz 0x0000000000000003 flags ---
+# ELF64-NEXT: UNKNOWN off 0x0000000000000548 vaddr 0x0000000000001000 paddr 0x0000000000001000 align 2**0
+# ELF64-NEXT: filesz 0x0000000000000003 memsz 0x0000000000000003 flags ---
+# ELF64-EMPTY:
+
+--- !ELF
+FileHeader:
+ Class: ELFCLASS[[BITS]]
+ Data: ELFDATA2LSB
+ Type: ET_EXEC
+ Machine: [[MACHINE]]
+Sections:
+ - Name: .foo.begin
+ Type: SHT_PROGBITS
+ Flags: [ SHF_ALLOC ]
+ Address: 0x1000
+ Size: 0x1
+ - Name: .foo.end
+ Type: SHT_PROGBITS
+ Flags: [ SHF_ALLOC ]
+ Size: 0x2
+ - Name: .bar.begin
+ Type: SHT_PROGBITS
+ Flags: [ SHF_ALLOC ]
+ Address: 0x2000
+ Size: 0x3
+ - Name: .bar.end
+ Type: SHT_PROGBITS
+ Flags: [ SHF_ALLOC ]
+ Size: 0x4
+ - Name: .interp
+ Type: SHT_PROGBITS
+ Flags: [ SHF_ALLOC ]
+ Address: 0x3000
+ Content: "41424300" ## "ABC"
+ - Name: .tls
+ Type: SHT_PROGBITS
+ Flags: [ SHF_ALLOC, SHF_TLS ]
+ Address: 0x4000
+ Size: 0x1
+ - Name: .unused
+ Type: SHT_PROGBITS
+ Flags: [ SHF_ALLOC, SHF_TLS ]
+ Address: 0x5000
+ Size: 0x1
+ - Name: .dynamic
+ Type: SHT_DYNAMIC
+ Flags: [ SHF_ALLOC ]
+ Address: 0x6000
+ Entries:
+ - Tag: DT_NEEDED
+ Value: 0x1
+ - Tag: DT_NULL
+ Value: 0x0
+ProgramHeaders:
+## Case 1: an arbitrary segment with sections.
+ - Type: PT_PHDR
+ Flags: [ PF_W ]
+ VAddr: 0x1000
+ FirstSec: .foo.begin
+ LastSec: .foo.end
+## Case 2: another segment with
diff erent sections.
+ - Type: PT_PHDR
+ Flags: [ PF_X ]
+ VAddr: 0x2000
+ FirstSec: .bar.begin
+ LastSec: .bar.end
+## Case 3: the PT_NULL segment.
+ - Type: PT_NULL
+ Flags: [ PF_X ]
+ VAddr: 0x2000
+ FirstSec: .bar.begin
+ LastSec: .bar.end
+## Case 4: the PT_DYNAMIC segment.
+ - Type: PT_DYNAMIC
+ Flags: [ PF_R, PF_W, PF_X ]
+ VAddr: 0x6000
+ FirstSec: .dynamic
+ LastSec: .dynamic
+## Case 5: the PT_INTERP segment.
+ - Type: PT_INTERP
+ Flags: [ PF_R, PF_W ]
+ VAddr: 0x3000
+ FirstSec: .interp
+ LastSec: .interp
+## Case 6: the PT_NOTE segment.
+ - Type: PT_NOTE
+ VAddr: 0x1000
+ FirstSec: .foo.begin
+ LastSec: .foo.end
+## Case 7: the PT_SHLIB segment.
+ - Type: PT_SHLIB
+ VAddr: 0x1000
+ FirstSec: .foo.begin
+ LastSec: .foo.begin
+## Case 8: the PT_TLS segment.
+ - Type: PT_TLS
+ VAddr: 0x4000
+ FirstSec: .tls
+ LastSec: .tls
+## Case 9: the PT_LOOS segment.
+ - Type: 0x60000000 ## PT_LOOS
+ VAddr: 0x1000
+ FirstSec: .foo.begin
+ LastSec: .foo.end
+## Case 10: the PT_GNU_EH_FRAME segment.
+ - Type: PT_GNU_EH_FRAME
+ VAddr: 0x1000
+ FirstSec: .foo.begin
+ LastSec: .foo.end
+## Case 11: the PT_SUNW_UNWIND segment.
+ - Type: 0x6464e550 ## PT_SUNW_UNWIND
+ VAddr: 0x1000
+ FirstSec: .foo.begin
+ LastSec: .foo.end
+## Case 12: the PT_GNU_STACK segment.
+ - Type: PT_GNU_STACK
+ VAddr: 0x1000
+ FirstSec: .foo.begin
+ LastSec: .foo.end
+## Case 13: the PT_GNU_RELRO segment.
+ - Type: PT_GNU_RELRO
+ VAddr: 0x1000
+ FirstSec: .foo.begin
+ LastSec: .foo.end
+## Case 14: the PT_GNU_PROPERTY segment.
+ - Type: PT_GNU_PROPERTY
+ VAddr: 0x1000
+ FirstSec: .foo.begin
+ LastSec: .foo.end
+## Case 15: the PT_OPENBSD_RANDOMIZE segment.
+ - Type: 0x65a3dbe6 ## PT_OPENBSD_RANDOMIZE
+ VAddr: 0x1000
+ FirstSec: .foo.begin
+ LastSec: .foo.end
+## Case 16: the PT_OPENBSD_WXNEEDED segment.
+ - Type: 0x65a3dbe7 ## PT_OPENBSD_WXNEEDED
+ VAddr: 0x1000
+ FirstSec: .foo.begin
+ LastSec: .foo.end
+## Case 17: the PT_OPENBSD_BOOTDATA segment.
+ - Type: 0x65a41be6 ## PT_OPENBSD_BOOTDATA
+ VAddr: 0x1000
+ FirstSec: .foo.begin
+ LastSec: .foo.end
+## Case 18: the PT_HIOS segment.
+ - Type: 0x6fffffff ## PT_HIOS
+ VAddr: 0x1000
+ FirstSec: .foo.begin
+ LastSec: .foo.end
+## Case 19: the PT_LOPROC/PT_ARM_ARCHEXT/PT_MIPS_REGINFO segment.
+ - Type: 0x70000000 ## PT_LOPROC/PT_ARM_ARCHEXT/PT_MIPS_REGINFO
+ VAddr: 0x1000
+ FirstSec: .foo.begin
+ LastSec: .foo.end
+## Case 20: the PT_ARM_EXIDX/PT_MIPS_RTPROC segment.
+ - Type: 0x70000001 ## PT_ARM_EXIDX, PT_MIPS_RTPROC
+ VAddr: 0x1000
+ FirstSec: .foo.begin
+ LastSec: .foo.end
+## Case 20: the PT_MIPS_OPTIONS segment.
+ - Type: 0x70000002 ## PT_MIPS_OPTIONS
+ VAddr: 0x1000
+ FirstSec: .foo.begin
+ LastSec: .foo.end
+## Case 21: the PT_MIPS_ABIFLAGS segment.
+ - Type: 0x70000003 ## PT_MIPS_ABIFLAGS
+ VAddr: 0x1000
+ FirstSec: .foo.begin
+ LastSec: .foo.end
+## Case 22: the PT_HIPROC segment.
+ - Type: 0x7fffffff ## PT_HIPROC
+ VAddr: 0x1000
+ FirstSec: .foo.begin
+ LastSec: .foo.end
+
+## Check we report an error / warning when we are unable to read program headers.
+## Case A: the e_phentsize field is invalid.
+# RUN: yaml2obj --docnum=2 -DPHENTSIZE=1 %s -o %t.phdr.err
+# RUN: not llvm-objdump --private-headers %t.phdr.err 2>&1 | \
+# RUN: FileCheck %s -DFILE=%t.phdr.err --check-prefix=PHENTSIZE
+
+# PHENTSIZE: Program Header:
+# PHENTSIZE-NEXT: warning: '[[FILE]]': unable to read program headers: invalid e_phentsize: 1
+# PHENTSIZE-NEXT: error: '[[FILE]]': invalid e_phentsize: 1
+
+--- !ELF
+FileHeader:
+ Class: ELFCLASS64
+ Data: ELFDATA2LSB
+ Type: ET_EXEC
+ EPhEntSize: [[PHENTSIZE=<none>]]
+ EPhOff: [[PHOFF=<none>]]
+Sections:
+ - Name: .foo
+ Type: SHT_PROGBITS
+ProgramHeaders:
+ - Type: PT_PHDR
+ FirstSec: .foo
+ LastSec: .foo
+
+## Case B: the value of the e_phoff field is invalid.
+
+## Check that we do not report a warning when the program header table ends right before the end of the file.
+## 0x160 + size of headers (56) == file size.
+# RUN: yaml2obj --docnum=2 -DPHOFF=0x160 %s -o %t.phdr.no.err2
+# RUN: llvm-objdump %t.phdr.no.err2 --private-headers 2>&1 | FileCheck %s --implicit-check-not=warning:
+
+## Check we report a warning / error when e_phoff goes 1 byte past the end of the file.
+# RUN: yaml2obj --docnum=2 -DPHOFF=0x161 %s -o %t.phdr.err2
+# RUN: not llvm-objdump --private-headers %t.phdr.err2 2>&1 | \
+# RUN: FileCheck %s -DFILE=%t.phdr.err2 --check-prefix=PHOFF -DOFF=0x161
+
+# PHOFF: Program Header:
+# PHOFF-NEXT: warning: '[[FILE]]': unable to read program headers: program headers are longer than binary of size 408: e_phoff = [[OFF]], e_phnum = 1, e_phentsize = 56
+# PHOFF-NEXT: error: '[[FILE]]': program headers are longer than binary of size 408: e_phoff = [[OFF]], e_phnum = 1, e_phentsize = 56
+
+
+## Check we report a warning / error when the value of e_phoff is so large that
+## e_phoff + e_phnum * e_phentsize > UINT64_MAX.
+# RUN: yaml2obj --docnum=2 -DPHOFF=0xffffffffffffffff %s -o %t.phdr.err3
+# RUN: not llvm-objdump --private-headers %t.phdr.err3 2>&1 | \
+# RUN: FileCheck %s -DFILE=%t.phdr.err3 --check-prefix=PHOFF -DOFF=0xffffffffffffffff
diff --git a/llvm/test/tools/llvm-objdump/X86/print-imm-hex.s b/llvm/test/tools/llvm-objdump/X86/print-imm-hex.s
new file mode 100644
index 000000000000..8de49fd4c2a7
--- /dev/null
+++ b/llvm/test/tools/llvm-objdump/X86/print-imm-hex.s
@@ -0,0 +1,29 @@
+# RUN: llvm-mc -filetype=obj -triple=x86_64 %s -o %t
+
+# RUN: llvm-objdump -d %t | FileCheck %s --check-prefix=NOPRINT
+# RUN: llvm-objdump -d --print-imm-hex --no-print-imm-hex %t | FileCheck %s --check-prefix=NOPRINT
+# RUN: llvm-objdump -d --no-print-imm-hex --print-imm-hex %t | FileCheck %s --check-prefix=PRINT
+
+.text
+ retq
+ movq 0x123456(%rip),%rax
+ movabs $0x5555555555555554,%rax
+ lwpval $0x0, 0x40(%rdx,%rax), %r15d
+ lwpins $0x0, 0x1cf01cf0, %r15d
+ .word 0xffff
+
+# NOPRINT: 0000000000000000 <.text>:
+# NOPRINT-NEXT: 0: c3 retq
+# NOPRINT-NEXT: 1: 48 8b 05 56 34 12 00 movq 1193046(%rip), %rax # 0x12345e <.text+0x12345e>
+# NOPRINT-NEXT: 8: 48 b8 54 55 55 55 55 55 55 55 movabsq $6148914691236517204, %rax # imm = 0x5555555555555554
+# NOPRINT-NEXT: 12: 8f ea 00 12 4c 02 40 00 00 00 00 lwpval $0, 64(%rdx,%rax), %r15d
+# NOPRINT-NEXT: 1d: 8f ea 00 12 04 25 f0 1c f0 1c 00 00 00 00 lwpins $0, 485498096, %r15d
+# NOPRINT-NEXT: 2b: ff ff <unknown>
+
+# PRINT: 0000000000000000 <.text>:
+# PRINT-NEXT: 0: c3 retq
+# PRINT-NEXT: 1: 48 8b 05 56 34 12 00 movq 0x123456(%rip), %rax # 0x12345e <.text+0x12345e>
+# PRINT-NEXT: 8: 48 b8 54 55 55 55 55 55 55 55 movabsq $0x5555555555555554, %rax # imm = 0x5555555555555554
+# PRINT-NEXT: 12: 8f ea 00 12 4c 02 40 00 00 00 00 lwpval $0x0, 0x40(%rdx,%rax), %r15d
+# PRINT-NEXT: 1d: 8f ea 00 12 04 25 f0 1c f0 1c 00 00 00 00 lwpins $0x0, 0x1cf01cf0, %r15d
+# PRINT-NEXT: 2b: ff ff <unknown>
diff --git a/llvm/test/tools/llvm-objdump/section-headers.test b/llvm/test/tools/llvm-objdump/section-headers.test
index f8159be03064..c850e3a3cb3f 100644
--- a/llvm/test/tools/llvm-objdump/section-headers.test
+++ b/llvm/test/tools/llvm-objdump/section-headers.test
@@ -51,6 +51,12 @@ Sections:
- Name: .debug_info
Type: SHT_PROGBITS
Flags: [ SHF_WRITE, SHF_ALLOC ]
+
+## Check that --section-headers and --headers are aliases for -h.
+# RUN: llvm-objdump --section-headers --show-lma %t-whitespace.o \
+# RUN: | FileCheck %s --check-prefix=WHITESPACE --strict-whitespace
+# RUN: llvm-objdump --headers --show-lma %t-whitespace.o \
+# RUN: | FileCheck %s --check-prefix=WHITESPACE --strict-whitespace
## The name field automatically expands past the default 13 columns when a
## section name is longer than that.
More information about the llvm-commits
mailing list