Fix PR18374 by making readelf and objdump ignore end-of-list markers in the .debug_loc section if there are relocations against them.
PR binutils/18374 bin * dwarf.h (struct dwarf_section): Add reloc_info and num_relocs fields. (struct dwarf_section_display): Change bitfield to boolean. (reloc_at): Add prototype. * dwarf.c (display_loc_list): Ignore list terminators if there are relocs against them. (display_debug_loc): Issue a warning if there are relocs against the .debug_loc section. (display_displays): Initialise reloc_info and num_relocs fields. * objdump.c (load_specific_debug_section): Initialise reloc_info and num_relocs fields. (reloc_at): New function. * readelf.c (is_32bit_abs_reloc): Add IA64's R_IA64_DIS32LSB reloc. (reloc_at): New function. (apply_relocations): Add relocs_return and num_relocs_return parameters. Fill them in with the loaded relocs if non-NULL. (dump_section_as_bytes): Update call to apply_relocations. (load_specific_debug_section): Initialise reloc_info and num_relocs fields. tests * binutils-all/pr18374.s: New test file. * binutils-all/readelf.exp: Assemble and run the new test. * binutils-all/readelf.pr18374: Expected output from readelf.
This commit is contained in:
parent
4bc0608a8b
commit
d1c4b12b9d
9 changed files with 492 additions and 86 deletions
|
@ -2278,6 +2278,8 @@ load_specific_debug_section (enum dwarf_section_display_enum debug,
|
|||
if (section->start != NULL)
|
||||
return 1;
|
||||
|
||||
section->reloc_info = NULL;
|
||||
section->num_relocs = 0;
|
||||
section->address = bfd_get_section_vma (abfd, sec);
|
||||
section->size = bfd_get_section_size (sec);
|
||||
section->start = NULL;
|
||||
|
@ -2308,11 +2310,49 @@ load_specific_debug_section (enum dwarf_section_display_enum debug,
|
|||
section->name);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
long reloc_size;
|
||||
|
||||
reloc_size = bfd_get_reloc_upper_bound (abfd, sec);
|
||||
if (reloc_size > 0)
|
||||
{
|
||||
unsigned long reloc_count;
|
||||
arelent **relocs;
|
||||
|
||||
relocs = (arelent **) xmalloc (reloc_size);
|
||||
|
||||
reloc_count = bfd_canonicalize_reloc (abfd, sec, relocs, NULL);
|
||||
if (reloc_count == 0)
|
||||
free (relocs);
|
||||
else
|
||||
{
|
||||
section->reloc_info = relocs;
|
||||
section->num_relocs = reloc_count;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
bfd_boolean
|
||||
reloc_at (struct dwarf_section * dsec, dwarf_vma offset)
|
||||
{
|
||||
arelent ** relocs;
|
||||
arelent * rp;
|
||||
|
||||
if (dsec == NULL || dsec->reloc_info == NULL)
|
||||
return FALSE;
|
||||
|
||||
relocs = (arelent **) dsec->reloc_info;
|
||||
|
||||
for (; (rp = * relocs) != NULL; ++ relocs)
|
||||
if (rp->address == offset)
|
||||
return TRUE;
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
int
|
||||
load_debug_section (enum dwarf_section_display_enum debug, void *file)
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue