summaryrefslogtreecommitdiffstats
path: root/libdw
diff options
context:
space:
mode:
Diffstat (limited to 'libdw')
-rw-r--r--libdw/ChangeLog5
-rw-r--r--libdw/dwarf_begin_elf.c32
2 files changed, 31 insertions, 6 deletions
diff --git a/libdw/ChangeLog b/libdw/ChangeLog
index b5462ef4..78a6bd39 100644
--- a/libdw/ChangeLog
+++ b/libdw/ChangeLog
@@ -1,3 +1,8 @@
12021-09-08 Mark Wielaard <mark@klomp.org>
2
3 * dwarf_begin_elf.c (valid_p): Identify ELF class and use this to set
4 address_size of the fake CUs. Also set offset_size and DWARF version.
5
12021-04-19 Martin Liska <mliska@suse.cz> 62021-04-19 Martin Liska <mliska@suse.cz>
2 7
3 * dwarf_begin_elf.c (check_section): Use startswith. 8 * dwarf_begin_elf.c (check_section): Use startswith.
diff --git a/libdw/dwarf_begin_elf.c b/libdw/dwarf_begin_elf.c
index 9e944b86..a368feb8 100644
--- a/libdw/dwarf_begin_elf.c
+++ b/libdw/dwarf_begin_elf.c
@@ -224,6 +224,23 @@ valid_p (Dwarf *result)
224 result = NULL; 224 result = NULL;
225 } 225 }
226 226
227 /* We are setting up some "fake" CUs, which need an address size.
228 Check the ELF class to come up with something reasonable. */
229 int elf_addr_size = 8;
230 if (result != NULL)
231 {
232 GElf_Ehdr ehdr;
233 if (gelf_getehdr (result->elf, &ehdr) == NULL)
234 {
235 Dwarf_Sig8_Hash_free (&result->sig8_hash);
236 __libdw_seterrno (DWARF_E_INVALID_ELF);
237 free (result);
238 result = NULL;
239 }
240 else if (ehdr.e_ident[EI_CLASS] == ELFCLASS32)
241 elf_addr_size = 4;
242 }
243
227 /* For dwarf_location_attr () we need a "fake" CU to indicate 244 /* For dwarf_location_attr () we need a "fake" CU to indicate
228 where the "fake" attribute data comes from. This is a block 245 where the "fake" attribute data comes from. This is a block
229 inside the .debug_loc or .debug_loclists section. */ 246 inside the .debug_loc or .debug_loclists section. */
@@ -247,8 +264,9 @@ valid_p (Dwarf *result)
247 = (result->sectiondata[IDX_debug_loc]->d_buf 264 = (result->sectiondata[IDX_debug_loc]->d_buf
248 + result->sectiondata[IDX_debug_loc]->d_size); 265 + result->sectiondata[IDX_debug_loc]->d_size);
249 result->fake_loc_cu->locs = NULL; 266 result->fake_loc_cu->locs = NULL;
250 result->fake_loc_cu->address_size = 0; 267 result->fake_loc_cu->address_size = elf_addr_size;
251 result->fake_loc_cu->version = 0; 268 result->fake_loc_cu->offset_size = 4;
269 result->fake_loc_cu->version = 4;
252 result->fake_loc_cu->split = NULL; 270 result->fake_loc_cu->split = NULL;
253 } 271 }
254 } 272 }
@@ -274,8 +292,9 @@ valid_p (Dwarf *result)
274 = (result->sectiondata[IDX_debug_loclists]->d_buf 292 = (result->sectiondata[IDX_debug_loclists]->d_buf
275 + result->sectiondata[IDX_debug_loclists]->d_size); 293 + result->sectiondata[IDX_debug_loclists]->d_size);
276 result->fake_loclists_cu->locs = NULL; 294 result->fake_loclists_cu->locs = NULL;
277 result->fake_loclists_cu->address_size = 0; 295 result->fake_loclists_cu->address_size = elf_addr_size;
278 result->fake_loclists_cu->version = 0; 296 result->fake_loclists_cu->offset_size = 4;
297 result->fake_loclists_cu->version = 5;
279 result->fake_loclists_cu->split = NULL; 298 result->fake_loclists_cu->split = NULL;
280 } 299 }
281 } 300 }
@@ -306,8 +325,9 @@ valid_p (Dwarf *result)
306 = (result->sectiondata[IDX_debug_addr]->d_buf 325 = (result->sectiondata[IDX_debug_addr]->d_buf
307 + result->sectiondata[IDX_debug_addr]->d_size); 326 + result->sectiondata[IDX_debug_addr]->d_size);
308 result->fake_addr_cu->locs = NULL; 327 result->fake_addr_cu->locs = NULL;
309 result->fake_addr_cu->address_size = 0; 328 result->fake_addr_cu->address_size = elf_addr_size;
310 result->fake_addr_cu->version = 0; 329 result->fake_addr_cu->offset_size = 4;
330 result->fake_addr_cu->version = 5;
311 result->fake_addr_cu->split = NULL; 331 result->fake_addr_cu->split = NULL;
312 } 332 }
313 } 333 }