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:
Nick Clifton 2015-05-15 11:21:38 +01:00
parent 4bc0608a8b
commit d1c4b12b9d
9 changed files with 492 additions and 86 deletions

View file

@ -124,6 +124,11 @@ struct dwarf_section
dwarf_vma address;
dwarf_size_type size;
enum dwarf_section_display_enum abbrev_sec;
/* Used by clients to help them implement the reloc_at callback. */
void * reloc_info;
unsigned long num_relocs;
/* A spare field for random use. */
void *user_data;
};
@ -135,7 +140,7 @@ struct dwarf_section_display
struct dwarf_section section;
int (*display) (struct dwarf_section *, void *);
int *enabled;
unsigned int relocate : 1;
bfd_boolean relocate;
};
extern struct dwarf_section_display debug_displays [];
@ -217,3 +222,8 @@ extern void * xcmalloc (size_t, size_t);
extern void * xcrealloc (void *, size_t, size_t);
extern dwarf_vma read_leb128 (unsigned char *, unsigned int *, bfd_boolean, const unsigned char * const);
/* A callback into the client. Retuns TRUE if there is a
relocation against the given debug section at the given
offset. */
extern bfd_boolean reloc_at (struct dwarf_section *, dwarf_vma);