• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Check the dumping of a section as strings.
2# RUN: yaml2obj %s -o %t
3
4# RUN: llvm-readobj --string-dump=.strings \
5# RUN:   --string-dump=.not_null_terminated %t > %t.readobj.out
6# RUN: FileCheck %s --input-file=%t.readobj.out
7
8# Also test the different ways --string-dump can be specified, i.e. as a short
9# flag (-p), with different prefix modes (-p .foo, -p=.foo, -p.foo), and with
10# the value being a index section number instead of a section name.
11# RUN: llvm-readobj -p=.strings -p=.not_null_terminated %t > %t.readobj.1
12# RUN: llvm-readobj -p.strings -p.strings -p.not_null_terminated %t > %t.readobj.2
13# RUN: llvm-readobj --string-dump=1 --string-dump=2 %t > %t.readobj.3
14# RUN: llvm-readobj -p1 -p1 -p2 %t > %t.readobj.4
15# RUN: llvm-readobj -p=1 -p=2 %t > %t.readobj.5
16
17# RUN: cmp %t.readobj.out %t.readobj.1
18# RUN: cmp %t.readobj.out %t.readobj.2
19# RUN: cmp %t.readobj.out %t.readobj.3
20# RUN: cmp %t.readobj.out %t.readobj.4
21# RUN: cmp %t.readobj.out %t.readobj.5
22
23# Run readelf flag tests with an additional flag, --file-header, so we can test
24# -p grouped with something.
25# RUN: llvm-readelf --file-header --string-dump=.strings \
26# RUN:   --string-dump=.not_null_terminated %t > %t.readelf.out
27# RUN: FileCheck %s --input-file=%t.readelf.out
28
29# RUN: llvm-readelf -h -p=.strings -p=.not_null_terminated %t > %t.readelf.1
30# RUN: llvm-readelf -p.strings -hp.not_null_terminated %t > %t.readelf.2
31# RUN: llvm-readelf -h --string-dump=1 --string-dump=2 %t > %t.readelf.3
32# RUN: llvm-readelf -hp1 -p2 %t > %t.readelf.4
33# RUN: llvm-readelf -hp 1 -p.not_null_terminated %t > %t.readelf.5
34# RUN: llvm-readelf -p=1 -hp=2 %t > %t.readelf.6
35
36# RUN: cmp %t.readelf.out %t.readelf.1
37# RUN: cmp %t.readelf.out %t.readelf.2
38# RUN: cmp %t.readelf.out %t.readelf.3
39# RUN: cmp %t.readelf.out %t.readelf.4
40# RUN: cmp %t.readelf.out %t.readelf.5
41# RUN: cmp %t.readelf.out %t.readelf.6
42
43# CHECK:      String dump of section '.strings':
44# CHECK-NEXT: [ 0] here
45# CHECK-NEXT: [ 5] are
46# CHECK-NEXT: [ 9] some
47# CHECK-NEXT: [ e] strings
48# CHECK-EMPTY:
49# CHECK-NEXT: String dump of section '.not_null_terminated':
50# CHECK-NEXT: [ 0] no
51# CHECK-NEXT: [ 3] null{{$}}
52# CHECK-NOT:  {{.}}
53
54# RUN: llvm-readobj --string-dump=does_not_exist %t 2>&1 | FileCheck -DFILE=%t %s --check-prefix=WARN1
55# RUN: llvm-readobj --string-dump=42 %t 2>&1 | FileCheck %s  -DFILE=%t --check-prefix=WARN2
56
57# RUN: llvm-readelf --string-dump=does_not_exist %t 2>&1 | FileCheck -DFILE=%t %s --check-prefix=WARN1
58# RUN: llvm-readelf --string-dump=42 %t 2>&1 | FileCheck %s  -DFILE=%t --check-prefix=WARN2
59
60# WARN1: warning: '[[FILE]]': could not find section 'does_not_exist'
61# WARN2: warning: '[[FILE]]': could not find section 42
62
63--- !ELF
64FileHeader:
65  Class: ELFCLASS64
66  Data:  ELFDATA2LSB
67  Type:  ET_REL
68Sections:
69  - Name: .strings
70    Type: SHT_PROGBITS
71    Content: 686572650061726500736f6d6500737472696e677300
72  - Name: .not_null_terminated
73    Type: SHT_PROGBITS
74    Content: 6e6f006e756c6c
75