Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* [patch] Fix a buglet in elfread.c
@ 2009-04-30 16:48 Paul Pluzhnikov
  2009-04-30 17:05 ` Joel Brobecker
  2009-04-30 21:54 ` Joel Brobecker
  0 siblings, 2 replies; 5+ messages in thread
From: Paul Pluzhnikov @ 2009-04-30 16:48 UTC (permalink / raw)
  To: gdb-patches; +Cc: Frank Middleton

Greetings,

GDB appears to make unwarranted assumptions about presence of .data,
.rodata in and ELF image.

In http://sourceware.org/ml/gdb/2009-04/msg00228.html you can see an image
on Solaris which has .rodata, but no .data, and this causes

  elfread.c:366: internal-error: sect_index_data not initialized

when using /usr/lib/libXau.so.6 from Solaris snv103 (SunOS 5.11) for SPARC.

Attached patch fixes that.

OK?

--
Paul Pluzhnikov

2009-04-30  Paul Pluzhnikov  <ppluzhnikov@google.com>

	* elfread.c (elf_symtab_read): Don't assume .data and .rodata
	are present.


Index: elfread.c
===================================================================
RCS file: /cvs/src/src/gdb/elfread.c,v
retrieving revision 1.76
diff -u -p -u -r1.76 elfread.c
--- elfread.c	3 Jan 2009 05:57:51 -0000	1.76
+++ elfread.c	30 Apr 2009 15:03:41 -0000
@@ -427,10 +427,11 @@ elf_symtab_read (struct objfile *objfile
 			  int max_index;
 			  size_t size;
 
-			  max_index 
-			    = max (SECT_OFF_BSS (objfile),
-				   max (SECT_OFF_DATA (objfile),
-					SECT_OFF_RODATA (objfile)));
+			  max_index = SECT_OFF_BSS (objfile);
+			  if (objfile->sect_index_data > max_index)
+			    max_index = objfile->sect_index_data;
+			  if (objfile->sect_index_rodata > max_index)
+			    max_index = objfile->sect_index_rodata;
 
 			  /* max_index is the largest index we'll
 			     use into this array, so we must


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [patch] Fix a buglet in elfread.c
  2009-04-30 16:48 [patch] Fix a buglet in elfread.c Paul Pluzhnikov
@ 2009-04-30 17:05 ` Joel Brobecker
  2009-04-30 21:54 ` Joel Brobecker
  1 sibling, 0 replies; 5+ messages in thread
From: Joel Brobecker @ 2009-04-30 17:05 UTC (permalink / raw)
  To: Paul Pluzhnikov; +Cc: gdb-patches, Frank Middleton

> 2009-04-30  Paul Pluzhnikov  <ppluzhnikov@google.com>
> 
> 	* elfread.c (elf_symtab_read): Don't assume .data and .rodata
> 	are present.

I remember facing this exact same type of issue on Tru64. I haven't
had a chance to look at the patch yet, but I'll try to get to it soon.
I also want to test it on x86 & sparc solaris.

(although, theoretically, it should be sufficient to test it on
a system using ELF such as GNU/Linux)

-- 
Joel


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [patch] Fix a buglet in elfread.c
  2009-04-30 16:48 [patch] Fix a buglet in elfread.c Paul Pluzhnikov
  2009-04-30 17:05 ` Joel Brobecker
@ 2009-04-30 21:54 ` Joel Brobecker
  2009-04-30 22:00   ` Paul Pluzhnikov
  2009-05-01  0:07   ` Frank Middleton
  1 sibling, 2 replies; 5+ messages in thread
From: Joel Brobecker @ 2009-04-30 21:54 UTC (permalink / raw)
  To: Paul Pluzhnikov; +Cc: gdb-patches, Frank Middleton

> 2009-04-30  Paul Pluzhnikov  <ppluzhnikov@google.com>
> 
> 	* elfread.c (elf_symtab_read): Don't assume .data and .rodata
> 	are present.

Looks good to me. Please go ahead and apply.

I tested this patch on sparc-solaris 2.8 with -gstabs+, since this
seems to be related to stabs. I don't think we can really test
this part of the code with a GCC compiler, but perhaps it's is
still exercised throught the loading of some of the Solaris shared
libraries.  We did our best, and we had 2 pairs of eyes looking at it,
so it should be fine.

-- 
Joel


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [patch] Fix a buglet in elfread.c
  2009-04-30 21:54 ` Joel Brobecker
@ 2009-04-30 22:00   ` Paul Pluzhnikov
  2009-05-01  0:07   ` Frank Middleton
  1 sibling, 0 replies; 5+ messages in thread
From: Paul Pluzhnikov @ 2009-04-30 22:00 UTC (permalink / raw)
  To: Joel Brobecker; +Cc: gdb-patches, Frank Middleton

On Thu, Apr 30, 2009 at 2:54 PM, Joel Brobecker <brobecker@adacore.com> wrote:

> Looks good to me. Please go ahead and apply.

Thanks. So committed.
-- 
Paul Pluzhnikov


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [patch] Fix a buglet in elfread.c
  2009-04-30 21:54 ` Joel Brobecker
  2009-04-30 22:00   ` Paul Pluzhnikov
@ 2009-05-01  0:07   ` Frank Middleton
  1 sibling, 0 replies; 5+ messages in thread
From: Frank Middleton @ 2009-05-01  0:07 UTC (permalink / raw)
  To: Joel Brobecker; +Cc: Paul Pluzhnikov, gdb-patches

On 04/30/09 17:54, Joel Brobecker wrote:
>> 2009-04-30  Paul Pluzhnikov<ppluzhnikov@google.com>
>>
>> 	* elfread.c (elf_symtab_read): Don't assume .data and .rodata
>> 	are present.
>
> Looks good to me. Please go ahead and apply.
>
> I tested this patch on sparc-solaris 2.8 with -gstabs+, since this
> seems to be related to stabs. I don't think we can really test
> this part of the code with a GCC compiler, but perhaps it's is
> still exercised throught the loading of some of the Solaris shared
> libraries.  We did our best, and we had 2 pairs of eyes looking at it,
> so it should be fine.

FWIW this wasn't a problem until at or after Solaris 10 (SunOS 5.10),
so your testing would presumably show that this patch didn't break
anything. I've been using the patched version all day on SunOS 5.11
(snv103) and it seems to be working perfectly, so it doesn't seem
like anything got broken and it certainly seems fixed. Thanks again!



^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2009-05-01  0:07 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-04-30 16:48 [patch] Fix a buglet in elfread.c Paul Pluzhnikov
2009-04-30 17:05 ` Joel Brobecker
2009-04-30 21:54 ` Joel Brobecker
2009-04-30 22:00   ` Paul Pluzhnikov
2009-05-01  0:07   ` Frank Middleton

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox