brintos

brintos / llvm-project-archived public Read only

0
0
Text · 7.0 KiB · 27d0aa6 Raw
230 lines · yaml
1## Test that yaml2obj emits .debug_str section.2 3## a) Generate the .debug_str section from the "DWARF" entry.4 5# RUN: yaml2obj --docnum=1 %s -o %t1.o6# RUN: llvm-readelf --string-dump=.debug_str %t1.o | FileCheck %s --check-prefix=DWARF-DEFAULT7 8#      DWARF-DEFAULT: String dump of section '.debug_str':9# DWARF-DEFAULT-NEXT: [     0] a10# DWARF-DEFAULT-NEXT: [     2] b11# DWARF-DEFAULT-NEXT: [     4] c12 13## Check the default sh_type, sh_entsize, sh_info, sh_flags and sh_addralign of the14## .debug_str section header.15 16# RUN: llvm-readelf -S %t1.o | FileCheck -DSIZE=000006 %s --check-prefix=SHDRS-DEFAULT17 18# SHDRS-DEFAULT: Name       Type     Address          Off    Size     ES Flg Lk Inf Al19# SHDRS-DEFAULT: .debug_str PROGBITS 0000000000000000 000040 [[SIZE]] 01 MS  0  0   120 21--- !ELF22FileHeader:23  Class: ELFCLASS6424  Data:  ELFDATA2LSB25  Type:  ET_EXEC26DWARF:27  debug_str:28    - a29    - b30    - c31 32## b) Generate the .debug_str section from the raw section content.33 34# RUN: yaml2obj --docnum=2 %s -o %t2.o35# RUN: llvm-readelf --string-dump=.debug_str %t2.o | FileCheck %s --check-prefix=DWARF-DEFAULT36# RUN: llvm-readelf -S %t2.o | FileCheck %s --check-prefix=SHDRS37 38# SHDRS: Name       Type     Address          Off    Size   ES Flg Lk Inf Al39# SHDRS: .debug_str PROGBITS 0000000000000000 000040 000006 01 MS  0  0   040 41--- !ELF42FileHeader:43  Class: ELFCLASS6444  Data:  ELFDATA2LSB45  Type:  ET_EXEC46Sections:47  - Name:    .debug_str48    Type:    SHT_PROGBITS49    Content: "610062006300"50 51## c) Generate the .debug_str section when the "Size" is specified.52 53# RUN: yaml2obj --docnum=3 %s -o %t3.o54# RUN: llvm-readelf -S %t3.o | FileCheck %s --check-prefix=SIZE55# RUN: llvm-readelf --hex-dump=.debug_str %t3.o | FileCheck %s --check-prefix=SIZE-CONTENT56 57# SIZE: Name       Type     Address          Off    Size   ES Flg Lk Inf Al58# SIZE: .debug_str PROGBITS 0000000000000000 000040 000010 01 MS  0  0   059 60#       SIZE-CONTENT: Hex dump of section '.debug_str':61#  SIZE-CONTENT-NEXT: 0x00000000 00000000 00000000 00000000 00000000 ................62# SIZE-CONTENT-EMPTY:63 64--- !ELF65FileHeader:66  Class: ELFCLASS6467  Data:  ELFDATA2LSB68  Type:  ET_EXEC69Sections:70  - Name:  .debug_str71    Type:  SHT_PROGBITS72    Size:  0x1073 74## d) Test that yaml2obj emits an error message when both the "Size" and the75## "debug_str" entry are specified at the same time.76 77# RUN: not yaml2obj --docnum=4 %s -o %t4.o 2>&1 | FileCheck %s --check-prefix=ERROR78 79# ERROR: yaml2obj: error: cannot specify section '.debug_str' contents in the 'DWARF' entry and the 'Content' or 'Size' in the 'Sections' entry at the same time80 81--- !ELF82FileHeader:83  Class: ELFCLASS6484  Data:  ELFDATA2LSB85  Type:  ET_EXEC86Sections:87  - Name:  .debug_str88    Type:  SHT_PROGBITS89    Size:  0x1090DWARF:91  debug_str:92    - a93 94## e) Test that yaml2obj emits an error message when both the "Content" and the95## "debug_str" entry are specified at the same time.96 97# RUN: not yaml2obj --docnum=5 %s -o %t5.o 2>&1 | FileCheck %s --check-prefix=ERROR98 99--- !ELF100FileHeader:101  Class: ELFCLASS64102  Data:  ELFDATA2LSB103  Type:  ET_EXEC104Sections:105  - Name:    .debug_str106    Type:    SHT_PROGBITS107    Content: "6100"108DWARF:109  debug_str:110    - a111 112## f) Test that all the properties can be overridden by the section header when113## the "debug_str" entry doesn't exist.114 115# RUN: yaml2obj --docnum=6 %s -o %t6.o116# RUN: llvm-readelf -S %t6.o | FileCheck %s --check-prefix=OVERRIDDEN117 118# OVERRIDDEN: [Nr]  Name       Type   Address          Off    Size   ES Flg Lk Inf Al119# OVERRIDDEN: [ 1]  .sec       STRTAB 0000000000000000 000040 000000 00     0  0   0120# OVERRIDDEN: [ 2]  .debug_str STRTAB 0000000000002020 000050 000006 02 A   1  1   2121 122--- !ELF123FileHeader:124  Class: ELFCLASS64125  Data:  ELFDATA2LSB126  Type:  ET_EXEC127Sections:128  - Name:         .sec               # Linked by .debug_str.129    Type:         SHT_STRTAB130  - Name:         .debug_str131    Type:         SHT_STRTAB         # SHT_PROGBITS by default.132    Flags:        [SHF_ALLOC]        # [SHF_STRINGS, SHF_MERGE] by default.133    Link:         .sec               # 0 by default.134    EntSize:      2                  # 1 by default.135    Info:         1                  # 0 by default.136    AddressAlign: 2                  # 0 by default.137    Address:      0x0000000000002020 # 0x00 by default.138    Offset:       0x00000050         # 0x40 for the first section.139    Size:         6                  # Set the "Size" so that we can reuse the check tag "OVERRIDDEN"140 141## g) Test that all the properties can be overridden by the section header when142## the "debug_str" entry is used.143 144# RUN: yaml2obj --docnum=7 %s -o %t7.o145# RUN: llvm-readelf --string-dump=.debug_str %t7.o | FileCheck %s --check-prefix=DWARF-DEFAULT146# RUN: llvm-readelf -S %t7.o | FileCheck %s --check-prefix=OVERRIDDEN147 148--- !ELF149FileHeader:150  Class: ELFCLASS64151  Data:  ELFDATA2LSB152  Type:  ET_EXEC153Sections:154  - Name:         .sec               # Linked by .debug_str.155    Type:         SHT_STRTAB156  - Name:         .debug_str157    Type:         SHT_STRTAB         # SHT_PROGBITS by default.158    Flags:        [SHF_ALLOC]        # [SHF_STRINGS, SHF_MERGE] by default.159    Link:         .sec               # 0 by default.160    EntSize:      2                  # 1 by default.161    Info:         1                  # 0 by default.162    AddressAlign: 2                  # 1 by default.163    Address:      0x0000000000002020 # 0x00 by default.164    Offset:       0x00000050         # 0x40 for the first section.165DWARF:166  debug_str:167    - a168    - b169    - c170 171## h) Test that if we try to initialize the .debug_str section with a "Type" with non-standard172## syntax, e.g., SHT_DYNAMIC, yaml2obj will treat it as a dynamic section and discard the173## content in the "DWARF" entry.174 175# RUN: yaml2obj --docnum=8 %s -o %t8.o176# RUN: llvm-readelf -S %t8.o | FileCheck %s --check-prefix=DYN-SHDR177# RUN: llvm-readelf -d %t8.o | FileCheck %s --check-prefix=DYNAMIC178 179# RUN: yaml2obj --docnum=9 %s -o %t9.o180# RUN: llvm-readelf -S %t9.o | FileCheck %s --check-prefix=DYN-SHDR181# RUN: llvm-readelf -d %t9.o | FileCheck %s --check-prefix=DYNAMIC182 183# DYN-SHDR: Name       Type    Address          Off    Size   ES Flg Lk Inf Al184# DYN-SHDR: .debug_str DYNAMIC 0000000000000000 000040 000010 10     0  0   0185 186#      DYNAMIC: Dynamic section at offset 0x40 contains 1 entries:187# DYNAMIC-NEXT:  Tag                Type   Name/Value188# DYNAMIC-NEXT:  0x0000000000000000 (NULL) 0x0189 190--- !ELF191FileHeader:192  Class: ELFCLASS64193  Data:  ELFDATA2LSB194  Type:  ET_EXEC195Sections:196  - Name: .debug_str197    Type: SHT_DYNAMIC198    Entries:199      - Tag:   DT_NULL200        Value: 0201 202--- !ELF203FileHeader:204  Class: ELFCLASS64205  Data:  ELFDATA2LSB206  Type:  ET_EXEC207Sections:208  - Name: .debug_str209    Type: SHT_DYNAMIC210    Entries:211      - Tag:   DT_NULL212        Value: 0213DWARF:214  debug_str:215    - a216 217## i) Test that the .debug_str section header is emitted if the "debug_str"218## entry is empty.219 220# RUN: yaml2obj --docnum=10 %s -o %t10.o221# RUN: llvm-readelf -S %t10.o | FileCheck -DSIZE=000000 %s --check-prefix=SHDRS-DEFAULT222 223--- !ELF224FileHeader:225  Class: ELFCLASS64226  Data:  ELFDATA2LSB227  Type:  ET_EXEC228DWARF:229  debug_str: []230