| 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.o |
| 6 |
# RUN: llvm-readelf --string-dump=.debug_str %t1.o | FileCheck %s --check-prefix=DWARF-DEFAULT |
| 7 |
|
| 8 |
# DWARF-DEFAULT: String dump of section '.debug_str': |
| 9 |
# DWARF-DEFAULT-NEXT: [ 0] a |
| 10 |
# DWARF-DEFAULT-NEXT: [ 2] b |
| 11 |
# DWARF-DEFAULT-NEXT: [ 4] c |
| 12 |
|
| 13 |
## Check the default sh_type, sh_entsize, sh_info, sh_flags and sh_addralign of the |
| 14 |
## .debug_str section header. |
| 15 |
|
| 16 |
# RUN: llvm-readelf -S %t1.o | FileCheck -DSIZE=000006 %s --check-prefix=SHDRS-DEFAULT |
| 17 |
|
| 18 |
# SHDRS-DEFAULT: Name Type Address Off Size ES Flg Lk Inf Al |
| 19 |
# SHDRS-DEFAULT: .debug_str PROGBITS 0000000000000000 000040 [[SIZE]] 01 MS 0 0 1 |
| 20 |
|
| 21 |
--- !ELF |
| 22 |
FileHeader: |
| 23 |
Class: ELFCLASS64 |
| 24 |
Data: ELFDATA2LSB |
| 25 |
Type: ET_EXEC |
| 26 |
DWARF: |
| 27 |
debug_str: |
| 28 |
- a |
| 29 |
- b |
| 30 |
- c |
| 31 |
|
| 32 |
## b) Generate the .debug_str section from the raw section content. |
| 33 |
|
| 34 |
# RUN: yaml2obj --docnum=2 %s -o %t2.o |
| 35 |
# RUN: llvm-readelf --string-dump=.debug_str %t2.o | FileCheck %s --check-prefix=DWARF-DEFAULT |
| 36 |
# RUN: llvm-readelf -S %t2.o | FileCheck %s --check-prefix=SHDRS |
| 37 |
|
| 38 |
# SHDRS: Name Type Address Off Size ES Flg Lk Inf Al |
| 39 |
# SHDRS: .debug_str PROGBITS 0000000000000000 000040 000006 01 MS 0 0 0 |
| 40 |
|
| 41 |
--- !ELF |
| 42 |
FileHeader: |
| 43 |
Class: ELFCLASS64 |
| 44 |
Data: ELFDATA2LSB |
| 45 |
Type: ET_EXEC |
| 46 |
Sections: |
| 47 |
- Name: .debug_str |
| 48 |
Type: SHT_PROGBITS |
| 49 |
Content: "610062006300" |
| 50 |
|
| 51 |
## c) Generate the .debug_str section when the "Size" is specified. |
| 52 |
|
| 53 |
# RUN: yaml2obj --docnum=3 %s -o %t3.o |
| 54 |
# RUN: llvm-readelf -S %t3.o | FileCheck %s --check-prefix=SIZE |
| 55 |
# RUN: llvm-readelf --hex-dump=.debug_str %t3.o | FileCheck %s --check-prefix=SIZE-CONTENT |
| 56 |
|
| 57 |
# SIZE: Name Type Address Off Size ES Flg Lk Inf Al |
| 58 |
# SIZE: .debug_str PROGBITS 0000000000000000 000040 000010 01 MS 0 0 0 |
| 59 |
|
| 60 |
# SIZE-CONTENT: Hex dump of section '.debug_str': |
| 61 |
# SIZE-CONTENT-NEXT: 0x00000000 00000000 00000000 00000000 00000000 ................ |
| 62 |
# SIZE-CONTENT-EMPTY: |
| 63 |
|
| 64 |
--- !ELF |
| 65 |
FileHeader: |
| 66 |
Class: ELFCLASS64 |
| 67 |
Data: ELFDATA2LSB |
| 68 |
Type: ET_EXEC |
| 69 |
Sections: |
| 70 |
- Name: .debug_str |
| 71 |
Type: SHT_PROGBITS |
| 72 |
Size: 0x10 |
| 73 |
|
| 74 |
## d) Test that yaml2obj emits an error message when both the "Size" and the |
| 75 |
## "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=ERROR |
| 78 |
|
| 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 time |
| 80 |
|
| 81 |
--- !ELF |
| 82 |
FileHeader: |
| 83 |
Class: ELFCLASS64 |
| 84 |
Data: ELFDATA2LSB |
| 85 |
Type: ET_EXEC |
| 86 |
Sections: |
| 87 |
- Name: .debug_str |
| 88 |
Type: SHT_PROGBITS |
| 89 |
Size: 0x10 |
| 90 |
DWARF: |
| 91 |
debug_str: |
| 92 |
- a |
| 93 |
|
| 94 |
## e) Test that yaml2obj emits an error message when both the "Content" and the |
| 95 |
## "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=ERROR |
| 98 |
|
| 99 |
--- !ELF |
| 100 |
FileHeader: |
| 101 |
Class: ELFCLASS64 |
| 102 |
Data: ELFDATA2LSB |
| 103 |
Type: ET_EXEC |
| 104 |
Sections: |
| 105 |
- Name: .debug_str |
| 106 |
Type: SHT_PROGBITS |
| 107 |
Content: "6100" |
| 108 |
DWARF: |
| 109 |
debug_str: |
| 110 |
- a |
| 111 |
|
| 112 |
## f) Test that all the properties can be overridden by the section header when |
| 113 |
## the "debug_str" entry doesn't exist. |
| 114 |
|
| 115 |
# RUN: yaml2obj --docnum=6 %s -o %t6.o |
| 116 |
# RUN: llvm-readelf -S %t6.o | FileCheck %s --check-prefix=OVERRIDDEN |
| 117 |
|
| 118 |
# OVERRIDDEN: [Nr] Name Type Address Off Size ES Flg Lk Inf Al |
| 119 |
# OVERRIDDEN: [ 1] .sec STRTAB 0000000000000000 000040 000000 00 0 0 0 |
| 120 |
# OVERRIDDEN: [ 2] .debug_str STRTAB 0000000000002020 000050 000006 02 A 1 1 2 |
| 121 |
|
| 122 |
--- !ELF |
| 123 |
FileHeader: |
| 124 |
Class: ELFCLASS64 |
| 125 |
Data: ELFDATA2LSB |
| 126 |
Type: ET_EXEC |
| 127 |
Sections: |
| 128 |
- Name: .sec # Linked by .debug_str. |
| 129 |
Type: SHT_STRTAB |
| 130 |
- Name: .debug_str |
| 131 |
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 when |
| 142 |
## the "debug_str" entry is used. |
| 143 |
|
| 144 |
# RUN: yaml2obj --docnum=7 %s -o %t7.o |
| 145 |
# RUN: llvm-readelf --string-dump=.debug_str %t7.o | FileCheck %s --check-prefix=DWARF-DEFAULT |
| 146 |
# RUN: llvm-readelf -S %t7.o | FileCheck %s --check-prefix=OVERRIDDEN |
| 147 |
|
| 148 |
--- !ELF |
| 149 |
FileHeader: |
| 150 |
Class: ELFCLASS64 |
| 151 |
Data: ELFDATA2LSB |
| 152 |
Type: ET_EXEC |
| 153 |
Sections: |
| 154 |
- Name: .sec # Linked by .debug_str. |
| 155 |
Type: SHT_STRTAB |
| 156 |
- Name: .debug_str |
| 157 |
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. |
| 165 |
DWARF: |
| 166 |
debug_str: |
| 167 |
- a |
| 168 |
- b |
| 169 |
- c |
| 170 |
|
| 171 |
## h) Test that if we try to initialize the .debug_str section with a "Type" with non-standard |
| 172 |
## syntax, e.g., SHT_DYNAMIC, yaml2obj will treat it as a dynamic section and discard the |
| 173 |
## content in the "DWARF" entry. |
| 174 |
|
| 175 |
# RUN: yaml2obj --docnum=8 %s -o %t8.o |
| 176 |
# RUN: llvm-readelf -S %t8.o | FileCheck %s --check-prefix=DYN-SHDR |
| 177 |
# RUN: llvm-readelf -d %t8.o | FileCheck %s --check-prefix=DYNAMIC |
| 178 |
|
| 179 |
# RUN: yaml2obj --docnum=9 %s -o %t9.o |
| 180 |
# RUN: llvm-readelf -S %t9.o | FileCheck %s --check-prefix=DYN-SHDR |
| 181 |
# RUN: llvm-readelf -d %t9.o | FileCheck %s --check-prefix=DYNAMIC |
| 182 |
|
| 183 |
# DYN-SHDR: Name Type Address Off Size ES Flg Lk Inf Al |
| 184 |
# DYN-SHDR: .debug_str DYNAMIC 0000000000000000 000040 000010 10 0 0 0 |
| 185 |
|
| 186 |
# DYNAMIC: Dynamic section at offset 0x40 contains 1 entries: |
| 187 |
# DYNAMIC-NEXT: Tag Type Name/Value |
| 188 |
# DYNAMIC-NEXT: 0x0000000000000000 (NULL) 0x0 |
| 189 |
|
| 190 |
--- !ELF |
| 191 |
FileHeader: |
| 192 |
Class: ELFCLASS64 |
| 193 |
Data: ELFDATA2LSB |
| 194 |
Type: ET_EXEC |
| 195 |
Sections: |
| 196 |
- Name: .debug_str |
| 197 |
Type: SHT_DYNAMIC |
| 198 |
Entries: |
| 199 |
- Tag: DT_NULL |
| 200 |
Value: 0 |
| 201 |
|
| 202 |
--- !ELF |
| 203 |
FileHeader: |
| 204 |
Class: ELFCLASS64 |
| 205 |
Data: ELFDATA2LSB |
| 206 |
Type: ET_EXEC |
| 207 |
Sections: |
| 208 |
- Name: .debug_str |
| 209 |
Type: SHT_DYNAMIC |
| 210 |
Entries: |
| 211 |
- Tag: DT_NULL |
| 212 |
Value: 0 |
| 213 |
DWARF: |
| 214 |
debug_str: |
| 215 |
- a |
| 216 |
|
| 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.o |
| 221 |
# RUN: llvm-readelf -S %t10.o | FileCheck -DSIZE=000000 %s --check-prefix=SHDRS-DEFAULT |
| 222 |
|
| 223 |
--- !ELF |
| 224 |
FileHeader: |
| 225 |
Class: ELFCLASS64 |
| 226 |
Data: ELFDATA2LSB |
| 227 |
Type: ET_EXEC |
| 228 |
DWARF: |
| 229 |
debug_str: [] |