This is the mail archive of the
binutils@sources.redhat.com
mailing list for the binutils project.
Patch for readelf (readelf -u dumps core)
- To: Bharadwaj Yadavalli <bharadwaj dot yadavalli at compaq dot com>
- Subject: Patch for readelf (readelf -u dumps core)
- From: "H . J . Lu" <hjl at lucon dot org>
- Date: Wed, 28 Mar 2001 15:48:33 -0800
- Cc: binutils at sourceware dot cygnus dot com
- References: <20010328144344.A22625@lucon.org> <200103282312.SAA01149@ives.lkg.dec.com>
On Wed, Mar 28, 2001 at 06:12:22PM -0500, Bharadwaj Yadavalli wrote:
> new readelf. I am attaching a gdb trace hoping that you'll
> see the problem more quickly than I. Ofcourse I'll be poking
> in to see if I can educate myself.
>
> Thanks for the help.
>
> Bharadwaj
>
> PS : Is ia64 unwinding and Alpha unwinding being handled
> in the same way? Just wondering....
>
> ---------------------------------------------------
>
> % gdb /home/utils/binutils-2.11.90.0.1/binutils/readelf
> GNU gdb 5.0
> Copyright 2000 Free Software Foundation, Inc.
> GDB is free software, covered by the GNU General Public License, and you are
> welcome to change it and/or distribute copies of it under certain conditions.
> Type "show copying" to see the conditions.
> There is absolutely no warranty for GDB. Type "show warranty" for details.
> This GDB was configured as "alpha-redhat-linux"...
> (gdb) set args -u java/tst
> (gdb) b process_unwind
> Breakpoint 1 at 0x12000de3c: file readelf.c, line 3411.
> (gdb) r
> Starting program: /home/utils/binutils-2.11.90.0.1/binutils/readelf -u java/tst
>
> Breakpoint 1, process_unwind (file=0x11ffff808) at readelf.c:3411
> 3411 memset (& aux, 0, sizeof (aux));
> (gdb) n
> 3406 {
> (gdb)
> 3411 memset (& aux, 0, sizeof (aux));
> (gdb) c
> Continuing.
>
> Unwind section '.mdebug' at offset 0x988 contains 6819 entries:
>
> <>: [0x5100001992-0x400000000), info at +0xc2
>
> Program received signal SIGSEGV, Segmentation fault.
> byte_get_little_endian (field=0xc2 <Address 0xc2 out of bounds>, size=-8) at readelf.c:403
> 403 | (((bfd_vma) (field [7])) << 56);
> (gdb) info stack
> #0 byte_get_little_endian (field=0xc2 <Address 0xc2 out of bounds>, size=-8) at readelf.c:403
> #1 0x12000d550 in dump_ia64_unwind (aux=0x11ffff6a0) at readelf.c:3226
> #2 0x12000e23c in process_unwind (file=0x120043200) at readelf.c:3456
> #3 0x12001e39c in process_file (file_name=0x1200415c0 ";\004 \001") at readelf.c:8392
> #4 0x12001e56c in main (argc=3, argv=0x11ffff808) at readelf.c:8477
> #5 0x20000259d44 in __libc_start_main (main=0x12001e4a0 <main>, argc=3, ubp_av=0x11ffff808,
> init=0x1200013f0 <_init>, fini=0x2000011d598 <_dl_debug_impcalls>, rtld_fini=0,
> stack_end=0x11ffff7f0) at ../sysdeps/generic/libc-start.c:111
> (gdb)
I believe unwind sections are for IA64 only. Here is a patch.
H.J.
---
2001-03-28 H.J. Lu <hjl@gnu.org>
* readelf.c (process_unwind): Only do unwind sections for
IA64.
Index: readelf.c
===================================================================
RCS file: /work/cvs/gnu/binutils/binutils/readelf.c,v
retrieving revision 1.52
diff -u -p -r1.52 readelf.c
--- readelf.c 2001/03/17 20:47:58 1.52
+++ readelf.c 2001/03/28 23:41:46
@@ -3411,6 +3411,12 @@ process_unwind (file)
unsigned long i, addr_size;
struct unw_aux_info aux;
+ if (elf_header.e_machine != EM_IA_64)
+ {
+ printf (_("\nThere are no unwind sections in this file.\n"));
+ return 1;
+ }
+
memset (& aux, 0, sizeof (aux));
addr_size = is_32bit_elf ? 4 : 8;