This is a resubmission of a previous patch that caused test failures, with the fixes for the relevant tests included. Fixes bug 40630: https://bugs.llvm.org/show_bug.cgi?id=40630 This patch changes the error message when the section specified by --string-dump cannot be found by including the name of the section in the error message and changing the prefix text to not imply that the file itself was invalid. As part of this change some uses of std::error_code have been replaced with the llvm Error class to better encapsulate the error info (rather than passing File strings around), and the WithColor class replaces string literal error prefixes. llvm-svn: 358395
75 lines
2.9 KiB
Plaintext
75 lines
2.9 KiB
Plaintext
# Check the dumping of a section as strings.
|
|
# RUN: yaml2obj %s > %t
|
|
|
|
# RUN: llvm-readobj --string-dump=.strings \
|
|
# RUN: --string-dump=.not_null_terminated %t > %t.readobj.out
|
|
# RUN: FileCheck %s --input-file=%t.readobj.out
|
|
|
|
# Also test the different ways --string-dump can be specified, i.e. as a short
|
|
# flag (-p), with different prefix modes (-p .foo, -p=.foo, -p.foo), and with
|
|
# the value being a index section number instead of a section name.
|
|
# RUN: llvm-readobj -p=.strings -p=.not_null_terminated %t > %t.readobj.1
|
|
# RUN: llvm-readobj -p.strings -p.not_null_terminated %t > %t.readobj.2
|
|
# RUN: llvm-readobj --string-dump=1 --string-dump=2 %t > %t.readobj.3
|
|
# RUN: llvm-readobj -p1 -p2 %t > %t.readobj.4
|
|
# RUN: llvm-readobj -p=1 -p=2 %t > %t.readobj.5
|
|
|
|
# RUN: cmp %t.readobj.out %t.readobj.1
|
|
# RUN: cmp %t.readobj.out %t.readobj.2
|
|
# RUN: cmp %t.readobj.out %t.readobj.3
|
|
# RUN: cmp %t.readobj.out %t.readobj.4
|
|
# RUN: cmp %t.readobj.out %t.readobj.5
|
|
|
|
# Run readelf flag tests with an additional flag, --file-header, so we can test
|
|
# -p grouped with something.
|
|
# RUN: llvm-readelf --file-header --string-dump=.strings \
|
|
# RUN: --string-dump=.not_null_terminated %t > %t.readelf.out
|
|
# RUN: FileCheck %s --input-file=%t.readelf.out
|
|
|
|
# RUN: llvm-readelf -h -p=.strings -p=.not_null_terminated %t > %t.readelf.1
|
|
# RUN: llvm-readelf -p.strings -hp.not_null_terminated %t > %t.readelf.2
|
|
# RUN: llvm-readelf -h --string-dump=1 --string-dump=2 %t > %t.readelf.3
|
|
# RUN: llvm-readelf -hp1 -p2 %t > %t.readelf.4
|
|
# RUN: llvm-readelf -hp 1 -p.not_null_terminated %t > %t.readelf.5
|
|
# RUN: llvm-readelf -p=1 -hp=2 %t > %t.readelf.6
|
|
|
|
# RUN: cmp %t.readelf.out %t.readelf.1
|
|
# RUN: cmp %t.readelf.out %t.readelf.2
|
|
# RUN: cmp %t.readelf.out %t.readelf.3
|
|
# RUN: cmp %t.readelf.out %t.readelf.4
|
|
# RUN: cmp %t.readelf.out %t.readelf.5
|
|
# RUN: cmp %t.readelf.out %t.readelf.6
|
|
|
|
# CHECK: String dump of section '.strings':
|
|
# CHECK-NEXT: [ 0] here
|
|
# CHECK-NEXT: [ 5] are
|
|
# CHECK-NEXT: [ 9] some
|
|
# CHECK-NEXT: [ e] strings
|
|
# CHECK-NEXT: String dump of section '.not_null_terminated':
|
|
# CHECK-NEXT: [ 0] no
|
|
# CHECK-NEXT: [ 3] null{{$}}
|
|
# CHECK-NOT: {{.}}
|
|
|
|
# RUN: not llvm-readobj --string-dump=does_not_exist %t 2>&1 | FileCheck %s --check-prefix=ERR1
|
|
# RUN: not llvm-readobj --string-dump=42 %t 2>&1 | FileCheck %s --check-prefix=ERR2
|
|
|
|
# RUN: not llvm-readelf --string-dump=does_not_exist %t 2>&1 | FileCheck %s --check-prefix=ERR1
|
|
# RUN: not llvm-readelf --string-dump=42 %t 2>&1 | FileCheck %s --check-prefix=ERR2
|
|
|
|
# ERR1: error: could not find section 'does_not_exist'
|
|
# ERR2: error: could not find section '42'
|
|
|
|
--- !ELF
|
|
FileHeader:
|
|
Class: ELFCLASS64
|
|
Data: ELFDATA2LSB
|
|
Type: ET_REL
|
|
Machine: EM_X86_64
|
|
Sections:
|
|
- Name: .strings
|
|
Type: SHT_PROGBITS
|
|
Content: 686572650061726500736f6d6500737472696e677300
|
|
- Name: .not_null_terminated
|
|
Type: SHT_PROGBITS
|
|
Content: 6e6f006e756c6c
|