brintos

brintos / llvm-project-archived public Read only

0
0
Text · 6.0 KiB · a2d9a3b Raw
203 lines · yaml
1## Show that yaml2obj supports custom section data for Mach-O YAML inputs.2 3## Case 1: The size of content is greater than the section size.4# RUN: not yaml2obj --docnum=1 %s -o %t1 2>&1 | FileCheck %s --check-prefix=CASE15# CASE1: error: Section size must be greater than or equal to the content size6 7--- !mach-o8FileHeader:9  magic:           0xFEEDFACF10  cputype:         0x0100000711  cpusubtype:      0x0000000312  filetype:        0x0000000113  ncmds:           114  sizeofcmds:      23215  flags:           0x0000200016  reserved:        0x0000000017LoadCommands:18  - cmd:             LC_SEGMENT_6419    cmdsize:         23220    segname:         ''21    vmaddr:          022    vmsize:          423    fileoff:         39224    filesize:        425    maxprot:         726    initprot:        727    nsects:          128    flags:           029    Sections:30      - sectname:        __data31        segname:         __DATA32        addr:            0x000000000000000033        size:            034        offset:          0x0000018835        align:           236        reloff:          0x0000000037        nreloc:          038        flags:           0x0000000039        reserved1:       0x0000000040        reserved2:       0x0000000041        reserved3:       0x0000000042        content:         CDAB341243 44## Case 2: The content size equals the section size.45# RUN: yaml2obj --docnum=2 %s -o %t246# RUN: llvm-readobj --sections --section-data %t2 | FileCheck %s --check-prefix=CASE247# CASE2:       Index: 048# CASE2-NEXT:  Name: __data (5F 5F 64 61 74 61 00 00 00 00 00 00 00 00 00 00)49# CASE2-NEXT:  Segment: __DATA (5F 5F 44 41 54 41 00 00 00 00 00 00 00 00 00 00)50# CASE2-NEXT:  Address: 0x051# CASE2-NEXT:  Size: 0x452# CASE2-NEXT:  Offset: 39253# CASE2-NEXT:  Alignment: 254# CASE2-NEXT:  RelocationOffset: 0x055# CASE2-NEXT:  RelocationCount: 056# CASE2-NEXT:  Type: Regular (0x0)57# CASE2-NEXT:  Attributes [ (0x0)58# CASE2-NEXT:  ]59# CASE2-NEXT:  Reserved1: 0x060# CASE2-NEXT:  Reserved2: 0x061# CASE2-NEXT:  Reserved3: 0x062# CASE2-NEXT:  SectionData (63# CASE2-NEXT:    0000: CDAB3412                             |..4.|64# CASE2-NEXT:  )65 66--- !mach-o67FileHeader:68  magic:           0xFEEDFACF69  cputype:         0x0100000770  cpusubtype:      0x0000000371  filetype:        0x0000000172  ncmds:           173  sizeofcmds:      23274  flags:           0x0000200075  reserved:        0x0000000076LoadCommands:77  - cmd:             LC_SEGMENT_6478    cmdsize:         23279    segname:         ''80    vmaddr:          081    vmsize:          482    fileoff:         39283    filesize:        484    maxprot:         785    initprot:        786    nsects:          187    flags:           088    Sections:89      - sectname:        __data90        segname:         __DATA91        addr:            0x000000000000000092        size:            493        offset:          0x0000018894        align:           295        reloff:          0x0000000096        nreloc:          097        flags:           0x0000000098        reserved1:       0x0000000099        reserved2:       0x00000000100        reserved3:       0x00000000101        content:         CDAB3412102 103## Case 3: The content size is less than the section size. In this case, the area104## after the custom content is filled with zeroes.105# RUN: yaml2obj --docnum=3 %s -o %t3106# RUN: llvm-readobj --sections --section-data %t3 | FileCheck %s --check-prefix=CASE3107# CASE3:       Index: 0108# CASE3-NEXT:  Name: __data (5F 5F 64 61 74 61 00 00 00 00 00 00 00 00 00 00)109# CASE3-NEXT:  Segment: __DATA (5F 5F 44 41 54 41 00 00 00 00 00 00 00 00 00 00)110# CASE3-NEXT:  Address: 0x0111# CASE3-NEXT:  Size: 0x4112# CASE3-NEXT:  Offset: 392113# CASE3-NEXT:  Alignment: 2114# CASE3-NEXT:  RelocationOffset: 0x0115# CASE3-NEXT:  RelocationCount: 0116# CASE3-NEXT:  Type: Regular (0x0)117# CASE3-NEXT:  Attributes [ (0x0)118# CASE3-NEXT:  ]119# CASE3-NEXT:  Reserved1: 0x0120# CASE3-NEXT:  Reserved2: 0x0121# CASE3-NEXT:  Reserved3: 0x0122# CASE3-NEXT:  SectionData (123# CASE3-NEXT:    0000: AA000000                             |....|124# CASE3-NEXT:  )125 126--- !mach-o127FileHeader:128  magic:           0xFEEDFACF129  cputype:         0x01000007130  cpusubtype:      0x00000003131  filetype:        0x00000001132  ncmds:           1133  sizeofcmds:      232134  flags:           0x00002000135  reserved:        0x00000000136LoadCommands:137  - cmd:             LC_SEGMENT_64138    cmdsize:         232139    segname:         ''140    vmaddr:          0141    vmsize:          4142    fileoff:         392143    filesize:        4144    maxprot:         7145    initprot:        7146    nsects:          1147    flags:           0148    Sections:149      - sectname:        __data150        segname:         __DATA151        addr:            0x0000000000000000152        size:            4153        offset:          0x00000188154        align:           2155        reloff:          0x00000000156        nreloc:          0157        flags:           0x00000000158        reserved1:       0x00000000159        reserved2:       0x00000000160        reserved3:       0x00000000161        content:         AA162 163## Case 4: Don't validate if size is missing.164# RUN: not yaml2obj --docnum=4 %s -o %t1 2>&1 | FileCheck %s --check-prefix=CASE4 --implicit-check-not=error:165# CASE4: error: missing required key 'size'166# CASE4: error: failed to parse YAML167 168--- !mach-o169FileHeader:170  magic:           0xFEEDFACF171  cputype:         0x01000007172  cpusubtype:      0x00000003173  filetype:        0x00000001174  ncmds:           1175  sizeofcmds:      232176  flags:           0x00002000177  reserved:        0x00000000178LoadCommands:179  - cmd:             LC_SEGMENT_64180    cmdsize:         232181    segname:         ''182    vmaddr:          0183    vmsize:          4184    fileoff:         392185    filesize:        4186    maxprot:         7187    initprot:        7188    nsects:          1189    flags:           0190    Sections:191      - sectname:        __data192        segname:         __DATA193        addr:            0x0000000000000000194        content:         AA195        offset:          0x00000188196        align:           2197        reloff:          0x00000000198        nreloc:          0199        flags:           0x00000000200        reserved1:       0x00000000201        reserved2:       0x00000000202        reserved3:       0x00000000203