139 lines · plain
1## Test that NT_FILE sections in core files are interpreted correctly.2 3# RUN: yaml2obj %s -o %t.o4# RUN: llvm-readelf --notes %t.o | FileCheck %s --check-prefix=GNU5# RUN: llvm-readobj --notes %t.o | FileCheck %s --check-prefix=LLVM6# RUN: llvm-readobj --elf-output-style=JSON --pretty-print --notes %t.o | FileCheck %s --check-prefix=JSON7 8## llvm-mc doesn't support generating ET_CORE files; the 'Content' field was9## generated with the following steps:10# $ llvm-mc -filetype=obj -triple x86_64-pc-linux-gnu tmp.s -o tmp.o11# $ bin/llvm-objcopy --dump-section=.note.foo=tmp.txt tmp.o /dev/null12# $ xxd -p tmp.txt | tr -d '\n'; echo13## Using the following input:14# .section ".note.foo", "a"15# .align 416# .long 5 /* namesz */17# .long end - begin /* descsz */18# .long 0x46494c45 /* type = NT_FILE */19# .asciz "CORE"20# .align 421# begin:22# .quad 3 /* 3 file mappings */23# .quad 4096 /* page size */24# .quad 0x1000 /* start #1 */25# .quad 0x2000 /* end #1 */26# .quad 0x3000 /* offset #1 */27# .quad 0x4000 /* start #2 */28# .quad 0x5000 /* end #2 */29# .quad 0x6000 /* offset #2 */30# .quad 0x7000 /* start #3 */31# .quad 0x8000 /* end #3 */32# .quad 0x9000 /* offset #3 */33# .asciz "/path/to/a.out"34# .asciz "/path/to/libc.so"35# .asciz "[stack]"36# .align 437# end:38 39--- !ELF40FileHeader:41 Class: ELFCLASS6442 Data: ELFDATA2LSB43 Type: ET_CORE44Sections:45 - Name: .note.foo46 Type: SHT_NOTE47 Content: 0500000080000000454C4946434F524500000000030000000000000000100000000000000010000000000000002000000000000000300000000000000040000000000000005000000000000000600000000000000070000000000000008000000000000000900000000000002F706174682F746F2F612E6F7574002F706174682F746F2F6C6962632E736F005B737461636B5D0048ProgramHeaders:49 - Type: PT_NOTE50 FirstSec: .note.foo51 LastSec: .note.foo52 53# GNU: Displaying notes found54# GNU-NEXT: Owner Data size Description55# GNU-NEXT: CORE 0x00000080 NT_FILE (mapped files)56# GNU-NEXT: Page size: 409657# GNU-NEXT: Start End Page Offset58# GNU-NEXT: 0x0000000000001000 0x0000000000002000 0x000000000000300059# GNU-NEXT: /path/to/a.out60# GNU-NEXT: 0x0000000000004000 0x0000000000005000 0x000000000000600061# GNU-NEXT: /path/to/libc.so62# GNU-NEXT: 0x0000000000007000 0x0000000000008000 0x000000000000900063# GNU-NEXT: [stack]64# GNU-EMPTY:65 66# LLVM: NoteSections [67# LLVM-NEXT: NoteSection {68# LLVM-NEXT: Name: <?>69# LLVM-NEXT: Offset:70# LLVM-NEXT: Size:71# LLVM-NEXT: Notes [72# LLVM-NEXT: {73# LLVM-NEXT: Owner: CORE74# LLVM-NEXT: Data size: 0x8075# LLVM-NEXT: Type: NT_FILE (mapped files)76# LLVM-NEXT: Page Size: 409677# LLVM-NEXT: Mappings [78# LLVM-NEXT: {79# LLVM-NEXT: Start: 0x100080# LLVM-NEXT: End: 0x200081# LLVM-NEXT: Offset: 0x300082# LLVM-NEXT: Filename: /path/to/a.out83# LLVM-NEXT: }84# LLVM-NEXT: {85# LLVM-NEXT: Start: 0x400086# LLVM-NEXT: End: 0x500087# LLVM-NEXT: Offset: 0x600088# LLVM-NEXT: Filename: /path/to/libc.so89# LLVM-NEXT: }90# LLVM-NEXT: {91# LLVM-NEXT: Start: 0x700092# LLVM-NEXT: End: 0x800093# LLVM-NEXT: Offset: 0x900094# LLVM-NEXT: Filename: [stack]95# LLVM-NEXT: }96# LLVM-NEXT: ]97# LLVM-NEXT: }98# LLVM-NEXT: ]99# LLVM-NEXT: }100# LLVM-NEXT: ]101 102# JSON: "NoteSections": [103# JSON-NEXT: {104# JSON-NEXT: "NoteSection": {105# JSON-NEXT: "Name": "<?>",106# JSON-NEXT: "Offset": 120,107# JSON-NEXT: "Size": 148,108# JSON-NEXT: "Notes": [109# JSON-NEXT: {110# JSON-NEXT: "Owner": "CORE",111# JSON-NEXT: "Data size": 128,112# JSON-NEXT: "Type": "NT_FILE (mapped files)",113# JSON-NEXT: "Page Size": 4096,114# JSON-NEXT: "Mappings": [115# JSON-NEXT: {116# JSON-NEXT: "Start": 4096,117# JSON-NEXT: "End": 8192,118# JSON-NEXT: "Offset": 12288,119# JSON-NEXT: "Filename": "/path/to/a.out"120# JSON-NEXT: },121# JSON-NEXT: {122# JSON-NEXT: "Start": 16384,123# JSON-NEXT: "End": 20480,124# JSON-NEXT: "Offset": 24576,125# JSON-NEXT: "Filename": "/path/to/libc.so"126# JSON-NEXT: },127# JSON-NEXT: {128# JSON-NEXT: "Start": 28672,129# JSON-NEXT: "End": 32768,130# JSON-NEXT: "Offset": 36864,131# JSON-NEXT: "Filename": "[stack]"132# JSON-NEXT: }133# JSON-NEXT: ]134# JSON-NEXT: }135# JSON-NEXT: ]136# JSON-NEXT: }137# JSON-NEXT: }138# JSON-NEXT: ]139