blob: 24ee3453786c5521191cb0e6235115f114d3bdce [file] [log] [blame]
## 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
# ERR-HEADER-SHORT: warning: '[[FILE]]': malformed note: header 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 0 /* no file mappings */
# end:
--- !ELF
FileHeader:
Class: ELFCLASS64
Data: ELFDATA2LSB
Type: ET_CORE
Machine: EM_X86_64
Sections:
- Name: .note.foo
Type: SHT_NOTE
Content: 0500000008000000454C4946434F5245000000000000000000000000
ProgramHeaders:
- Type: PT_NOTE
Sections:
- Section: .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
# ERR-NULL-TERM: warning: '[[FILE]]': malformed note: 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
Machine: EM_X86_64
Sections:
- Name: .note.foo
Type: SHT_NOTE
Content: 050000002C000000454C4946434F5245000000000100000000000000001000000000000000100000000000000020000000000000003000000000000078787878
ProgramHeaders:
- Type: PT_NOTE
Sections:
- Section: .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
# ERR-FILE-COUNT: warning: '[[FILE]]': malformed note: too short for number of files
# .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
Machine: EM_X86_64
Sections:
- Name: .note.foo
Type: SHT_NOTE
Content: 050000002C000000454C4946434F5245000000000200000000000000001000000000000000100000000000000020000000000000003000000000000078797A00
ProgramHeaders:
- Type: PT_NOTE
Sections:
- Section: .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
# ERR-FILE-END-EARLY: warning: '[[FILE]]': malformed note: too few filenames
# .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
Machine: EM_X86_64
Sections:
- Name: .note.foo
Type: SHT_NOTE
Content: 0500000044000000454C4946434F5245000000000200000000000000001000000000000000100000000000000020000000000000003000000000000000400000000000000050000000000000006000000000000078797A00
ProgramHeaders:
- Type: PT_NOTE
Sections:
- Section: .note.foo