You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
382 lines
11 KiB
382 lines
11 KiB
## a) Test that obj2yaml is able to dump the __debug_str section.
|
|
|
|
# RUN: yaml2obj --docnum=1 %s | obj2yaml | FileCheck %s
|
|
|
|
--- !mach-o
|
|
FileHeader:
|
|
magic: 0xFEEDFACF
|
|
cputype: 0x01000007
|
|
cpusubtype: 0x00000003
|
|
filetype: 0x0000000A
|
|
ncmds: 6
|
|
sizeofcmds: 1376
|
|
flags: 0x00000000
|
|
reserved: 0x00000000
|
|
LoadCommands:
|
|
- cmd: LC_UUID
|
|
cmdsize: 24
|
|
uuid: 9304404B-E522-3BBA-A861-AF5938908725
|
|
- cmd: LC_SYMTAB
|
|
cmdsize: 24
|
|
symoff: 4096
|
|
nsyms: 2
|
|
stroff: 4128
|
|
strsize: 28
|
|
- cmd: LC_SEGMENT_64
|
|
cmdsize: 72
|
|
segname: __PAGEZERO
|
|
vmaddr: 0
|
|
vmsize: 4294967296
|
|
fileoff: 0
|
|
filesize: 0
|
|
maxprot: 0
|
|
initprot: 0
|
|
nsects: 0
|
|
flags: 0
|
|
- cmd: LC_SEGMENT_64
|
|
cmdsize: 232
|
|
segname: __TEXT
|
|
vmaddr: 4294967296
|
|
vmsize: 4096
|
|
fileoff: 0
|
|
filesize: 0
|
|
maxprot: 7
|
|
initprot: 5
|
|
nsects: 2
|
|
flags: 0
|
|
Sections:
|
|
- sectname: __text
|
|
segname: __TEXT
|
|
addr: 0x0000000100000FA0
|
|
size: 22
|
|
offset: 0x00000000
|
|
align: 4
|
|
reloff: 0x00000000
|
|
nreloc: 0
|
|
flags: 0x80000400
|
|
reserved1: 0x00000000
|
|
reserved2: 0x00000000
|
|
reserved3: 0x00000000
|
|
- sectname: __unwind_info
|
|
segname: __TEXT
|
|
addr: 0x0000000100000FB8
|
|
size: 72
|
|
offset: 0x00000000
|
|
align: 2
|
|
reloff: 0x00000000
|
|
nreloc: 0
|
|
flags: 0x00000000
|
|
reserved1: 0x00000000
|
|
reserved2: 0x00000000
|
|
reserved3: 0x00000000
|
|
- cmd: LC_SEGMENT_64
|
|
cmdsize: 72
|
|
segname: __LINKEDIT
|
|
vmaddr: 4294971392
|
|
vmsize: 4096
|
|
fileoff: 4096
|
|
filesize: 60
|
|
maxprot: 7
|
|
initprot: 1
|
|
nsects: 0
|
|
flags: 0
|
|
- cmd: LC_SEGMENT_64
|
|
cmdsize: 952
|
|
segname: __DWARF
|
|
vmaddr: 4294975488
|
|
vmsize: 4096
|
|
fileoff: 8192
|
|
filesize: 765
|
|
maxprot: 7
|
|
initprot: 3
|
|
nsects: 11
|
|
flags: 0
|
|
Sections:
|
|
- sectname: __debug_line
|
|
segname: __DWARF
|
|
addr: 0x0000000100002000
|
|
size: 70
|
|
offset: 0x00002000
|
|
align: 0
|
|
reloff: 0x00000000
|
|
nreloc: 0
|
|
flags: 0x00000000
|
|
reserved1: 0x00000000
|
|
reserved2: 0x00000000
|
|
reserved3: 0x00000000
|
|
- sectname: __debug_pubnames
|
|
segname: __DWARF
|
|
addr: 0x0000000100002046
|
|
size: 27
|
|
offset: 0x00002046
|
|
align: 0
|
|
reloff: 0x00000000
|
|
nreloc: 0
|
|
flags: 0x00000000
|
|
reserved1: 0x00000000
|
|
reserved2: 0x00000000
|
|
reserved3: 0x00000000
|
|
- sectname: __debug_pubtypes
|
|
segname: __DWARF
|
|
addr: 0x0000000100002061
|
|
size: 35
|
|
offset: 0x00002061
|
|
align: 0
|
|
reloff: 0x00000000
|
|
nreloc: 0
|
|
flags: 0x00000000
|
|
reserved1: 0x00000000
|
|
reserved2: 0x00000000
|
|
reserved3: 0x00000000
|
|
- sectname: __debug_info
|
|
segname: __DWARF
|
|
addr: 0x00000001000020B4
|
|
size: 121
|
|
offset: 0x000020B4
|
|
align: 0
|
|
reloff: 0x00000000
|
|
nreloc: 0
|
|
flags: 0x00000000
|
|
reserved1: 0x00000000
|
|
reserved2: 0x00000000
|
|
reserved3: 0x00000000
|
|
- sectname: __debug_abbrev
|
|
segname: __DWARF
|
|
addr: 0x000000010000212D
|
|
size: 76
|
|
offset: 0x0000212D
|
|
align: 0
|
|
reloff: 0x00000000
|
|
nreloc: 0
|
|
flags: 0x00000000
|
|
reserved1: 0x00000000
|
|
reserved2: 0x00000000
|
|
reserved3: 0x00000000
|
|
- sectname: __debug_str
|
|
segname: __DWARF
|
|
addr: 0x0000000100002179
|
|
size: 142
|
|
offset: 0x00002179
|
|
align: 0
|
|
reloff: 0x00000000
|
|
nreloc: 0
|
|
flags: 0x00000000
|
|
reserved1: 0x00000000
|
|
reserved2: 0x00000000
|
|
reserved3: 0x00000000
|
|
- sectname: __apple_names
|
|
segname: __DWARF
|
|
addr: 0x0000000100002207
|
|
size: 60
|
|
offset: 0x00002207
|
|
align: 0
|
|
reloff: 0x00000000
|
|
nreloc: 0
|
|
flags: 0x00000000
|
|
reserved1: 0x00000000
|
|
reserved2: 0x00000000
|
|
reserved3: 0x00000000
|
|
- sectname: __apple_namespac
|
|
segname: __DWARF
|
|
addr: 0x0000000100002243
|
|
size: 36
|
|
offset: 0x00002243
|
|
align: 0
|
|
reloff: 0x00000000
|
|
nreloc: 0
|
|
flags: 0x00000000
|
|
reserved1: 0x00000000
|
|
reserved2: 0x00000000
|
|
reserved3: 0x00000000
|
|
- sectname: __apple_types
|
|
segname: __DWARF
|
|
addr: 0x0000000100002267
|
|
size: 114
|
|
offset: 0x00002267
|
|
align: 0
|
|
reloff: 0x00000000
|
|
nreloc: 0
|
|
flags: 0x00000000
|
|
reserved1: 0x00000000
|
|
reserved2: 0x00000000
|
|
reserved3: 0x00000000
|
|
- sectname: __apple_objc
|
|
segname: __DWARF
|
|
addr: 0x00000001000022D9
|
|
size: 36
|
|
offset: 0x000022D9
|
|
align: 0
|
|
reloff: 0x00000000
|
|
nreloc: 0
|
|
flags: 0x00000000
|
|
reserved1: 0x00000000
|
|
reserved2: 0x00000000
|
|
reserved3: 0x00000000
|
|
LinkEditData:
|
|
NameList:
|
|
- n_strx: 2
|
|
n_type: 0x0F
|
|
n_sect: 1
|
|
n_desc: 16
|
|
n_value: 4294967296
|
|
- n_strx: 22
|
|
n_type: 0x0F
|
|
n_sect: 1
|
|
n_desc: 0
|
|
n_value: 4294971296
|
|
StringTable:
|
|
- ''
|
|
- ''
|
|
- __mh_execute_header
|
|
- _main
|
|
DWARF:
|
|
debug_str:
|
|
- ''
|
|
- 'clang version 4.0.0 (trunk 288677) (llvm/trunk 288676)'
|
|
- hello_world.c
|
|
- /Users/cbieneman/dev/open-source/llvm-build-rel
|
|
- main
|
|
- argc
|
|
- argv
|
|
- int
|
|
- char
|
|
...
|
|
|
|
#CHECK: DWARF:
|
|
#CHECK: debug_str:
|
|
#CHECK: - ''
|
|
#CHECK: - 'clang version 4.0.0 (trunk 288677) (llvm/trunk 288676)'
|
|
#CHECK: - hello_world.c
|
|
#CHECK: - '/Users/cbieneman/dev/open-source/llvm-build-rel'
|
|
#CHECK: - main
|
|
#CHECK: - argc
|
|
#CHECK: - argv
|
|
#CHECK: - int
|
|
#CHECK: - char
|
|
|
|
## b) Test dumping an empty __debug_str section.
|
|
|
|
# RUN: yaml2obj --docnum=2 -DCONTENT='[]' %s | obj2yaml | FileCheck %s --check-prefix=EMPTY-CONTENT
|
|
|
|
# EMPTY-CONTENT: Sections:
|
|
# EMPTY-CONTENT-NEXT: - sectname: __debug_str
|
|
# EMPTY-CONTENT-NEXT: segname: __DWARF
|
|
# EMPTY-CONTENT-NEXT: addr: 0x0
|
|
# EMPTY-CONTENT-NEXT: size: 0
|
|
# EMPTY-CONTENT-NEXT: offset: 0x210
|
|
# EMPTY-CONTENT-NEXT: align: 0
|
|
# EMPTY-CONTENT-NEXT: reloff: 0x0
|
|
# EMPTY-CONTENT-NEXT: nreloc: 0
|
|
# EMPTY-CONTENT-NEXT: flags: 0x0
|
|
# EMPTY-CONTENT-NEXT: reserved1: 0x0
|
|
# EMPTY-CONTENT-NEXT: reserved2: 0x0
|
|
# EMPTY-CONTENT-NEXT: reserved3: 0x0
|
|
# EMPTY-CONTENT-NEXT: DWARF:
|
|
# EMPTY-CONTENT-NEXT: debug_str: []
|
|
|
|
--- !mach-o
|
|
FileHeader:
|
|
magic: 0xFEEDFACF
|
|
cputype: 0x01000007
|
|
cpusubtype: 0x00000003
|
|
filetype: 0x0000000A
|
|
ncmds: 1
|
|
sizeofcmds: 232
|
|
flags: 0x00000000
|
|
reserved: 0x00000000
|
|
LoadCommands:
|
|
- cmd: LC_SEGMENT_64
|
|
cmdsize: 152
|
|
segname: __DWARF
|
|
vmaddr: 0x00
|
|
vmsize: 0x00
|
|
fileoff: 0x00
|
|
filesize: 0x00
|
|
maxprot: 0
|
|
initprot: 0
|
|
nsects: 1
|
|
flags: 0
|
|
Sections:
|
|
- sectname: __debug_str
|
|
segname: __DWARF
|
|
addr: 0x00
|
|
size: [[SIZE=0]]
|
|
offset: 0x210
|
|
align: 0
|
|
reloff: 0x00000000
|
|
nreloc: 0
|
|
flags: 0x00000000
|
|
reserved1: 0x00000000
|
|
reserved2: 0x00000000
|
|
reserved3: 0x00000000
|
|
DWARF:
|
|
debug_str:
|
|
[[CONTENT]]
|
|
|
|
## c) Test generating and dumping a __debug_str section who only has an empty string.
|
|
|
|
# RUN: yaml2obj --docnum=2 -DCONTENT='[ "" ]' -DSIZE=1 %s | obj2yaml | FileCheck %s --check-prefix=EMPTY-STRING
|
|
|
|
# EMPTY-STRING: DWARF:
|
|
# EMPTY-STRING-NEXT: debug_str:
|
|
# EMPTY-STRING-NEXT: - ''
|
|
# EMPTY-STRING-NEXT: ...
|
|
|
|
## d) Test generating and dumping a __debug_str section which contains a string without a null terminator.
|
|
|
|
# RUN: yaml2obj --docnum=3 %s | obj2yaml | FileCheck %s --check-prefix=NO-TERMINATOR
|
|
|
|
# NO-TERMINATOR-NOT: DWARF:
|
|
# NO-TERMINATOR: Sections:
|
|
# NO-TERMINATOR-NEXT: - sectname: __debug_str
|
|
# NO-TERMINATOR-NEXT: segname: __DWARF
|
|
# NO-TERMINATOR-NEXT: addr: 0x0
|
|
# NO-TERMINATOR-NEXT: size: 7
|
|
# NO-TERMINATOR-NEXT: offset: 0x210
|
|
# NO-TERMINATOR-NEXT: align: 0
|
|
# NO-TERMINATOR-NEXT: reloff: 0x0
|
|
# NO-TERMINATOR-NEXT: nreloc: 0
|
|
# NO-TERMINATOR-NEXT: flags: 0x0
|
|
# NO-TERMINATOR-NEXT: reserved1: 0x0
|
|
# NO-TERMINATOR-NEXT: reserved2: 0x0
|
|
# NO-TERMINATOR-NEXT: reserved3: 0x0
|
|
# NO-TERMINATOR-NEXT: content: '61626300616263'
|
|
# NO-TERMINATOR-NEXT: ...
|
|
|
|
--- !mach-o
|
|
FileHeader:
|
|
magic: 0xFEEDFACF
|
|
cputype: 0x01000007
|
|
cpusubtype: 0x00000003
|
|
filetype: 0x0000000A
|
|
ncmds: 1
|
|
sizeofcmds: 232
|
|
flags: 0x00000000
|
|
reserved: 0x00000000
|
|
LoadCommands:
|
|
- cmd: LC_SEGMENT_64
|
|
cmdsize: 152
|
|
segname: __DWARF
|
|
vmaddr: 0x00
|
|
vmsize: 0x00
|
|
fileoff: 0x00
|
|
filesize: 0x00
|
|
maxprot: 0
|
|
initprot: 0
|
|
nsects: 1
|
|
flags: 0
|
|
Sections:
|
|
- sectname: __debug_str
|
|
segname: __DWARF
|
|
addr: 0x00
|
|
size: 7
|
|
offset: 0x210
|
|
align: 0
|
|
reloff: 0x00000000
|
|
nreloc: 0
|
|
flags: 0x00000000
|
|
reserved1: 0x00000000
|
|
reserved2: 0x00000000
|
|
reserved3: 0x00000000
|
|
content: '61626300616263' ## "abc\0abc"
|