Bug 13219 - readelf segmentation fault in apply_relocations
Summary: readelf segmentation fault in apply_relocations
Status: RESOLVED FIXED
Alias: None
Product: binutils
Classification: Unclassified
Component: binutils (show other bugs)
Version: 2.21
: P2 normal
Target Milestone: ---
Assignee: unassigned
URL:
Keywords:
: 13220 (view as bug list)
Depends on:
Blocks:
 
Reported: 2011-09-23 12:01 UTC by Paul Marinescu
Modified: 2011-10-13 09:39 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Last reconfirmed:


Attachments
reproduce the bug via zest -w readelf-zest-segv.o (692 bytes, application/octet-stream)
2011-09-23 12:01 UTC, Paul Marinescu
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Paul Marinescu 2011-09-23 12:01:27 UTC
Created attachment 5942 [details]
reproduce the bug via zest -w readelf-zest-segv.o

readelf -w <file> crashes with a segmentation fault at readelf.c:10140 on my machine with a particular file (attached). readelf -a shows a bad symbol in the .rel.debug_info section.

I would expect to get the same 'bad symbol' output in the -w output instead of the crash.

Paul
Comment 1 Sourceware Commits 2011-10-13 09:33:08 UTC
CVSROOT:	/cvs/src
Module name:	src
Changes by:	nickc@sourceware.org	2011-10-13 09:33:02

Modified files:
	binutils       : ChangeLog readelf.c 

Log message:
	PR binutils/13219
	* readelf.c (GET_ELF_SYMBOLS): Add sym_count parameter.
	(get_32bit_elf_symbols): Add num_syms_return argument.
	Return the number of symbols loaded into the symbol table.
	(get_64bit_elf_symbols): Likewise.
	(process_section_headers): Use GET_ELF_SYMBOLS to initialise
	symbol count.
	(proces_relocs): Likewise.
	(ia64_process_unwind): Likewise.
	(hppa_process_unwind): Likewise.
	(arm_process_unwind): Likewise.
	(process_dynamic_section): Likewise.
	(process_version_sections): Likewise.
	(process_symbol_table): Likewise.
	(process_section_groups): Likewise.
	Add check before indexing into the symbol table.
	(apply_relocations): Likewise.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/src/binutils/ChangeLog.diff?cvsroot=src&r1=1.1839&r2=1.1840
http://sourceware.org/cgi-bin/cvsweb.cgi/src/binutils/readelf.c.diff?cvsroot=src&r1=1.556&r2=1.557
Comment 2 Nick Clifton 2011-10-13 09:34:34 UTC
Hi Paul,

  Thanks for reporting this problem and supplying a test case.

  I have now checked in a patch that fixes readelf so that it will skip the broken relocation and continue to display the rest of the debugging information.

Cheers
  Nick
Comment 3 Nick Clifton 2011-10-13 09:39:48 UTC
*** Bug 13220 has been marked as a duplicate of this bug. ***