1 ## Test that malformed NT_FILE sections in core files are gracefully ignored.
3 ## llvm-mc doesn't support generating ET_CORE files; the 'Content' field in
4 ## each of the following test cases were generated with the following steps:
5 # $ llvm-mc -filetype=obj -triple x86_64-pc-linux-gnu tmp.s -o tmp.o
6 # $ bin/llvm-objcopy --dump-section=.note.foo=tmp.txt tmp.o /dev/null
7 # $ xxd -p tmp.txt | tr -d '\n'; echo
8 # using the assembly shown with each test case.
10 # RUN: yaml2obj --docnum=1 %s -o %t1.o
11 # RUN: llvm-readelf -n %t1.o 2>&1 | FileCheck -DFILE=%t1.o %s --check-prefix=ERR-HEADER-SHORT
12 # RUN: llvm-readobj -n %t1.o 2>&1 | FileCheck -DFILE=%t1.o %s --check-prefix=ERR-HEADER-SHORT
14 # ERR-HEADER-SHORT: warning: '[[FILE]]': unable to read note with index 0 from the PT_NOTE segment with index 0: the note of size 0x8 is too short, expected at least 0x10
16 # .section ".note.foo", "a"
18 # .long 5 /* namesz */
19 # .long end - begin /* descsz */
20 # .long 0x46494c45 /* type = NT_FILE */
24 # .quad 0 /* no file mappings */
35 Content: 0500000008000000454C4946434F5245000000000000000000000000
41 # RUN: yaml2obj --docnum=2 %s -o %t2.o
42 # RUN: llvm-readelf -n %t2.o 2>&1 | FileCheck -DFILE=%t2.o %s --check-prefix=ERR-NULL-TERM
43 # RUN: llvm-readobj -n %t2.o 2>&1 | FileCheck -DFILE=%t2.o %s --check-prefix=ERR-NULL-TERM
45 # ERR-NULL-TERM: warning: '[[FILE]]': unable to read note with index 0 from the PT_NOTE segment with index 0: the note is not NUL terminated
47 # .section ".note.foo", "a"
49 # .long 5 /* namesz */
50 # .long end - begin /* descsz */
51 # .long 0x46494c45 /* type = NT_FILE */
55 # .quad 1 /* 1 file mapping */
56 # .quad 4096 /* page size */
57 # .quad 0x1000 /* start #1 */
58 # .quad 0x2000 /* end #1 */
59 # .quad 0x3000 /* offset #1 */
71 Content: 050000002C000000454C4946434F5245000000000100000000000000001000000000000000100000000000000020000000000000003000000000000078787878
77 # RUN: yaml2obj --docnum=3 %s -o %t3.o
78 # RUN: llvm-readelf -n %t3.o 2>&1 | FileCheck -DFILE=%t3.o %s --check-prefix=ERR-FILE-COUNT
79 # RUN: llvm-readobj -n %t3.o 2>&1 | FileCheck -DFILE=%t3.o %s --check-prefix=ERR-FILE-COUNT
81 # ERR-FILE-COUNT: warning: '[[FILE]]': unable to read note with index 0 from the PT_NOTE segment with index 0: unable to read file mappings (found 2): the note of size 0x2c is too short
83 # .section ".note.foo", "a"
85 # .long 5 /* namesz */
86 # .long end - begin /* descsz */
87 # .long 0x46494c45 /* type = NT_FILE */
91 # .quad 2 /* 2 file mappings */
92 # .quad 4096 /* page size */
93 # .quad 0x1000 /* start #1 */
94 # .quad 0x2000 /* end #1 */
95 # .quad 0x3000 /* offset #1 */
107 Content: 050000002C000000454C4946434F5245000000000200000000000000001000000000000000100000000000000020000000000000003000000000000078797A00
113 # RUN: yaml2obj --docnum=4 %s -o %t4.o
114 # RUN: llvm-readelf -n %t4.o 2>&1 | FileCheck -DFILE=%t4.o %s --check-prefix=ERR-FILE-END-EARLY
115 # RUN: llvm-readobj -n %t4.o 2>&1 | FileCheck -DFILE=%t4.o %s --check-prefix=ERR-FILE-END-EARLY
117 # ERR-FILE-END-EARLY: warning: '[[FILE]]': unable to read note with index 0 from the PT_NOTE segment with index 0: unable to read the file name for the mapping with index 2: the note of size 0x44 is truncated
119 # .section ".note.foo", "a"
121 # .long 5 /* namesz */
122 # .long end - begin /* descsz */
123 # .long 0x46494c45 /* type = NT_FILE */
127 # .quad 2 /* 2 file mappings */
128 # .quad 4096 /* page size */
129 # .quad 0x1000 /* start #1 */
130 # .quad 0x2000 /* end #1 */
131 # .quad 0x3000 /* offset #1 */
132 # .quad 0x4000 /* start #2 */
133 # .quad 0x5000 /* end #2 */
134 # .quad 0x6000 /* offset #2 */
146 Content: 0500000044000000454C4946434F5245000000000200000000000000001000000000000000100000000000000020000000000000003000000000000000400000000000000050000000000000006000000000000078797A00