## This file contains test cases for generating .debug_pubnames/.debug_pubtypes
## section in object files from the DWARF entry of Mach-O YAML inputs
## a) Test that yaml2obj emits the .debug_pubnames and .debug_pubtypes sections and
## obj2yaml converts them back.
# RUN: yaml2obj %s | obj2yaml | FileCheck %s
--- !mach-o
FileHeader:
magic: 0xFEEDFACF
cputype: 0x01000007
cpusubtype: 0x00000003
filetype: 0x0000000A
ncmds: 1
sizeofcmds: 1800
flags: 0x00000000
reserved: 0x00000000
LoadCommands:
- cmd: LC_SEGMENT_64
cmdsize: 232
segname: __DWARF
vmaddr: 0
vmsize: 0
fileoff: 152
filesize: 0xffff
maxprot: 0
initprot: 0
nsects: 2
flags: 0
Sections:
- sectname: __debug_pubnames
segname: __DWARF
addr: 0x0000000000000000
size: 27
offset: 0x00000152
align: 0
reloff: 0x00000000
nreloc: 0
flags: 0x00000000
reserved1: 0x00000000
reserved2: 0x00000000
reserved3: 0x00000000
- sectname: __debug_pubtypes
segname: __DWARF
addr: 0x0000000000000000
size: 35
offset: 0x00000720
align: 0
reloff: 0x00000000
nreloc: 0
flags: 0x00000000
reserved1: 0x00000000
reserved2: 0x00000000
reserved3: 0x00000000
DWARF:
debug_pubnames:
Length: 23
Version: 2
UnitOffset: 0
UnitSize: 121
Entries:
- DieOffset: 0x0000002A
Name: main
debug_pubtypes:
Length: 31
Version: 2
UnitOffset: 0
UnitSize: 121
Entries:
- DieOffset: 0x00000060
Name: int
- DieOffset: 0x00000071
Name: char
# CHECK: DWARF:
# CHECK: debug_pubnames:
# CHECK-NEXT: Length: 0x17
# CHECK-NEXT: Version: 2
# CHECK-NEXT: UnitOffset: 0
# CHECK-NEXT: UnitSize: 121
# CHECK-NEXT: Entries:
# CHECK-NEXT: - DieOffset: 0x2A
# CHECK-NEXT: Name: main
# CHECK-NEXT: debug_pubtypes:
# CHECK-NEXT: Length: 0x1F
# CHECK-NEXT: Version: 2
# CHECK-NEXT: UnitOffset: 0
# CHECK-NEXT: UnitSize: 121
# CHECK-NEXT: Entries:
# CHECK-NEXT: - DieOffset: 0x60
# CHECK-NEXT: Name: int
# CHECK-NEXT: - DieOffset: 0x71
# CHECK-NEXT: Name: char
# CHECK-NEXT: ...
## b) Test that yaml2obj will not emit the .debug_pubnames/.debug_pubtypes section's
## contents, if the "debug_pubnames"/"debug_pubtypes" entry doesn't exist in the
## "DWARF" entry.
# RUN: yaml2obj --docnum=2 %s -o %t2
# RUN: obj2yaml %t2 | FileCheck %s --check-prefix=EMPTY
# EMPTY: Sections:
# EMPTY-NEXT: - sectname: __debug_pubnames
# EMPTY-NEXT: segname: __DWARF
# EMPTY-NEXT: addr: 0x0
# EMPTY-NEXT: size: 0
# EMPTY-NEXT: offset: 0x0
# EMPTY-NEXT: align: 0
# EMPTY-NEXT: reloff: 0x0
# EMPTY-NEXT: nreloc: 0
# EMPTY-NEXT: flags: 0x0
# EMPTY-NEXT: reserved1: 0x0
# EMPTY-NEXT: reserved2: 0x0
# EMPTY-NEXT: reserved3: 0x0
# EMPTY-NEXT: - sectname: __debug_pubtypes
# EMPTY-NEXT: segname: __DWARF
# EMPTY-NEXT: addr: 0x0
# EMPTY-NEXT: size: 0
# EMPTY-NEXT: offset: 0x720
# EMPTY-NEXT: align: 0
# EMPTY-NEXT: reloff: 0x0
# EMPTY-NEXT: nreloc: 0
# EMPTY-NEXT: flags: 0x0
# EMPTY-NEXT: reserved1: 0x0
# EMPTY-NEXT: reserved2: 0x0
# EMPTY-NEXT: reserved3: 0x0
# EMPTY-NEXT: ...
--- !mach-o
FileHeader:
magic: 0xFEEDFACF
cputype: 0x01000007
cpusubtype: 0x00000003
filetype: 0x0000000A
ncmds: 1
sizeofcmds: 1772
flags: 0x00000000
reserved: 0x00000000
LoadCommands:
- cmd: LC_SEGMENT_64
cmdsize: 232
segname: __DWARF
vmaddr: 0x00000000
vmsize: 0x00000000
fileoff: 0
filesize: 0
maxprot: 0
initprot: 0
nsects: 2
flags: 0
Sections:
- sectname: __debug_pubnames
segname: __DWARF
addr: 0x0000000000000000
size: 0
offset: 0x00000000
align: 0
reloff: 0x00000000
nreloc: 0
flags: 0x00000000
reserved1: 0x00000000
reserved2: 0x00000000
reserved3: 0x00000000
- sectname: __debug_pubtypes
segname: __DWARF
addr: 0x0000000000000000
size: 0
offset: 0x00000720
align: 0
reloff: 0x00000000
nreloc: 0
flags: 0x00000000
reserved1: 0x00000000
reserved2: 0x00000000
reserved3: 0x00000000
DWARF:
## c) Test that obj2yaml is able to dump a __debug_pubnames section whose length field is greater than the section size.
# RUN: yaml2obj --docnum=3 %s | obj2yaml | FileCheck %s --check-prefix=INVALID-LENGTH
# INVALID-LENGTH: DWARF:
# INVALID-LENGTH-NEXT: debug_pubnames:
# INVALID-LENGTH-NEXT: Length: 0xDEADBEEF
# INVALID-LENGTH-NEXT: Version: 2
# INVALID-LENGTH-NEXT: UnitOffset: 0
# INVALID-LENGTH-NEXT: UnitSize: 121
# INVALID-LENGTH-NEXT: Entries:
# INVALID-LENGTH-NEXT: - DieOffset: 0x2A
# INVALID-LENGTH-NEXT: Name: main
--- !mach-o
FileHeader:
magic: 0xFEEDFACF
cputype: 0x01000007
cpusubtype: 0x00000003
filetype: 0x0000000A
ncmds: 1
sizeofcmds: 1888
flags: 0x00000000
reserved: 0x00000000
LoadCommands:
- cmd: LC_SEGMENT_64
cmdsize: 152
segname: __DWARF
vmaddr: 0x00000000
vmsize: 0x00000000
fileoff: 0
filesize: 0xffff
maxprot: 0
initprot: 0
nsects: 1
flags: 0
Sections:
- sectname: __debug_pubnames
segname: __DWARF
addr: 0x0000000000000000
size: 24
offset: 0x000000b8
align: 0
reloff: 0x00000000
nreloc: 0
flags: 0x00000000
reserved1: 0x00000000
reserved2: 0x00000000
reserved3: 0x00000000
DWARF:
debug_pubnames:
Length: 0xdeadbeef
Version: 2
UnitOffset: 0
UnitSize: 121
Entries:
- DieOffset: 0x0000002A
Name: main