brintos

brintos / llvm-project-archived public Read only

0
0
Text · 13.7 KiB · daea0dc Raw
448 lines · yaml
1## Show that the SectionHeaderStringTable field in the document header is set,2## iff the section name is not ".shstrtab".3## Also show that no section appears in the Sections table for this section,4## unless some property is different to the default.5 6## Show the case when the name is a custom string (the key should be set).7# RUN: yaml2obj --docnum=1 %s -o %t1.o8# RUN: obj2yaml %t1.o > %t1.yaml9# RUN: FileCheck %s --input-file=%t1.yaml --check-prefix=CUSTOM10 11# CUSTOM:      --- !ELF12# CUSTOM-NEXT: FileHeader:13# CUSTOM-NEXT:   Class:           ELFCLASS6414# CUSTOM-NEXT:   Data:            ELFDATA2LSB15# CUSTOM-NEXT:   Type:            ET_EXEC16# CUSTOM-NEXT:   SectionHeaderStringTable: .foo17# CUSTOM-NEXT: ...18 19--- !ELF20FileHeader:21  Class: ELFCLASS6422  Data:  ELFDATA2LSB23  Type:  ET_EXEC24  SectionHeaderStringTable: .foo25 26## Show the case when the e_shstrndx value is SHN_XINDEX and the name is not27## ".shstrtab" (the key should be set).28# RUN: yaml2obj --docnum=2 %s -o %t2.o29# RUN: obj2yaml %t2.o > %t2.yaml30# RUN: FileCheck %s --input-file=%t2.yaml --check-prefix=XINDEX31 32--- !ELF33FileHeader:34  Class:     ELFCLASS6435  Data:      ELFDATA2LSB36  Type:      ET_EXEC37  EShStrNdx: 0xffff38  SectionHeaderStringTable: .foo39Sections:40  - Type: SHT_NULL41    Link: .foo42 43# XINDEX:      --- !ELF44# XINDEX-NEXT: FileHeader:45# XINDEX-NEXT:   Class:           ELFCLASS6446# XINDEX-NEXT:   Data:            ELFDATA2LSB47# XINDEX-NEXT:   Type:            ET_EXEC48# XINDEX-NEXT:   SectionHeaderStringTable: .foo49# XINDEX-NEXT: Sections:50# XINDEX-NEXT:   - Type:            SHT_NULL51# XINDEX-NEXT:     Link:            .foo52# XINDEX-NEXT:     Size:            0x053# XINDEX-NEXT: ...54 55## Show the case when the string table section is also the symbol table's string56## table (the key should be set).57# RUN: yaml2obj --docnum=3 %s -o %t3.o58# RUN: obj2yaml %t3.o > %t3.yaml59# RUN: FileCheck %s --input-file=%t3.yaml --check-prefix=STRTAB60 61# STRTAB:      --- !ELF62# STRTAB-NEXT: FileHeader:63# STRTAB-NEXT:   Class:           ELFCLASS6464# STRTAB-NEXT:   Data:            ELFDATA2LSB65# STRTAB-NEXT:   Type:            ET_EXEC66# STRTAB-NEXT:   SectionHeaderStringTable: .strtab67# STRTAB-NEXT: Symbols:68# STRTAB-NEXT:   - Name:            boz69# STRTAB-NEXT: ...70 71--- !ELF72FileHeader:73  Class: ELFCLASS6474  Data:  ELFDATA2LSB75  Type:  ET_EXEC76  SectionHeaderStringTable: ".strtab"77Symbols:78  - Name: boz79 80## Document the case when the string table section is also the symbol table's81## dynamic string table (the key should be set).82## FIXME: Regardless of whether it is shared with the section header string83##        table or not, the dynstr (and also the dynsym) should be omitted if84##        they match the default behaviour.85# RUN: yaml2obj --docnum=4 %s -o %t4.o86# RUN: obj2yaml %t4.o > %t4.yaml87# RUN: FileCheck %s --input-file=%t4.yaml --check-prefix=DYNSTR88 89# DYNSTR:      --- !ELF90# DYNSTR-NEXT: FileHeader:91# DYNSTR-NEXT:   Class:           ELFCLASS6492# DYNSTR-NEXT:   Data:            ELFDATA2LSB93# DYNSTR-NEXT:   Type:            ET_EXEC94# DYNSTR-NEXT:   SectionHeaderStringTable: .dynstr95# DYNSTR-NEXT: Sections:96# DYNSTR-NEXT:   - Name:            .dynsym97# DYNSTR-NEXT:     Type:            SHT_DYNSYM98# DYNSTR-NEXT:     Flags:           [ SHF_ALLOC ]99# DYNSTR-NEXT:     Link:            .dynstr100# DYNSTR-NEXT:     AddressAlign:    0x8101# DYNSTR-NEXT:   - Name:            .dynstr102# DYNSTR-NEXT:     Type:            SHT_STRTAB103# DYNSTR-NEXT:     Flags:           [ SHF_ALLOC ]104# DYNSTR-NEXT:     Address:         0x30105# DYNSTR-NEXT:     AddressAlign:    0x1106# DYNSTR-NEXT: DynamicSymbols:107# DYNSTR-NEXT:   - Name:            boz108# DYNSTR-NEXT: ...109 110--- !ELF111FileHeader:112  Class: ELFCLASS64113  Data:  ELFDATA2LSB114  Type:  ET_EXEC115  SectionHeaderStringTable: ".dynstr"116DynamicSymbols:117  - Name: boz118 119## Show the case when the name is the default ".shstrtab" (the key should not be120## set).121# RUN: yaml2obj --docnum=5 %s -o %t5.o122# RUN: obj2yaml %t5.o > %t5.yaml123# RUN: FileCheck %s --input-file=%t5.yaml --check-prefix=DEFAULT124 125# DEFAULT:      --- !ELF126# DEFAULT-NEXT: FileHeader:127# DEFAULT-NEXT:   Class:           ELFCLASS64128# DEFAULT-NEXT:   Data:            ELFDATA2LSB129# DEFAULT-NEXT:   Type:            ET_EXEC130# DEFAULT-NEXT: ...131 132--- !ELF133FileHeader:134  Class: ELFCLASS64135  Data:  ELFDATA2LSB136  Type:  ET_EXEC137 138## Show the case when the e_shstrndx value is 0 and the name is ".shstrtab" (the139## key should not be set).140# RUN: yaml2obj --docnum=6 %s -o %t6.o141# RUN: obj2yaml %t6.o > %t6.yaml142# RUN: FileCheck %s --input-file=%t6.yaml --check-prefix=DEFXINDEX143 144--- !ELF145FileHeader:146  Class:     ELFCLASS64147  Data:      ELFDATA2LSB148  Type:      ET_EXEC149  EShStrNdx: 0xffff150Sections:151  - Type: SHT_NULL152    Link: .shstrtab153 154# DEFXINDEX:      --- !ELF155# DEFXINDEX-NEXT: FileHeader:156# DEFXINDEX-NEXT:   Class:           ELFCLASS64157# DEFXINDEX-NEXT:   Data:            ELFDATA2LSB158# DEFXINDEX-NEXT:   Type:            ET_EXEC159# DEFXINDEX-NEXT: Sections:160# DEFXINDEX-NEXT:   - Type:            SHT_NULL161# DEFXINDEX-NEXT:     Link:            .shstrtab162# DEFXINDEX-NEXT:     Size:            0x0163# DEFXINDEX-NEXT: ...164 165## Show that if there are no section headers, the key is not set.166# RUN: yaml2obj --docnum=7 %s -o %t7.o167# RUN: obj2yaml %t7.o > %t7.yaml168# RUN: FileCheck %s --input-file=%t7.yaml --check-prefix=NOHDRS169 170--- !ELF171FileHeader:172  Class: ELFCLASS64173  Data:  ELFDATA2LSB174  Type:  ET_EXEC175Sections:176  - Type: SectionHeaderTable177    NoHeaders: true178 179# NOHDRS:      --- !ELF180# NOHDRS-NEXT: FileHeader:181# NOHDRS-NEXT:   Class:  ELFCLASS64182# NOHDRS-NEXT:   Data:   ELFDATA2LSB183# NOHDRS-NEXT:   Type:   ET_EXEC184## FIXME: There should be a SectionHeaderTable key as per the input.185# NOHDRS-NEXT: ...186 187## Show that a custom-named section header string table can be in a reordered188## section header table.189# RUN: yaml2obj --docnum=8 %s -o %t8.o190# RUN: obj2yaml %t8.o > %t8.yaml191# RUN: FileCheck %s --input-file=%t8.yaml --check-prefix=REORDER192 193# REORDER:      --- !ELF194# REORDER-NEXT: FileHeader:195# REORDER-NEXT:   Class:           ELFCLASS64196# REORDER-NEXT:   Data:            ELFDATA2LSB197# REORDER-NEXT:   Type:            ET_EXEC198# REORDER-NEXT:   SectionHeaderStringTable: .foo199# REORDER-NEXT: Sections:200# REORDER-NEXT:   - Name:            .baz201# REORDER-NEXT:     Type:            SHT_PROGBITS202# REORDER-NEXT:     Offset:          0x180203# REORDER-NEXT:   - Name:            .bar204# REORDER-NEXT:     Type:            SHT_PROGBITS205## FIXME: This should be at the start of the sections list.206# REORDER-NEXT:   - Type:            SectionHeaderTable207# REORDER-NEXT:     Sections:208# REORDER-NEXT:       - Name:            .baz209# REORDER-NEXT:       - Name:            .foo210# REORDER-NEXT:       - Name:            .bar211# REORDER-NEXT:       - Name:            .strtab212# REORDER-NEXT: ...213 214--- !ELF215FileHeader:216  Class: ELFCLASS64217  Data:  ELFDATA2LSB218  Type:  ET_EXEC219  SectionHeaderStringTable: .foo220Sections:221  - Type: SectionHeaderTable222    Sections:223      - Name: .baz224      - Name: .foo225      - Name: .bar226      ## FIXME: we shouldn't need a .strtab section if there are no symbols.227      - Name: .strtab228  - Name: .baz229    Type: SHT_PROGBITS230  - Name: .bar231    Type: SHT_PROGBITS232 233## Document what happens when a custom-named section header string table is234## placed in between other sections.235## FIXME: obj2yaml should preserve the ordering in the Sections list, but it236##        doesn't for custom or default named tables.237# RUN: yaml2obj --docnum=9 %s -o %t9.o238# RUN: obj2yaml %t9.o > %t9.yaml239# RUN: FileCheck %s --input-file=%t9.yaml --check-prefix=PLACED240 241# PLACED:      --- !ELF242# PLACED-NEXT: FileHeader:243# PLACED-NEXT:   Class:           ELFCLASS64244# PLACED-NEXT:   Data:            ELFDATA2LSB245# PLACED-NEXT:   Type:            ET_EXEC246# PLACED-NEXT:   SectionHeaderStringTable: .foo247# PLACED-NEXT: Sections:248# PLACED-NEXT:   - Name:            .baz249# PLACED-NEXT:     Type:            SHT_PROGBITS250# PLACED-NEXT:   - Name:            .bar251# PLACED-NEXT:     Type:            SHT_PROGBITS252 253--- !ELF254FileHeader:255  Class: ELFCLASS64256  Data:  ELFDATA2LSB257  Type:  ET_EXEC258  SectionHeaderStringTable: .foo259Sections:260  - Name: .baz261    Type: SHT_PROGBITS262  - Name: .foo263    Type: SHT_STRTAB264  - Name: .bar265    Type: SHT_PROGBITS266 267## Show that a custom-named section header string table can be given different268## properties.269# RUN: yaml2obj --docnum=10 %s -o %t10.o270# RUN: obj2yaml %t10.o > %t10.yaml271# RUN: FileCheck %s --input-file=%t10.yaml --check-prefix=PROPS272 273# PROPS:      --- !ELF274# PROPS-NEXT: FileHeader:275# PROPS-NEXT:   Class: ELFCLASS64276# PROPS-NEXT:   Data:  ELFDATA2LSB277# PROPS-NEXT:   Type:  ET_EXEC278# PROPS-NEXT:   SectionHeaderStringTable: .foo279# PROPS-NEXT: Sections:280# PROPS-NEXT:   - Name:  .foo281# PROPS-NEXT:     Type:  SHT_STRTAB282# PROPS-NEXT:     Flags: [ SHF_ALLOC ]283# PROPS-NEXT: ...284 285--- !ELF286FileHeader:287  Class: ELFCLASS64288  Data:  ELFDATA2LSB289  Type:  ET_EXEC290  SectionHeaderStringTable: .foo291Sections:292  - Name:  .foo293    Type:  SHT_STRTAB294    Flags: [ SHF_ALLOC ]295 296## Show that an error is reported if the section header string table name cannot297## be read.298# RUN: yaml2obj --docnum=11 %s -o %t11.o299# RUNasda: not obj2yaml %t11.o 2>&1 | FileCheck %s --check-prefix=ERR -DFILE=%t11.o300 301# ERR: Error reading file: [[FILE]]: unable to read section header string table name: a section [index 1] has an invalid sh_name (0x10000) offset which goes past the end of the section name string table302 303--- !ELF304FileHeader:305  Class: ELFCLASS64306  Data:  ELFDATA2LSB307  Type:  ET_EXEC308Sections:309  - Name:  .shstrtab310    Type:  SHT_STRTAB311    ShName: 0x10000312 313## Show that the name is uniquified if necessary.314 315## Case 1: generic name.316# RUN: yaml2obj --docnum=12 %s -o %t12.o317# RUN: obj2yaml %t12.o > %t12.yaml318# RUN: FileCheck %s --input-file=%t12.yaml --check-prefix=UNIQUIFY1319 320# UNIQUIFY1:      --- !ELF321# UNIQUIFY1-NEXT: FileHeader:322# UNIQUIFY1-NEXT:   Class: ELFCLASS64323# UNIQUIFY1-NEXT:   Data:  ELFDATA2LSB324# UNIQUIFY1-NEXT:   Type:  ET_EXEC325# UNIQUIFY1-NEXT:   SectionHeaderStringTable: '.strings (1)'326# UNIQUIFY1-NEXT: Sections:327# UNIQUIFY1-NEXT:   - Name:  .strings328# UNIQUIFY1-NEXT:     Type:  SHT_PROGBITS329# UNIQUIFY1-NEXT: ...330 331--- !ELF332FileHeader:333  Class: ELFCLASS64334  Data:  ELFDATA2LSB335  Type:  ET_EXEC336  SectionHeaderStringTable: '.strings (1)'337Sections:338  - Name: '.strings (2)'339    Type: SHT_PROGBITS340 341## Case 2: '.strtab' when symbols are present.342# RUN: yaml2obj --docnum=13 %s -o %t13.o '-DNAME=".strtab (1)"'343# RUN: obj2yaml %t13.o > %t13.yaml344# RUN: FileCheck %s --input-file=%t13.yaml --check-prefix=UNIQUIFY2 \345# RUN:   -DNAME=.strtab346 347# UNIQUIFY2:      --- !ELF348# UNIQUIFY2-NEXT: FileHeader:349# UNIQUIFY2-NEXT:   Class: ELFCLASS64350# UNIQUIFY2-NEXT:   Data:  ELFDATA2LSB351# UNIQUIFY2-NEXT:   Type:  ET_EXEC352# UNIQUIFY2-NEXT:   SectionHeaderStringTable: '[[NAME]] (1)'353# UNIQUIFY2-NEXT: Symbols:354# UNIQUIFY2-NEXT:   - Name:  foo355# UNIQUIFY2-NEXT: ...356 357--- !ELF358FileHeader:359  Class: ELFCLASS64360  Data:  ELFDATA2LSB361  Type:  ET_EXEC362  SectionHeaderStringTable: [[NAME]]363Symbols:364  - Name: foo365 366## Case 3: '.symtab' when symbols are present.367# RUN: yaml2obj --docnum=13 %s -o %t14.o '-DNAME=".symtab (1)"'368# RUN: obj2yaml %t14.o > %t14.yaml369# RUN: FileCheck %s --input-file=%t14.yaml --check-prefix=UNIQUIFY2 \370# RUN:   -DNAME=.symtab371 372## Case 4: '.dynstr' when dynamic symbols are present.373# RUN: yaml2obj --docnum=14 %s -o %t15.o '-DNAME=".dynstr (1)"'374# RUN: obj2yaml %t15.o > %t15.yaml375# RUN: FileCheck %s --input-file=%t15.yaml --check-prefix=UNIQUIFY3 \376# RUN:   -DNAME=.dynstr377 378# UNIQUIFY3:      --- !ELF379# UNIQUIFY3-NEXT: FileHeader:380# UNIQUIFY3-NEXT:   Class: ELFCLASS64381# UNIQUIFY3-NEXT:   Data:  ELFDATA2LSB382# UNIQUIFY3-NEXT:   Type:  ET_EXEC383# UNIQUIFY3-NEXT:   SectionHeaderStringTable: '[[NAME]] (1)'384## FIXME: The .dynsym and .dynstr sections shouldn't need to be emitted, since385##        their values are the default produced by yaml2obj.386# UNIQUIFY3-NEXT: Sections:387# UNIQUIFY3-NEXT:   - Name:            .dynsym388# UNIQUIFY3-NEXT:     Type:            SHT_DYNSYM389# UNIQUIFY3-NEXT:     Flags:           [ SHF_ALLOC ]390# UNIQUIFY3-NEXT:     Link:            .dynstr391# UNIQUIFY3-NEXT:     AddressAlign:    0x8392# UNIQUIFY3-NEXT:   - Name:            .dynstr393# UNIQUIFY3-NEXT:     Type:            SHT_STRTAB394# UNIQUIFY3-NEXT:     Flags:           [ SHF_ALLOC ]395# UNIQUIFY3-NEXT:     Address:         0x30396# UNIQUIFY3-NEXT:     AddressAlign:    0x1397# UNIQUIFY3-NEXT: DynamicSymbols:398# UNIQUIFY3-NEXT:   - Name:  foo399# UNIQUIFY3-NEXT: ...400 401--- !ELF402FileHeader:403  Class: ELFCLASS64404  Data:  ELFDATA2LSB405  Type:  ET_EXEC406  SectionHeaderStringTable: [[NAME]]407DynamicSymbols:408  - Name: foo409 410## Case 5: '.dynsym' when dynamic symbols are present.411# RUN: yaml2obj --docnum=14 %s -o %t16.o '-DNAME=".dynsym (1)"'412# RUN: obj2yaml %t16.o > %t16.yaml413# RUN: FileCheck %s --input-file=%t16.yaml --check-prefix=UNIQUIFY3 \414# RUN:   -DNAME=.dynsym415 416## Case 6: Document what happens for '.debug_str' when DWARF debug strings are417##         requested. The dwarf2yaml code uses the last .debug_* named section418##         to populate the corresponding DWARF block. As a result, the original419##         .debug_str content is lost.420## TODO: We should prevent the dwarf2yaml code from using the section header421##       string table to populate the DWARF block.422# RUN: yaml2obj --docnum=15 %s -o %t17.o423# RUN: obj2yaml %t17.o > %t17.yaml424# RUN: FileCheck %s --input-file=%t17.yaml --check-prefix=UNIQUIFY6425 426# UNIQUIFY6:      --- !ELF427# UNIQUIFY6-NEXT: FileHeader:428# UNIQUIFY6-NEXT:   Class:           ELFCLASS64429# UNIQUIFY6-NEXT:   Data:            ELFDATA2LSB430# UNIQUIFY6-NEXT:   Type:            ET_EXEC431# UNIQUIFY6-NEXT:   SectionHeaderStringTable: '.debug_str (1)'432# UNIQUIFY6-NEXT: DWARF:433# UNIQUIFY6-NEXT:   debug_str:434# UNIQUIFY6-NEXT:     - ''435# UNIQUIFY6-NEXT:     - .debug_str436# UNIQUIFY6-NEXT:     - .strtab437# UNIQUIFY6-NEXT: ...438 439--- !ELF440FileHeader:441  Class: ELFCLASS64442  Data:  ELFDATA2LSB443  Type:  ET_EXEC444  SectionHeaderStringTable: '.debug_str (1)'445DWARF:446  debug_str:447    - string448