brintos

brintos / llvm-project-archived public Read only

0
0
Text · 13.3 KiB · 7e0e142 Raw
447 lines · plain
1## This test is based on a trimmed down version of the binary built as follows:2## a.c:3## __attribute__((used)) static int PrivateSymbol;4## __attribute__((visibility("hidden"))) int PrivateExternalSymbol;5## __attribute__((used)) int CommonSymbol;6## extern int UndefinedExternalSymbol;7## // Defined external symbol8## int main() {9##   return PrivateSymbol + PrivateExternalSymbol + CommonSymbol +10##          UndefinedExternalSymbol;11## }12## build command:13##   clang -g -fno-exceptions -fno-unwind-tables -undefined dynamic_lookup \14##   a.c -o a.exe15## All the load commands except the symbol table and its transitive dependencies16## have been removed.17 18# RUN: yaml2obj %s -o %t19# RUN: llvm-objcopy %t %t.copy20# RUN: cmp %t %t.copy21 22## Verify that the binary is valid and check its symbol table.23# RUN: llvm-readobj --symbols %t.copy | FileCheck %s24 25# CHECK: Symbols [26# CHECK-NEXT:   Symbol {27# CHECK-NEXT:     Name: _PrivateSymbol (170)28# CHECK-NEXT:     Type: Section (0xE)29# CHECK-NEXT:     Section: __bss (0x4)30# CHECK-NEXT:     RefType: UndefinedNonLazy (0x0)31# CHECK-NEXT:     Flags [ (0x0)32# CHECK-NEXT:     ]33# CHECK-NEXT:     Value: 0x10000100834# CHECK-NEXT:   }35# CHECK-NEXT:   Symbol {36# CHECK-NEXT:     Name: _PrivateExternalSymbol (122)37# CHECK-NEXT:     PrivateExtern38# CHECK-NEXT:     Type: Section (0xE)39# CHECK-NEXT:     Section: __common (0x5)40# CHECK-NEXT:     RefType: UndefinedNonLazy (0x0)41# CHECK-NEXT:     Flags [ (0x0)42# CHECK-NEXT:     ]43# CHECK-NEXT:     Value: 0x10000101044# CHECK-NEXT:   }45# CHECK-NEXT:   Symbol {46# CHECK-NEXT:     Name: /Users/aaaaaaaa/ (192)47# CHECK-NEXT:     Type: SymDebugTable (0x64)48# CHECK-NEXT:     Section:  (0x0)49# CHECK-NEXT:     RefType: UndefinedNonLazy (0x0)50# CHECK-NEXT:     Flags [ (0x0)51# CHECK-NEXT:     ]52# CHECK-NEXT:     Value: 0x053# CHECK-NEXT:   }54# CHECK-NEXT:   Symbol {55# CHECK-NEXT:     Name: main.c (185)56# CHECK-NEXT:     Type: SymDebugTable (0x64)57# CHECK-NEXT:     Section:  (0x0)58# CHECK-NEXT:     RefType: UndefinedNonLazy (0x0)59# CHECK-NEXT:     Flags [ (0x0)60# CHECK-NEXT:     ]61# CHECK-NEXT:     Value: 0x062# CHECK-NEXT:   }63# CHECK-NEXT:   Symbol {64# CHECK-NEXT:     Name: /var/folders/1d/zyfdpp7j2995h5hqspjy28bc0000gn/T/main-c5ac21.o (39)65# CHECK-NEXT:     Type: SymDebugTable (0x66)66# CHECK-NEXT:     Section:  (0x3)67# CHECK-NEXT:     RefType: ReferenceFlagUndefinedLazy (0x1)68# CHECK-NEXT:     Flags [ (0x0)69# CHECK-NEXT:     ]70# CHECK-NEXT:     Value: 0x5EA74C8171# CHECK-NEXT:   }72# CHECK-NEXT:   Symbol {73# CHECK-NEXT:     Name:  (208)74# CHECK-NEXT:     Type: SymDebugTable (0x2E)75# CHECK-NEXT:     Section:  (0x1)76# CHECK-NEXT:     RefType: UndefinedNonLazy (0x0)77# CHECK-NEXT:     Flags [ (0x0)78# CHECK-NEXT:     ]79# CHECK-NEXT:     Value: 0x100000F8080# CHECK-NEXT:   }81# CHECK-NEXT:   Symbol {82# CHECK-NEXT:     Name: _main (102)83# CHECK-NEXT:     Type: SymDebugTable (0x24)84# CHECK-NEXT:     Section:  (0x1)85# CHECK-NEXT:     RefType: UndefinedNonLazy (0x0)86# CHECK-NEXT:     Flags [ (0x0)87# CHECK-NEXT:     ]88# CHECK-NEXT:     Value: 0x100000F8089# CHECK-NEXT:   }90# CHECK-NEXT:   Symbol {91# CHECK-NEXT:     Name:  (208)92# CHECK-NEXT:     Type: SymDebugTable (0x24)93# CHECK-NEXT:     Section:  (0x0)94# CHECK-NEXT:     RefType: UndefinedNonLazy (0x0)95# CHECK-NEXT:     Flags [ (0x0)96# CHECK-NEXT:     ]97# CHECK-NEXT:     Value: 0x2D98# CHECK-NEXT:   }99# CHECK-NEXT:   Symbol {100# CHECK-NEXT:     Name:  (208)101# CHECK-NEXT:     Type: SymDebugTable (0x4E)102# CHECK-NEXT:     Section:  (0x1)103# CHECK-NEXT:     RefType: UndefinedNonLazy (0x0)104# CHECK-NEXT:     Flags [ (0x0)105# CHECK-NEXT:     ]106# CHECK-NEXT:     Value: 0x2D107# CHECK-NEXT:   }108# CHECK-NEXT:   Symbol {109# CHECK-NEXT:     Name: _PrivateSymbol (170)110# CHECK-NEXT:     Type: SymDebugTable (0x26)111# CHECK-NEXT:     Section:  (0x4)112# CHECK-NEXT:     RefType: UndefinedNonLazy (0x0)113# CHECK-NEXT:     Flags [ (0x0)114# CHECK-NEXT:     ]115# CHECK-NEXT:     Value: 0x100001008116# CHECK-NEXT:   }117# CHECK-NEXT:   Symbol {118# CHECK-NEXT:     Name: _CommonSymbol (108)119# CHECK-NEXT:     Type: SymDebugTable (0x20)120# CHECK-NEXT:     Section:  (0x0)121# CHECK-NEXT:     RefType: UndefinedNonLazy (0x0)122# CHECK-NEXT:     Flags [ (0x0)123# CHECK-NEXT:     ]124# CHECK-NEXT:     Value: 0x0125# CHECK-NEXT:   }126# CHECK-NEXT:   Symbol {127# CHECK-NEXT:     Name: _PrivateExternalSymbol (122)128# CHECK-NEXT:     Type: SymDebugTable (0x20)129# CHECK-NEXT:     Section:  (0x0)130# CHECK-NEXT:     RefType: UndefinedNonLazy (0x0)131# CHECK-NEXT:     Flags [ (0x0)132# CHECK-NEXT:     ]133# CHECK-NEXT:     Value: 0x0134# CHECK-NEXT:   }135# CHECK-NEXT:   Symbol {136# CHECK-NEXT:     Name:  (208)137# CHECK-NEXT:     Type: SymDebugTable (0x64)138# CHECK-NEXT:     Section:  (0x1)139# CHECK-NEXT:     RefType: UndefinedNonLazy (0x0)140# CHECK-NEXT:     Flags [ (0x0)141# CHECK-NEXT:     ]142# CHECK-NEXT:     Value: 0x0143# CHECK-NEXT:   }144# CHECK-NEXT:   Symbol {145# CHECK-NEXT:     Name: _CommonSymbol (108)146# CHECK-NEXT:     Extern147# CHECK-NEXT:     Type: Section (0xE)148# CHECK-NEXT:     Section: __common (0x5)149# CHECK-NEXT:     RefType: UndefinedNonLazy (0x0)150# CHECK-NEXT:     Flags [ (0x0)151# CHECK-NEXT:     ]152# CHECK-NEXT:     Value: 0x10000100C153# CHECK-NEXT:   }154# CHECK-NEXT:   Symbol {155# CHECK-NEXT:     Name: __mh_execute_header (19)156# CHECK-NEXT:     Extern157# CHECK-NEXT:     Type: Section (0xE)158# CHECK-NEXT:     Section: __text (0x1)159# CHECK-NEXT:     RefType: UndefinedNonLazy (0x0)160# CHECK-NEXT:     Flags [ (0x10)161# CHECK-NEXT:       ReferencedDynamically (0x10)162# CHECK-NEXT:     ]163# CHECK-NEXT:     Value: 0x100000000164# CHECK-NEXT:   }165# CHECK-NEXT:   Symbol {166# CHECK-NEXT:     Name: _main (102)167# CHECK-NEXT:     Extern168# CHECK-NEXT:     Type: Section (0xE)169# CHECK-NEXT:     Section: __text (0x1)170# CHECK-NEXT:     RefType: UndefinedNonLazy (0x0)171# CHECK-NEXT:     Flags [ (0x0)172# CHECK-NEXT:     ]173# CHECK-NEXT:     Value: 0x100000F80174# CHECK-NEXT:   }175# CHECK-NEXT:   Symbol {176# CHECK-NEXT:     Name: _UndefinedExternalSymbol (145)177# CHECK-NEXT:     Extern178# CHECK-NEXT:     Type: Undef (0x0)179# CHECK-NEXT:     Section:  (0x0)180# CHECK-NEXT:     RefType: UndefinedNonLazy (0x0)181# CHECK-NEXT:     Flags [ (0xFE00)182# CHECK-NEXT:       AltEntry (0x200)183# CHECK-NEXT:       ColdFunc (0x400)184# CHECK-NEXT:     ]185# CHECK-NEXT:     Value: 0x0186# CHECK-NEXT:   }187# CHECK-NEXT:   Symbol {188# CHECK-NEXT:     Name: dyld_stub_binder (2)189# CHECK-NEXT:     Extern190# CHECK-NEXT:     Type: Undef (0x0)191# CHECK-NEXT:     Section:  (0x0)192# CHECK-NEXT:     RefType: UndefinedNonLazy (0x0)193# CHECK-NEXT:     Flags [ (0x100)194# CHECK-NEXT:       SymbolResolver (0x100)195# CHECK-NEXT:     ]196# CHECK-NEXT:     Value: 0x0197# CHECK-NEXT:   }198# CHECK-NEXT: ]199 200--- !mach-o201FileHeader:202  magic:           0xFEEDFACF203  cputype:         0x01000007204  cpusubtype:      0x80000003205  filetype:        0x00000002206  ncmds:           5207  sizeofcmds:      720208  flags:           0x00200085209  reserved:        0x00000000210LoadCommands:211  - cmd:             LC_SEGMENT_64212    cmdsize:         232213    segname:         __TEXT214    vmaddr:          4294967296215    vmsize:          4096216    fileoff:         0217    filesize:        4096218    maxprot:         5219    initprot:        5220    nsects:          2221    flags:           0222    Sections:223      - sectname:        __text224        segname:         __TEXT225        addr:            0x0000000100000F80226        size:            45227        offset:          0x00000F80228        align:           4229        reloff:          0x00000000230        nreloc:          0231        flags:           0x80000400232        reserved1:       0x00000000233        reserved2:       0x00000000234        reserved3:       0x00000000235        content:         554889E5488B0575000000488D0D7A000000C745FC000000008B156900000003156B0000000311031089D05DC3236      - sectname:        __unwind_info237        segname:         __TEXT238        addr:            0x0000000100000FB0239        size:            72240        offset:          0x00000FB0241        align:           2242        reloff:          0x00000000243        nreloc:          0244        flags:           0x00000000245        reserved1:       0x00000000246        reserved2:       0x00000000247        reserved3:       0x00000000248        content:         010000001C000000000000001C000000000000001C00000002000000800F00003400000034000000AE0F00000000000034000000030000000C000100100001000000000000000000249  - cmd:             LC_SEGMENT_64250    cmdsize:         312251    segname:         __DATA252    vmaddr:          4294971392253    vmsize:          4096254    fileoff:         4096255    filesize:        4096256    maxprot:         3257    initprot:        3258    nsects:          3259    flags:           0260    Sections:261      - sectname:        __got262        segname:         __DATA263        addr:            0x0000000100001000264        size:            8265        offset:          0x00001000266        align:           3267        reloff:          0x00000000268        nreloc:          0269        flags:           0x00000006270        reserved1:       0x00000000271        reserved2:       0x00000000272        reserved3:       0x00000000273        content:         '0000000000000000'274      - sectname:        __bss275        segname:         __DATA276        addr:            0x0000000100001008277        size:            4278        offset:          0x00000000279        align:           2280        reloff:          0x00000000281        nreloc:          0282        flags:           0x00000001283        reserved1:       0x00000000284        reserved2:       0x00000000285        reserved3:       0x00000000286      - sectname:        __common287        segname:         __DATA288        addr:            0x000000010000100C289        size:            8290        offset:          0x00000000291        align:           2292        reloff:          0x00000000293        nreloc:          0294        flags:           0x00000001295        reserved1:       0x00000000296        reserved2:       0x00000000297        reserved3:       0x00000000298  - cmd:             LC_SEGMENT_64299    cmdsize:         72300    segname:         __LINKEDIT301    vmaddr:          4294975488302    vmsize:          4096303    fileoff:         8192304    filesize:        508305    maxprot:         1306    initprot:        1307    nsects:          0308    flags:           0309  - cmd:             LC_SYMTAB310    cmdsize:         24311    symoff:          8192312    nsyms:           18313    stroff:          8484314    strsize:         216315  - cmd:             LC_DYSYMTAB316    cmdsize:         80317    ilocalsym:       0318    nlocalsym:       13319    iextdefsym:      13320    nextdefsym:      3321    iundefsym:       16322    nundefsym:       2323    tocoff:          0324    ntoc:            0325    modtaboff:       0326    nmodtab:         0327    extrefsymoff:    0328    nextrefsyms:     0329    indirectsymoff:  8480330    nindirectsyms:   1331    extreloff:       0332    nextrel:         0333    locreloff:       0334    nlocrel:         0335LinkEditData:336  NameList:337    - n_strx:          170338      n_type:          0x0E339      n_sect:          4340      n_desc:          0341      n_value:         4294971400342    - n_strx:          122343      n_type:          0x1E344      n_sect:          5345      n_desc:          0346      n_value:         4294971408347    - n_strx:          192348      n_type:          0x64349      n_sect:          0350      n_desc:          0351      n_value:         0352    - n_strx:          185353      n_type:          0x64354      n_sect:          0355      n_desc:          0356      n_value:         0357    - n_strx:          39358      n_type:          0x66359      n_sect:          3360      n_desc:          1361      n_value:         1588022401362    - n_strx:          208363      n_type:          0x2E364      n_sect:          1365      n_desc:          0366      n_value:         4294971264367    - n_strx:          102368      n_type:          0x24369      n_sect:          1370      n_desc:          0371      n_value:         4294971264372    - n_strx:          208373      n_type:          0x24374      n_sect:          0375      n_desc:          0376      n_value:         45377    - n_strx:          208378      n_type:          0x4E379      n_sect:          1380      n_desc:          0381      n_value:         45382    - n_strx:          170383      n_type:          0x26384      n_sect:          4385      n_desc:          0386      n_value:         4294971400387    - n_strx:          108388      n_type:          0x20389      n_sect:          0390      n_desc:          0391      n_value:         0392    - n_strx:          122393      n_type:          0x20394      n_sect:          0395      n_desc:          0396      n_value:         0397    - n_strx:          208398      n_type:          0x64399      n_sect:          1400      n_desc:          0401      n_value:         0402    - n_strx:          108403      n_type:          0x0F404      n_sect:          5405      n_desc:          0406      n_value:         4294971404407    - n_strx:          19408      n_type:          0x0F409      n_sect:          1410      n_desc:          16411      n_value:         4294967296412    - n_strx:          102413      n_type:          0x0F414      n_sect:          1415      n_desc:          0416      n_value:         4294971264417    - n_strx:          145418      n_type:          0x01419      n_sect:          0420      n_desc:          65024421      n_value:         0422    - n_strx:          2423      n_type:          0x01424      n_sect:          0425      n_desc:          256426      n_value:         0427  StringTable:428    - ' '429    - dyld_stub_binder430    - __mh_execute_header431    - '/var/folders/1d/zyfdpp7j2995h5hqspjy28bc0000gn/T/main-c5ac21.o'432    - _main433    - _CommonSymbol434    - _PrivateExternalSymbol435    - _UndefinedExternalSymbol436    - _PrivateSymbol437    - main.c438    - '/Users/aaaaaaaa/'439    - ''440    - ''441    - ''442    - ''443    - ''444    - ''445    - ''446...447