brintos

brintos / llvm-project-archived public Read only

0
0
Text · 8.6 KiB · 3c0309b Raw
249 lines · yaml
1## Test that yaml2obj emits .debug_gnu_pubnames section.2 3## a) Generate the '.debug_gnu_pubnames' section from the 'DWARF' entry.4 5## Generate and verify a 32-bit little endian .debug_gnu_pubnames section.6 7# RUN: yaml2obj --docnum=1 -DENDIAN=ELFDATA2LSB %s -o %t1.le.o8# RUN: llvm-readobj --sections --section-data %t1.le.o | \9# RUN:   FileCheck -DSIZE=32 -DADDRALIGN=1 %s --check-prefixes=SHDR,DWARF32-LE10 11#            SHDR: Index: 112#       SHDR-NEXT: Name: .debug_gnu_pubnames (1)13#       SHDR-NEXT: Type: SHT_PROGBITS (0x1)14#       SHDR-NEXT: Flags [ (0x0)15#       SHDR-NEXT: ]16#       SHDR-NEXT: Address: 0x017#       SHDR-NEXT: Offset: 0x4018#       SHDR-NEXT: Size: [[SIZE]]19#       SHDR-NEXT: Link: 020#       SHDR-NEXT: Info: 021#       SHDR-NEXT: AddressAlignment: [[ADDRALIGN]]22#       SHDR-NEXT: EntrySize: 023# DWARF32-LE-NEXT: SectionData (24# DWARF32-LE-NEXT:   0000: 34120000 02003412 00002143 00007856 |4.....4...!C..xV|25##                         ^-------                            unit_length (4-byte)26##                                  ^---                       version (2-byte)27##                                      ^--------              debug_info_offset (4-byte)28##                                               ^--------     debug_info_length (4-byte)29##                                                        ^--- offset (4-byte)30# DWARF32-LE-NEXT:   0010: 34123061 62630021 43658730 64656600 |4.0abc.!Ce.0def.|31##                         ----32##                             ^-                              descriptor (1-byte)33##                               ^--------                     name "abc\0"34##                                        ^--------            offset (4-byte)35##                                                 ^-          descriptor (1-byte)36##                                                    ^------- name "def\0"37# DWARF32-LE-NEXT: )38 39--- !ELF40FileHeader:41  Class: ELFCLASS6442  Data:  [[ENDIAN]]43  Type:  ET_EXEC44DWARF:45  debug_gnu_pubnames:46    Length:     0x123447    Version:    248    UnitOffset: 0x123449    UnitSize:   0x432150    Entries:51      - DieOffset:  0x1234567852        Descriptor: 0x3053        Name:       abc54      - DieOffset:  0x8765432155        Descriptor: 0x3056        Name:       def57 58## Generate and verify a 32-bit big endian .debug_gnu_pubnames section.59 60# RUN: yaml2obj --docnum=1 -DENDIAN=ELFDATA2MSB %s -o %t1.be.o61# RUN: llvm-readobj --sections --section-data %t1.be.o | \62# RUN:   FileCheck -DSIZE=32 -DADDRALIGN=1 %s --check-prefixes=SHDR,DWARF32-BE63 64# DWARF32-BE-NEXT: SectionData (65# DWARF32-BE-NEXT:   0000: 00001234 00020000 12340000 43211234 |...4.....4..C!.4|66##                         ^-------                            unit_length (4-byte)67##                                  ^---                       version (2-byte)68##                                      ^--------              debug_info_offset (4-byte)69##                                               ^--------     debug_info_length (4-byte)70##                                                        ^--- offset (4-byte)71# DWARF32-BE-NEXT:   0010: 56783061 62630087 65432130 64656600 |Vx0abc..eC!0def.|72##                         ----73##                             ^-                              descriptor (1-byte)74##                               ^--------                     name "abc\0"75##                                        ^--------            offset (4-byte)76##                                                 ^-          descriptor (1-byte)77##                                                    ^------- name "def\0"78# DWARF32-BE-NEXT: )79 80## b) Generate the .debug_gnu_pubnames section from raw section content.81 82# RUN: yaml2obj --docnum=2 %s -o %t2.o83# RUN: llvm-readobj --sections --section-data %t2.o | \84# RUN:   FileCheck %s -DADDRALIGN=0 -DSIZE=3 --check-prefixes=SHDR,ARBITRARY-CONTENT85 86#      ARBITRARY-CONTENT: SectionData (87# ARBITRARY-CONTENT-NEXT:   0000: 11223388# ARBITRARY-CONTENT-NEXT: )89 90--- !ELF91FileHeader:92  Class: ELFCLASS6493  Data:  ELFDATA2LSB94  Type:  ET_EXEC95Sections:96  - Name:    .debug_gnu_pubnames97    Type:    SHT_PROGBITS98    Content: "112233"99 100## c) Generate the .debug_gnu_pubnames section when the "Size" is specified.101 102# RUN: yaml2obj --docnum=3 %s -o %t3.o103# RUN: llvm-readobj --sections --section-data %t3.o | \104# RUN:   FileCheck -DSIZE=16 -DADDRALIGN=0 %s --check-prefixes=SHDR,SIZE105 106#      SIZE: SectionData (107# SIZE-NEXT:   0000: 00000000 00000000 00000000 00000000  |................|108# SIZE-NEXT: )109 110--- !ELF111FileHeader:112  Class: ELFCLASS64113  Data:  ELFDATA2LSB114  Type:  ET_EXEC115Sections:116  - Name: .debug_gnu_pubnames117    Type: SHT_PROGBITS118    Size: 0x10119 120## d) Test that yaml2obj emits an error message when both the "Size" and the121## "debug_gnu_pubnames" entry are specified at the same time.122 123# RUN: not yaml2obj --docnum=4 %s 2>&1 | FileCheck %s --check-prefix=ERROR124 125# ERROR: yaml2obj: error: cannot specify section '.debug_gnu_pubnames' contents in the 'DWARF' entry and the 'Content' or 'Size' in the 'Sections' entry at the same time126 127--- !ELF128FileHeader:129  Class: ELFCLASS64130  Data:  ELFDATA2LSB131  Type:  ET_EXEC132Sections:133  - Name: .debug_gnu_pubnames134    Type: SHT_PROGBITS135    Size: 0x10136DWARF:137  debug_gnu_pubnames:138    Length:     0x1234139    Version:    2140    UnitOffset: 0x1234141    UnitSize:   0x4321142    Entries:    []143 144## e) Test that yaml2obj emits an error message when both the "Content" and the145## "debug_gnu_pubnames" entry are specified at the same time.146 147# RUN: not yaml2obj --docnum=5 %s 2>&1 | FileCheck %s --check-prefix=ERROR148 149--- !ELF150FileHeader:151  Class: ELFCLASS64152  Data:  ELFDATA2LSB153  Type:  ET_EXEC154Sections:155  - Name:    .debug_gnu_pubnames156    Type:    SHT_PROGBITS157    Content: "00"158DWARF:159  debug_gnu_pubnames:160    Length:     0x1234161    Version:    2162    UnitOffset: 0x1234163    UnitSize:   0x4321164    Entries:    []165 166## f) Test that all the properties can be overridden by the section header when167## the "debug_gnu_pubnames" entry doesn't exist.168 169# RUN: yaml2obj --docnum=6 %s -o %t6.o170# RUN: llvm-readelf --sections %t6.o | FileCheck %s --check-prefix=OVERRIDDEN171 172#      OVERRIDDEN: [Nr] Name                Type   Address          Off    Size   ES Flg Lk Inf Al173#      OVERRIDDEN: [ 1] .debug_gnu_pubnames STRTAB 0000000000002020 000050 00000e 01   A  2   1  2174# OVERRIDDEN-NEXT: [ 2] .sec                STRTAB 0000000000000000 00005e 000000 00      0   0  0175 176--- !ELF177FileHeader:178  Class: ELFCLASS64179  Data:  ELFDATA2LSB180  Type:  ET_EXEC181Sections:182  - Name:         .debug_gnu_pubnames183    Type:         SHT_STRTAB  ## SHT_PROGBITS by default.184    Flags:        [SHF_ALLOC] ## 0 by default.185    Link:         .sec        ## 0 by default.186    EntSize:      1           ## 0 by default.187    Info:         1           ## 0 by default.188    AddressAlign: 2           ## 0 by default.189    Address:      0x2020      ## 0x00 by default.190    Offset:       0x50        ## 0x40 for the first section.191    Size:         0x0e        ## Set the "Size" so that we can reuse the check tag "OVERRIDDEN".192  - Name:         .sec        ## Linked by .debug_gnu_pubnames.193    Type:         SHT_STRTAB194 195## g) Test that all the properties can be overridden by the section header when196## the "debug_gnu_pubnames" entry exists.197 198# RUN: yaml2obj --docnum=7 %s -o %t7.o199# RUN: llvm-readelf --sections %t7.o | FileCheck %s --check-prefix=OVERRIDDEN200 201--- !ELF202FileHeader:203  Class: ELFCLASS64204  Data:  ELFDATA2LSB205  Type:  ET_EXEC206Sections:207  - Name:         .debug_gnu_pubnames208    Type:         SHT_STRTAB  ## SHT_PROGBITS by default.209    Flags:        [SHF_ALLOC] ## 0 by default.210    Link:         .sec        ## 0 by default.211    EntSize:      1           ## 0 by default.212    Info:         1           ## 0 by default.213    AddressAlign: 2           ## 1 by default.214    Address:      0x2020      ## 0x00 by default.215    Offset:       0x50        ## 0x40 for the first section.216  - Name:         .sec        ## Linked by .debug_gnu_pubnames.217    Type:         SHT_STRTAB218DWARF:219  debug_gnu_pubnames:220    Length:     0x1234221    Version:    2222    UnitOffset: 0x1234223    UnitSize:   0x4321224    Entries:    []225 226## h) Test that yaml2obj emits an error if 'Descriptor' is missing.227 228# RUN: not yaml2obj --docnum=8 %s -o %t8.o 2>&1 | FileCheck -DMSG=%errc_EINVAL %s --check-prefix=MISSING-KEY229 230#      MISSING-KEY: YAML:{{.*}}:9: error: missing required key 'Descriptor'231# MISSING-KEY-NEXT:       - DieOffset: 0x12345678232# MISSING-KEY-NEXT:         ^233# MISSING-KEY-NEXT: yaml2obj: error: failed to parse YAML input: [[MSG]]234 235--- !ELF236FileHeader:237  Class: ELFCLASS64238  Data:  ELFDATA2LSB239  Type:  ET_EXEC240DWARF:241  debug_gnu_pubnames:242    Length:     0x1234243    Version:    2244    UnitOffset: 0x1234245    UnitSize:   0x4321246    Entries:247      - DieOffset: 0x12345678248        Name:      abc249