1## a) Test that obj2yaml is able to dump the __debug_str section. 2 3# RUN: yaml2obj --docnum=1 %s | obj2yaml | FileCheck %s 4 5--- !mach-o 6FileHeader: 7 magic: 0xFEEDFACF 8 cputype: 0x01000007 9 cpusubtype: 0x00000003 10 filetype: 0x0000000A 11 ncmds: 6 12 sizeofcmds: 1376 13 flags: 0x00000000 14 reserved: 0x00000000 15LoadCommands: 16 - cmd: LC_UUID 17 cmdsize: 24 18 uuid: 9304404B-E522-3BBA-A861-AF5938908725 19 - cmd: LC_SYMTAB 20 cmdsize: 24 21 symoff: 4096 22 nsyms: 2 23 stroff: 4128 24 strsize: 28 25 - cmd: LC_SEGMENT_64 26 cmdsize: 72 27 segname: __PAGEZERO 28 vmaddr: 0 29 vmsize: 4294967296 30 fileoff: 0 31 filesize: 0 32 maxprot: 0 33 initprot: 0 34 nsects: 0 35 flags: 0 36 - cmd: LC_SEGMENT_64 37 cmdsize: 232 38 segname: __TEXT 39 vmaddr: 4294967296 40 vmsize: 4096 41 fileoff: 0 42 filesize: 0 43 maxprot: 7 44 initprot: 5 45 nsects: 2 46 flags: 0 47 Sections: 48 - sectname: __text 49 segname: __TEXT 50 addr: 0x0000000100000FA0 51 size: 22 52 offset: 0x00000000 53 align: 4 54 reloff: 0x00000000 55 nreloc: 0 56 flags: 0x80000400 57 reserved1: 0x00000000 58 reserved2: 0x00000000 59 reserved3: 0x00000000 60 - sectname: __unwind_info 61 segname: __TEXT 62 addr: 0x0000000100000FB8 63 size: 72 64 offset: 0x00000000 65 align: 2 66 reloff: 0x00000000 67 nreloc: 0 68 flags: 0x00000000 69 reserved1: 0x00000000 70 reserved2: 0x00000000 71 reserved3: 0x00000000 72 - cmd: LC_SEGMENT_64 73 cmdsize: 72 74 segname: __LINKEDIT 75 vmaddr: 4294971392 76 vmsize: 4096 77 fileoff: 4096 78 filesize: 60 79 maxprot: 7 80 initprot: 1 81 nsects: 0 82 flags: 0 83 - cmd: LC_SEGMENT_64 84 cmdsize: 952 85 segname: __DWARF 86 vmaddr: 4294975488 87 vmsize: 4096 88 fileoff: 8192 89 filesize: 765 90 maxprot: 7 91 initprot: 3 92 nsects: 11 93 flags: 0 94 Sections: 95 - sectname: __debug_line 96 segname: __DWARF 97 addr: 0x0000000100002000 98 size: 70 99 offset: 0x00002000 100 align: 0 101 reloff: 0x00000000 102 nreloc: 0 103 flags: 0x00000000 104 reserved1: 0x00000000 105 reserved2: 0x00000000 106 reserved3: 0x00000000 107 - sectname: __debug_pubnames 108 segname: __DWARF 109 addr: 0x0000000100002046 110 size: 27 111 offset: 0x00002046 112 align: 0 113 reloff: 0x00000000 114 nreloc: 0 115 flags: 0x00000000 116 reserved1: 0x00000000 117 reserved2: 0x00000000 118 reserved3: 0x00000000 119 - sectname: __debug_pubtypes 120 segname: __DWARF 121 addr: 0x0000000100002061 122 size: 35 123 offset: 0x00002061 124 align: 0 125 reloff: 0x00000000 126 nreloc: 0 127 flags: 0x00000000 128 reserved1: 0x00000000 129 reserved2: 0x00000000 130 reserved3: 0x00000000 131 - sectname: __debug_info 132 segname: __DWARF 133 addr: 0x00000001000020B4 134 size: 121 135 offset: 0x000020B4 136 align: 0 137 reloff: 0x00000000 138 nreloc: 0 139 flags: 0x00000000 140 reserved1: 0x00000000 141 reserved2: 0x00000000 142 reserved3: 0x00000000 143 - sectname: __debug_abbrev 144 segname: __DWARF 145 addr: 0x000000010000212D 146 size: 76 147 offset: 0x0000212D 148 align: 0 149 reloff: 0x00000000 150 nreloc: 0 151 flags: 0x00000000 152 reserved1: 0x00000000 153 reserved2: 0x00000000 154 reserved3: 0x00000000 155 - sectname: __debug_str 156 segname: __DWARF 157 addr: 0x0000000100002179 158 size: 142 159 offset: 0x00002179 160 align: 0 161 reloff: 0x00000000 162 nreloc: 0 163 flags: 0x00000000 164 reserved1: 0x00000000 165 reserved2: 0x00000000 166 reserved3: 0x00000000 167 - sectname: __apple_names 168 segname: __DWARF 169 addr: 0x0000000100002207 170 size: 60 171 offset: 0x00002207 172 align: 0 173 reloff: 0x00000000 174 nreloc: 0 175 flags: 0x00000000 176 reserved1: 0x00000000 177 reserved2: 0x00000000 178 reserved3: 0x00000000 179 - sectname: __apple_namespac 180 segname: __DWARF 181 addr: 0x0000000100002243 182 size: 36 183 offset: 0x00002243 184 align: 0 185 reloff: 0x00000000 186 nreloc: 0 187 flags: 0x00000000 188 reserved1: 0x00000000 189 reserved2: 0x00000000 190 reserved3: 0x00000000 191 - sectname: __apple_types 192 segname: __DWARF 193 addr: 0x0000000100002267 194 size: 114 195 offset: 0x00002267 196 align: 0 197 reloff: 0x00000000 198 nreloc: 0 199 flags: 0x00000000 200 reserved1: 0x00000000 201 reserved2: 0x00000000 202 reserved3: 0x00000000 203 - sectname: __apple_objc 204 segname: __DWARF 205 addr: 0x00000001000022D9 206 size: 36 207 offset: 0x000022D9 208 align: 0 209 reloff: 0x00000000 210 nreloc: 0 211 flags: 0x00000000 212 reserved1: 0x00000000 213 reserved2: 0x00000000 214 reserved3: 0x00000000 215LinkEditData: 216 NameList: 217 - n_strx: 2 218 n_type: 0x0F 219 n_sect: 1 220 n_desc: 16 221 n_value: 4294967296 222 - n_strx: 22 223 n_type: 0x0F 224 n_sect: 1 225 n_desc: 0 226 n_value: 4294971296 227 StringTable: 228 - '' 229 - '' 230 - __mh_execute_header 231 - _main 232DWARF: 233 debug_str: 234 - '' 235 - 'clang version 4.0.0 (trunk 288677) (llvm/trunk 288676)' 236 - hello_world.c 237 - /Users/cbieneman/dev/open-source/llvm-build-rel 238 - main 239 - argc 240 - argv 241 - int 242 - char 243... 244 245#CHECK: DWARF: 246#CHECK: debug_str: 247#CHECK: - '' 248#CHECK: - 'clang version 4.0.0 (trunk 288677) (llvm/trunk 288676)' 249#CHECK: - hello_world.c 250#CHECK: - '/Users/cbieneman/dev/open-source/llvm-build-rel' 251#CHECK: - main 252#CHECK: - argc 253#CHECK: - argv 254#CHECK: - int 255#CHECK: - char 256 257## b) Test dumping an empty __debug_str section. 258 259# RUN: yaml2obj --docnum=2 -DCONTENT='[]' %s | obj2yaml | FileCheck %s --check-prefix=EMPTY-CONTENT 260 261# EMPTY-CONTENT: Sections: 262# EMPTY-CONTENT-NEXT: - sectname: __debug_str 263# EMPTY-CONTENT-NEXT: segname: __DWARF 264# EMPTY-CONTENT-NEXT: addr: 0x0 265# EMPTY-CONTENT-NEXT: size: 0 266# EMPTY-CONTENT-NEXT: offset: 0x210 267# EMPTY-CONTENT-NEXT: align: 0 268# EMPTY-CONTENT-NEXT: reloff: 0x0 269# EMPTY-CONTENT-NEXT: nreloc: 0 270# EMPTY-CONTENT-NEXT: flags: 0x0 271# EMPTY-CONTENT-NEXT: reserved1: 0x0 272# EMPTY-CONTENT-NEXT: reserved2: 0x0 273# EMPTY-CONTENT-NEXT: reserved3: 0x0 274# EMPTY-CONTENT-NEXT: DWARF: 275# EMPTY-CONTENT-NEXT: debug_str: [] 276 277--- !mach-o 278FileHeader: 279 magic: 0xFEEDFACF 280 cputype: 0x01000007 281 cpusubtype: 0x00000003 282 filetype: 0x0000000A 283 ncmds: 1 284 sizeofcmds: 232 285 flags: 0x00000000 286 reserved: 0x00000000 287LoadCommands: 288 - cmd: LC_SEGMENT_64 289 cmdsize: 152 290 segname: __DWARF 291 vmaddr: 0x00 292 vmsize: 0x00 293 fileoff: 0x00 294 filesize: 0x00 295 maxprot: 0 296 initprot: 0 297 nsects: 1 298 flags: 0 299 Sections: 300 - sectname: __debug_str 301 segname: __DWARF 302 addr: 0x00 303 size: [[SIZE=0]] 304 offset: 0x210 305 align: 0 306 reloff: 0x00000000 307 nreloc: 0 308 flags: 0x00000000 309 reserved1: 0x00000000 310 reserved2: 0x00000000 311 reserved3: 0x00000000 312DWARF: 313 debug_str: 314 [[CONTENT]] 315 316## c) Test generating and dumping a __debug_str section who only has an empty string. 317 318# RUN: yaml2obj --docnum=2 -DCONTENT='[ "" ]' -DSIZE=1 %s | obj2yaml | FileCheck %s --check-prefix=EMPTY-STRING 319 320# EMPTY-STRING: DWARF: 321# EMPTY-STRING-NEXT: debug_str: 322# EMPTY-STRING-NEXT: - '' 323# EMPTY-STRING-NEXT: ... 324 325## d) Test generating and dumping a __debug_str section which contains a string without a null terminator. 326 327# RUN: yaml2obj --docnum=3 %s | obj2yaml | FileCheck %s --check-prefix=NO-TERMINATOR 328 329# NO-TERMINATOR-NOT: DWARF: 330# NO-TERMINATOR: Sections: 331# NO-TERMINATOR-NEXT: - sectname: __debug_str 332# NO-TERMINATOR-NEXT: segname: __DWARF 333# NO-TERMINATOR-NEXT: addr: 0x0 334# NO-TERMINATOR-NEXT: size: 7 335# NO-TERMINATOR-NEXT: offset: 0x210 336# NO-TERMINATOR-NEXT: align: 0 337# NO-TERMINATOR-NEXT: reloff: 0x0 338# NO-TERMINATOR-NEXT: nreloc: 0 339# NO-TERMINATOR-NEXT: flags: 0x0 340# NO-TERMINATOR-NEXT: reserved1: 0x0 341# NO-TERMINATOR-NEXT: reserved2: 0x0 342# NO-TERMINATOR-NEXT: reserved3: 0x0 343# NO-TERMINATOR-NEXT: content: '61626300616263' 344# NO-TERMINATOR-NEXT: ... 345 346--- !mach-o 347FileHeader: 348 magic: 0xFEEDFACF 349 cputype: 0x01000007 350 cpusubtype: 0x00000003 351 filetype: 0x0000000A 352 ncmds: 1 353 sizeofcmds: 232 354 flags: 0x00000000 355 reserved: 0x00000000 356LoadCommands: 357 - cmd: LC_SEGMENT_64 358 cmdsize: 152 359 segname: __DWARF 360 vmaddr: 0x00 361 vmsize: 0x00 362 fileoff: 0x00 363 filesize: 0x00 364 maxprot: 0 365 initprot: 0 366 nsects: 1 367 flags: 0 368 Sections: 369 - sectname: __debug_str 370 segname: __DWARF 371 addr: 0x00 372 size: 7 373 offset: 0x210 374 align: 0 375 reloff: 0x00000000 376 nreloc: 0 377 flags: 0x00000000 378 reserved1: 0x00000000 379 reserved2: 0x00000000 380 reserved3: 0x00000000 381 content: '61626300616263' ## "abc\0abc" 382