| 1 |
# This test verifies that if a DW_TAG_compile_unit has DW_AT_ranges that |
| 2 |
# overlap, that it doesn't end up producing invalid errors claiming a child |
| 3 |
# DW_TAG_subprogram DIE is not in the parant (CU) ranges. Prior to the commit |
| 4 |
# that fixed this, a loop was iterating over all DW_AT_ranges for a DIE and |
| 5 |
# stopping the loop if any intersecting ranges were found. This would cause |
| 6 |
# the DW_TAG_subprogram DIEs, like "stripped2" and "main", to improperly report |
| 7 |
# that they were not contained in the parent's address ranges |
| 8 |
# |
| 9 |
# The DWARF looks like: |
| 10 |
# 0x0000000b: DW_TAG_compile_unit |
| 11 |
# DW_AT_name ("/tmp/main.c") |
| 12 |
# DW_AT_language (DW_LANG_C) |
| 13 |
# DW_AT_low_pc (0x0000000000000000) |
| 14 |
# DW_AT_ranges (0x00000000 |
| 15 |
# [0x0000000000002000, 0x0000000000003000) |
| 16 |
# [0x0000000000000000, 0x0000000000000020) |
| 17 |
# [0x0000000000000000, 0x0000000000000030) |
| 18 |
# [0x0000000000001000, 0x0000000000002000)) |
| 19 |
# |
| 20 |
# 0x0000001e: DW_TAG_subprogram |
| 21 |
# DW_AT_name ("stripped1") |
| 22 |
# DW_AT_low_pc (0x0000000000000000) |
| 23 |
# DW_AT_high_pc (0x0000000000000020) |
| 24 |
# |
| 25 |
# 0x0000002f: DW_TAG_subprogram |
| 26 |
# DW_AT_name ("stripped2") |
| 27 |
# DW_AT_low_pc (0x0000000000000000) |
| 28 |
# DW_AT_high_pc (0x0000000000000030) |
| 29 |
# |
| 30 |
# 0x00000044: DW_TAG_subprogram |
| 31 |
# DW_AT_name ("main") |
| 32 |
# DW_AT_low_pc (0x0000000000001000) |
| 33 |
# DW_AT_high_pc (0x0000000000002000) |
| 34 |
# |
| 35 |
# 0x00000055: DW_TAG_subprogram |
| 36 |
# DW_AT_name ("foo") |
| 37 |
# DW_AT_low_pc (0x0000000000002000) |
| 38 |
# DW_AT_high_pc (0x0000000000003000) |
| 39 |
# |
| 40 |
# 0x00000066: NULL |
| 41 |
|
| 42 |
# RUN: yaml2obj %s | not llvm-dwarfdump --error-display=details --verify - | FileCheck %s --implicit-check-not=error: |
| 43 |
|
| 44 |
# CHECK: error: DIE has overlapping ranges in DW_AT_ranges attribute: [0x0000000000000000, 0x0000000000000020) and [0x0000000000000000, 0x0000000000000030) |
| 45 |
|
| 46 |
# CHECK: 0x0000000b: DW_TAG_compile_unit |
| 47 |
# CHECK-NEXT: DW_AT_name [DW_FORM_strp] ( .debug_str[0x00000001] = "/tmp/main.c") |
| 48 |
# CHECK-NEXT: DW_AT_language [DW_FORM_data2] (DW_LANG_C) |
| 49 |
# CHECK-NEXT: DW_AT_low_pc [DW_FORM_addr] (0x0000000000000000) |
| 50 |
# CHECK-NEXT: DW_AT_ranges [DW_FORM_sec_offset] (0x00000000 |
| 51 |
# CHECK-NEXT: [0x0000000000002000, 0x0000000000003000) |
| 52 |
# CHECK-NEXT: [0x0000000000000000, 0x0000000000000020) |
| 53 |
# CHECK-NEXT: [0x0000000000000000, 0x0000000000000030) |
| 54 |
# CHECK-NEXT: [0x0000000000001000, 0x0000000000002000)) |
| 55 |
|
| 56 |
# CHECK: error: DIEs have overlapping address ranges: |
| 57 |
# CHECK: 0x0000002f: DW_TAG_subprogram |
| 58 |
# CHECK-NEXT: DW_AT_name [DW_FORM_strp] ( .debug_str[0x00000017] = "stripped2") |
| 59 |
# CHECK-NEXT: DW_AT_low_pc [DW_FORM_addr] (0x0000000000000000) |
| 60 |
# CHECK-NEXT: DW_AT_high_pc [DW_FORM_addr] (0x0000000000000030) |
| 61 |
|
| 62 |
# CHECK: 0x0000001e: DW_TAG_subprogram |
| 63 |
# CHECK-NEXT: DW_AT_name [DW_FORM_strp] ( .debug_str[0x0000000d] = "stripped1") |
| 64 |
# CHECK-NEXT: DW_AT_low_pc [DW_FORM_addr] (0x0000000000000000) |
| 65 |
# CHECK-NEXT: DW_AT_high_pc [DW_FORM_data4] (0x00000020) |
| 66 |
|
| 67 |
--- !mach-o |
| 68 |
FileHeader: |
| 69 |
magic: 0xFEEDFACF |
| 70 |
cputype: 0x01000007 |
| 71 |
cpusubtype: 0x00000003 |
| 72 |
filetype: 0x00000001 |
| 73 |
ncmds: 4 |
| 74 |
sizeofcmds: 464 |
| 75 |
flags: 0x00002000 |
| 76 |
reserved: 0x00000000 |
| 77 |
LoadCommands: |
| 78 |
- cmd: LC_SEGMENT_64 |
| 79 |
cmdsize: 392 |
| 80 |
segname: '' |
| 81 |
vmaddr: 0 |
| 82 |
vmsize: 261 |
| 83 |
fileoff: 528 |
| 84 |
filesize: 261 |
| 85 |
maxprot: 7 |
| 86 |
initprot: 7 |
| 87 |
nsects: 4 |
| 88 |
flags: 0 |
| 89 |
Sections: |
| 90 |
- sectname: __debug_abbrev |
| 91 |
segname: __DWARF |
| 92 |
addr: 0x0000000000000000 |
| 93 |
size: 36 |
| 94 |
offset: 0x00000210 |
| 95 |
align: 0 |
| 96 |
reloff: 0x00000000 |
| 97 |
nreloc: 0 |
| 98 |
flags: 0x00000000 |
| 99 |
reserved1: 0x00000000 |
| 100 |
reserved2: 0x00000000 |
| 101 |
reserved3: 0x00000000 |
| 102 |
- sectname: __debug_info |
| 103 |
segname: __DWARF |
| 104 |
addr: 0x0000000000000024 |
| 105 |
size: 103 |
| 106 |
offset: 0x00000234 |
| 107 |
align: 0 |
| 108 |
reloff: 0x00000000 |
| 109 |
nreloc: 0 |
| 110 |
flags: 0x00000000 |
| 111 |
reserved1: 0x00000000 |
| 112 |
reserved2: 0x00000000 |
| 113 |
reserved3: 0x00000000 |
| 114 |
- sectname: __debug_ranges |
| 115 |
segname: __DWARF |
| 116 |
addr: 0x000000000000008B |
| 117 |
size: 80 |
| 118 |
offset: 0x0000029B |
| 119 |
align: 0 |
| 120 |
reloff: 0x00000000 |
| 121 |
nreloc: 0 |
| 122 |
flags: 0x00000000 |
| 123 |
reserved1: 0x00000000 |
| 124 |
reserved2: 0x00000000 |
| 125 |
reserved3: 0x00000000 |
| 126 |
- sectname: __debug_str |
| 127 |
segname: __DWARF |
| 128 |
addr: 0x00000000000000DB |
| 129 |
size: 42 |
| 130 |
offset: 0x000002EB |
| 131 |
align: 0 |
| 132 |
reloff: 0x00000000 |
| 133 |
nreloc: 0 |
| 134 |
flags: 0x00000000 |
| 135 |
reserved1: 0x00000000 |
| 136 |
reserved2: 0x00000000 |
| 137 |
reserved3: 0x00000000 |
| 138 |
- cmd: LC_SYMTAB |
| 139 |
cmdsize: 24 |
| 140 |
symoff: 0 |
| 141 |
nsyms: 0 |
| 142 |
stroff: 792 |
| 143 |
strsize: 8 |
| 144 |
- cmd: LC_BUILD_VERSION |
| 145 |
cmdsize: 32 |
| 146 |
platform: 1 |
| 147 |
minos: 658944 |
| 148 |
sdk: 658944 |
| 149 |
ntools: 1 |
| 150 |
Tools: |
| 151 |
- tool: 3 |
| 152 |
version: 34734080 |
| 153 |
- cmd: LC_DATA_IN_CODE |
| 154 |
cmdsize: 16 |
| 155 |
dataoff: 792 |
| 156 |
datasize: 0 |
| 157 |
LinkEditData: |
| 158 |
StringTable: |
| 159 |
- ' ' |
| 160 |
- '' |
| 161 |
- '' |
| 162 |
- '' |
| 163 |
- '' |
| 164 |
- '' |
| 165 |
- '' |
| 166 |
DWARF: |
| 167 |
debug_str: |
| 168 |
- '' |
| 169 |
- '/tmp/main.c' |
| 170 |
- stripped1 |
| 171 |
- stripped2 |
| 172 |
- main |
| 173 |
- foo |
| 174 |
debug_abbrev: |
| 175 |
- Table: |
| 176 |
- Code: 0x00000001 |
| 177 |
Tag: DW_TAG_compile_unit |
| 178 |
Children: DW_CHILDREN_yes |
| 179 |
Attributes: |
| 180 |
- Attribute: DW_AT_name |
| 181 |
Form: DW_FORM_strp |
| 182 |
- Attribute: DW_AT_language |
| 183 |
Form: DW_FORM_data2 |
| 184 |
- Attribute: DW_AT_low_pc |
| 185 |
Form: DW_FORM_addr |
| 186 |
- Attribute: DW_AT_ranges |
| 187 |
Form: DW_FORM_sec_offset |
| 188 |
- Code: 0x00000002 |
| 189 |
Tag: DW_TAG_subprogram |
| 190 |
Children: DW_CHILDREN_no |
| 191 |
Attributes: |
| 192 |
- Attribute: DW_AT_name |
| 193 |
Form: DW_FORM_strp |
| 194 |
- Attribute: DW_AT_low_pc |
| 195 |
Form: DW_FORM_addr |
| 196 |
- Attribute: DW_AT_high_pc |
| 197 |
Form: DW_FORM_data4 |
| 198 |
- Code: 0x00000003 |
| 199 |
Tag: DW_TAG_subprogram |
| 200 |
Children: DW_CHILDREN_no |
| 201 |
Attributes: |
| 202 |
- Attribute: DW_AT_name |
| 203 |
Form: DW_FORM_strp |
| 204 |
- Attribute: DW_AT_low_pc |
| 205 |
Form: DW_FORM_addr |
| 206 |
- Attribute: DW_AT_high_pc |
| 207 |
Form: DW_FORM_addr |
| 208 |
debug_ranges: |
| 209 |
- Offset: 0x00000000 |
| 210 |
AddrSize: 0x08 |
| 211 |
Entries: |
| 212 |
- LowOffset: 0x0000000000002000 |
| 213 |
HighOffset: 0x0000000000003000 |
| 214 |
- LowOffset: 0x0000000000000000 |
| 215 |
HighOffset: 0x0000000000000020 |
| 216 |
- LowOffset: 0x0000000000000000 |
| 217 |
HighOffset: 0x0000000000000030 |
| 218 |
- LowOffset: 0x0000000000001000 |
| 219 |
HighOffset: 0x0000000000002000 |
| 220 |
debug_info: |
| 221 |
- Version: 4 |
| 222 |
AddrSize: 8 |
| 223 |
Entries: |
| 224 |
- AbbrCode: 0x00000001 |
| 225 |
Values: |
| 226 |
- Value: 0x0000000000000001 |
| 227 |
- Value: 0x0000000000000002 |
| 228 |
- Value: 0x0000000000000000 |
| 229 |
- Value: 0x0000000000000000 |
| 230 |
- AbbrCode: 0x00000002 |
| 231 |
Values: |
| 232 |
- Value: 0x000000000000000D |
| 233 |
- Value: 0x0000000000000000 |
| 234 |
- Value: 0x0000000000000020 |
| 235 |
- AbbrCode: 0x00000003 |
| 236 |
Values: |
| 237 |
- Value: 0x0000000000000017 |
| 238 |
- Value: 0x0000000000000000 |
| 239 |
- Value: 0x0000000000000030 |
| 240 |
- AbbrCode: 0x00000002 |
| 241 |
Values: |
| 242 |
- Value: 0x0000000000000021 |
| 243 |
- Value: 0x0000000000001000 |
| 244 |
- Value: 0x0000000000001000 |
| 245 |
- AbbrCode: 0x00000002 |
| 246 |
Values: |
| 247 |
- Value: 0x0000000000000026 |
| 248 |
- Value: 0x0000000000002000 |
| 249 |
- Value: 0x0000000000001000 |
| 250 |
- AbbrCode: 0x00000000 |
| 251 |
... |