151 lines
5.0 KiB
Plaintext
151 lines
5.0 KiB
Plaintext
## Test that malformed NT_FILE sections in core files are gracefully ignored.
|
|
|
|
## llvm-mc doesn't support generating ET_CORE files; the 'Content' field in
|
|
## each of the following test cases were generated with the following steps:
|
|
# $ llvm-mc -filetype=obj -triple x86_64-pc-linux-gnu tmp.s -o tmp.o
|
|
# $ bin/llvm-objcopy --dump-section=.note.foo=tmp.txt tmp.o /dev/null
|
|
# $ xxd -p tmp.txt | tr -d '\n'; echo
|
|
# using the assembly shown with each test case.
|
|
|
|
# RUN: yaml2obj --docnum=1 %s -o %t1.o
|
|
# RUN: llvm-readelf -n %t1.o 2>&1 | FileCheck -DFILE=%t1.o %s --check-prefix=ERR-HEADER-SHORT
|
|
# RUN: llvm-readobj -n %t1.o 2>&1 | FileCheck -DFILE=%t1.o %s --check-prefix=ERR-HEADER-SHORT
|
|
|
|
# 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
|
|
|
|
# .section ".note.foo", "a"
|
|
# .align 4
|
|
# .long 5 /* namesz */
|
|
# .long end - begin /* descsz */
|
|
# .long 0x46494c45 /* type = NT_FILE */
|
|
# .asciz "CORE"
|
|
# .align 4
|
|
# begin:
|
|
# .quad 0 /* no file mappings */
|
|
# end:
|
|
|
|
--- !ELF
|
|
FileHeader:
|
|
Class: ELFCLASS64
|
|
Data: ELFDATA2LSB
|
|
Type: ET_CORE
|
|
Sections:
|
|
- Name: .note.foo
|
|
Type: SHT_NOTE
|
|
Content: 0500000008000000454C4946434F5245000000000000000000000000
|
|
ProgramHeaders:
|
|
- Type: PT_NOTE
|
|
FirstSec: .note.foo
|
|
LastSec: .note.foo
|
|
|
|
# RUN: yaml2obj --docnum=2 %s -o %t2.o
|
|
# RUN: llvm-readelf -n %t2.o 2>&1 | FileCheck -DFILE=%t2.o %s --check-prefix=ERR-NULL-TERM
|
|
# RUN: llvm-readobj -n %t2.o 2>&1 | FileCheck -DFILE=%t2.o %s --check-prefix=ERR-NULL-TERM
|
|
|
|
# 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
|
|
|
|
# .section ".note.foo", "a"
|
|
# .align 4
|
|
# .long 5 /* namesz */
|
|
# .long end - begin /* descsz */
|
|
# .long 0x46494c45 /* type = NT_FILE */
|
|
# .asciz "CORE"
|
|
# .align 4
|
|
# begin:
|
|
# .quad 1 /* 1 file mapping */
|
|
# .quad 4096 /* page size */
|
|
# .quad 0x1000 /* start #1 */
|
|
# .quad 0x2000 /* end #1 */
|
|
# .quad 0x3000 /* offset #1 */
|
|
# .ascii "xxxx"
|
|
# end:
|
|
|
|
--- !ELF
|
|
FileHeader:
|
|
Class: ELFCLASS64
|
|
Data: ELFDATA2LSB
|
|
Type: ET_CORE
|
|
Sections:
|
|
- Name: .note.foo
|
|
Type: SHT_NOTE
|
|
Content: 050000002C000000454C4946434F5245000000000100000000000000001000000000000000100000000000000020000000000000003000000000000078787878
|
|
ProgramHeaders:
|
|
- Type: PT_NOTE
|
|
FirstSec: .note.foo
|
|
LastSec: .note.foo
|
|
|
|
# RUN: yaml2obj --docnum=3 %s -o %t3.o
|
|
# RUN: llvm-readelf -n %t3.o 2>&1 | FileCheck -DFILE=%t3.o %s --check-prefix=ERR-FILE-COUNT
|
|
# RUN: llvm-readobj -n %t3.o 2>&1 | FileCheck -DFILE=%t3.o %s --check-prefix=ERR-FILE-COUNT
|
|
|
|
# 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
|
|
|
|
# .section ".note.foo", "a"
|
|
# .align 4
|
|
# .long 5 /* namesz */
|
|
# .long end - begin /* descsz */
|
|
# .long 0x46494c45 /* type = NT_FILE */
|
|
# .asciz "CORE"
|
|
# .align 4
|
|
# begin:
|
|
# .quad 2 /* 2 file mappings */
|
|
# .quad 4096 /* page size */
|
|
# .quad 0x1000 /* start #1 */
|
|
# .quad 0x2000 /* end #1 */
|
|
# .quad 0x3000 /* offset #1 */
|
|
# .asciz "xyz"
|
|
# end:
|
|
|
|
--- !ELF
|
|
FileHeader:
|
|
Class: ELFCLASS64
|
|
Data: ELFDATA2LSB
|
|
Type: ET_CORE
|
|
Sections:
|
|
- Name: .note.foo
|
|
Type: SHT_NOTE
|
|
Content: 050000002C000000454C4946434F5245000000000200000000000000001000000000000000100000000000000020000000000000003000000000000078797A00
|
|
ProgramHeaders:
|
|
- Type: PT_NOTE
|
|
FirstSec: .note.foo
|
|
LastSec: .note.foo
|
|
|
|
# RUN: yaml2obj --docnum=4 %s -o %t4.o
|
|
# RUN: llvm-readelf -n %t4.o 2>&1 | FileCheck -DFILE=%t4.o %s --check-prefix=ERR-FILE-END-EARLY
|
|
# RUN: llvm-readobj -n %t4.o 2>&1 | FileCheck -DFILE=%t4.o %s --check-prefix=ERR-FILE-END-EARLY
|
|
|
|
# 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
|
|
|
|
# .section ".note.foo", "a"
|
|
# .align 4
|
|
# .long 5 /* namesz */
|
|
# .long end - begin /* descsz */
|
|
# .long 0x46494c45 /* type = NT_FILE */
|
|
# .asciz "CORE"
|
|
# .align 4
|
|
# begin:
|
|
# .quad 2 /* 2 file mappings */
|
|
# .quad 4096 /* page size */
|
|
# .quad 0x1000 /* start #1 */
|
|
# .quad 0x2000 /* end #1 */
|
|
# .quad 0x3000 /* offset #1 */
|
|
# .quad 0x4000 /* start #2 */
|
|
# .quad 0x5000 /* end #2 */
|
|
# .quad 0x6000 /* offset #2 */
|
|
# .asciz "xyz"
|
|
# end:
|
|
|
|
--- !ELF
|
|
FileHeader:
|
|
Class: ELFCLASS64
|
|
Data: ELFDATA2LSB
|
|
Type: ET_CORE
|
|
Sections:
|
|
- Name: .note.foo
|
|
Type: SHT_NOTE
|
|
Content: 0500000044000000454C4946434F5245000000000200000000000000001000000000000000100000000000000020000000000000003000000000000000400000000000000050000000000000006000000000000078797A00
|
|
ProgramHeaders:
|
|
- Type: PT_NOTE
|
|
FirstSec: .note.foo
|
|
LastSec: .note.foo
|