* [PING] Deal with intermixed 32-bit and 64-bit DWARF sections]
@ 2005-01-16 19:47 Mark Kettenis
2005-01-25 21:07 ` [PING PING] " Mark Kettenis
0 siblings, 1 reply; 5+ messages in thread
From: Mark Kettenis @ 2005-01-16 19:47 UTC (permalink / raw)
To: ezannoni, gdb-patches
[ Elena, I never saw a reaction of you on this. Could you please
review it? ]
Date: Wed, 10 Nov 2004 22:28:46 +0100 (CET)
From: Mark Kettenis <kettenis@gnu.org>
Currently GDB crashes hard when we encounter both 32-bit anbd 64-bit
DWARF sections within the same compilation unit. Keeping the mantra
"Be liberal what you accept, but complain loudly", this patch fixes
that.
Mark
Index: ChangeLog
from Mark Kettenis <kettenis@gnu.org>
* dwarf2read.c (dwarf2_build_psymtabs_easy): Initailize initial
length size of compilation header to zero.
(dwarf2_build_psymtabs_hard): Adjust info_ptr before building
psymtabs for included files.
(create_all_comp_units): Initailize initial length size of
compilation header to zero.
(read_initial_length): Complain if both 32-bit and 64-bit DWARF
sections are encountered within the same compilation header.
(dwarf_decode_line_header): Pass compilation header in call to
read_initial_length.
Index: dwarf2read.c
===================================================================
RCS file: /cvs/src/src/gdb/dwarf2read.c,v
retrieving revision 1.169
diff -u -p -r1.169 dwarf2read.c
- --- dwarf2read.c 10 Nov 2004 20:40:33 -0000 1.169
+++ dwarf2read.c 10 Nov 2004 21:19:41 -0000
@@ -1243,6 +1243,7 @@ dwarf2_build_psymtabs_easy (struct objfi
struct comp_unit_head cu_header;
int bytes_read;
+ cu_header.initial_length_size = 0;
entry_length = read_initial_length (abfd, pubnames_ptr, &cu_header,
&bytes_read);
pubnames_ptr += bytes_read;
@@ -1269,6 +1270,7 @@ read_comp_unit_head (struct comp_unit_he
{
int signed_addr;
int bytes_read;
+
cu_header->length = read_initial_length (abfd, info_ptr, cu_header,
&bytes_read);
info_ptr += bytes_read;
@@ -1533,6 +1535,9 @@ dwarf2_build_psymtabs_hard (struct objfi
also happen.) This happens in VxWorks. */
free_named_symtabs (pst->filename);
+ info_ptr = beg_of_comp_unit + cu.header.length
+ + cu.header.initial_length_size;
+
if (comp_unit_die.has_stmt_list)
{
/* Get the list of files included in the current compilation unit,
@@ -1540,9 +1545,6 @@ dwarf2_build_psymtabs_hard (struct objfi
dwarf2_build_include_psymtabs (&cu, &comp_unit_die, pst);
}
- - info_ptr = beg_of_comp_unit + cu.header.length
- - + cu.header.initial_length_size;
- -
do_cleanups (back_to_inner);
}
do_cleanups (back_to);
@@ -1632,6 +1634,7 @@ create_all_comp_units (struct objfile *o
/* Read just enough information to find out where the next
compilation unit is. */
+ cu_header.initial_length_size = 0;
cu_header.length = read_initial_length (objfile->obfd, info_ptr,
&cu_header, &bytes_read);
@@ -5850,7 +5853,7 @@ read_address (bfd *abfd, char *buf, stru
As a side effect, this function sets the fields initial_length_size
and offset_size in cu_header to the values appropriate for the
length field. (The format of the initial length field determines
- - the width of file offsets to be fetched later with fetch_offset().)
+ the width of file offsets to be fetched later with read_offset().)
[ Note: read_initial_length() and read_offset() are based on the
document entitled "DWARF Debugging Information Format", revision
@@ -5872,43 +5875,41 @@ static LONGEST
read_initial_length (bfd *abfd, char *buf, struct comp_unit_head *cu_header,
int *bytes_read)
{
- - LONGEST retval = 0;
- -
- - retval = bfd_get_32 (abfd, (bfd_byte *) buf);
+ LONGEST length = bfd_get_32 (abfd, (bfd_byte *) buf);
- - if (retval == 0xffffffff)
+ if (length == 0xffffffff)
{
- - retval = bfd_get_64 (abfd, (bfd_byte *) buf + 4);
+ length = bfd_get_64 (abfd, (bfd_byte *) buf + 4);
*bytes_read = 12;
- - if (cu_header != NULL)
- - {
- - cu_header->initial_length_size = 12;
- - cu_header->offset_size = 8;
- - }
}
- - else if (retval == 0)
+ else if (length == 0)
{
- - /* Handle (non-standard) 64-bit DWARF2 formats such as that used
- - by IRIX. */
- - retval = bfd_get_64 (abfd, (bfd_byte *) buf);
+ /* Handle the (non-standard) 64-bit DWARF2 format used by IRIX. */
+ length = bfd_get_64 (abfd, (bfd_byte *) buf);
*bytes_read = 8;
- - if (cu_header != NULL)
- - {
- - cu_header->initial_length_size = 8;
- - cu_header->offset_size = 8;
- - }
}
else
{
*bytes_read = 4;
- - if (cu_header != NULL)
- - {
- - cu_header->initial_length_size = 4;
- - cu_header->offset_size = 4;
- - }
}
- - return retval;
+ if (cu_header)
+ {
+ gdb_assert (cu_header->initial_length_size == 0
+ || cu_header->initial_length_size == 4
+ || cu_header->initial_length_size == 8
+ || cu_header->initial_length_size == 12);
+
+ if (cu_header->initial_length_size != 0
+ && cu_header->initial_length_size != *bytes_read)
+ complaint (&symfile_complaints,
+ "intermixed 32-bit and 64-bit DWARF sections");
+
+ cu_header->initial_length_size = *bytes_read;
+ cu_header->offset_size = (*bytes_read == 4) ? 4 : 8;
+ }
+
+ return length;
}
/* Read an offset from the data stream. The size of the offset is
@@ -6286,7 +6287,8 @@ dwarf_decode_line_header (unsigned int o
line_ptr = dwarf2_per_objfile->line_buffer + offset;
/* Read in the header. */
- - lh->total_length = read_initial_length (abfd, line_ptr, NULL, &bytes_read);
+ lh->total_length =
+ read_initial_length (abfd, line_ptr, &cu->header, &bytes_read);
line_ptr += bytes_read;
if (line_ptr + lh->total_length > (dwarf2_per_objfile->line_buffer
+ dwarf2_per_objfile->line_size))
------- End of forwarded message -------
^ permalink raw reply [flat|nested] 5+ messages in thread* [PING PING] Deal with intermixed 32-bit and 64-bit DWARF sections]
2005-01-16 19:47 [PING] Deal with intermixed 32-bit and 64-bit DWARF sections] Mark Kettenis
@ 2005-01-25 21:07 ` Mark Kettenis
2005-02-24 20:35 ` Daniel Jacobowitz
0 siblings, 1 reply; 5+ messages in thread
From: Mark Kettenis @ 2005-01-25 21:07 UTC (permalink / raw)
To: ezannoni, gdb-patches
[ Second ping ]
[ Elena, I never saw a reaction of you on this. Could you please
review it? ]
Date: Wed, 10 Nov 2004 22:28:46 +0100 (CET)
From: Mark Kettenis <kettenis@gnu.org>
Currently GDB crashes hard when we encounter both 32-bit anbd 64-bit
DWARF sections within the same compilation unit. Keeping the mantra
"Be liberal what you accept, but complain loudly", this patch fixes
that.
Mark
Index: ChangeLog
from Mark Kettenis <kettenis@gnu.org>
* dwarf2read.c (dwarf2_build_psymtabs_easy): Initailize initial
length size of compilation header to zero.
(dwarf2_build_psymtabs_hard): Adjust info_ptr before building
psymtabs for included files.
(create_all_comp_units): Initailize initial length size of
compilation header to zero.
(read_initial_length): Complain if both 32-bit and 64-bit DWARF
sections are encountered within the same compilation header.
(dwarf_decode_line_header): Pass compilation header in call to
read_initial_length.
Index: dwarf2read.c
===================================================================
RCS file: /cvs/src/src/gdb/dwarf2read.c,v
retrieving revision 1.169
diff -u -p -r1.169 dwarf2read.c
- --- dwarf2read.c 10 Nov 2004 20:40:33 -0000 1.169
+++ dwarf2read.c 10 Nov 2004 21:19:41 -0000
@@ -1243,6 +1243,7 @@ dwarf2_build_psymtabs_easy (struct objfi
struct comp_unit_head cu_header;
int bytes_read;
+ cu_header.initial_length_size = 0;
entry_length = read_initial_length (abfd, pubnames_ptr, &cu_header,
&bytes_read);
pubnames_ptr += bytes_read;
@@ -1269,6 +1270,7 @@ read_comp_unit_head (struct comp_unit_he
{
int signed_addr;
int bytes_read;
+
cu_header->length = read_initial_length (abfd, info_ptr, cu_header,
&bytes_read);
info_ptr += bytes_read;
@@ -1533,6 +1535,9 @@ dwarf2_build_psymtabs_hard (struct objfi
also happen.) This happens in VxWorks. */
free_named_symtabs (pst->filename);
+ info_ptr = beg_of_comp_unit + cu.header.length
+ + cu.header.initial_length_size;
+
if (comp_unit_die.has_stmt_list)
{
/* Get the list of files included in the current compilation unit,
@@ -1540,9 +1545,6 @@ dwarf2_build_psymtabs_hard (struct objfi
dwarf2_build_include_psymtabs (&cu, &comp_unit_die, pst);
}
- info_ptr = beg_of_comp_unit + cu.header.length
- + cu.header.initial_length_size;
-
do_cleanups (back_to_inner);
}
do_cleanups (back_to);
@@ -1632,6 +1634,7 @@ create_all_comp_units (struct objfile *o
/* Read just enough information to find out where the next
compilation unit is. */
+ cu_header.initial_length_size = 0;
cu_header.length = read_initial_length (objfile->obfd, info_ptr,
&cu_header, &bytes_read);
@@ -5850,7 +5853,7 @@ read_address (bfd *abfd, char *buf, stru
As a side effect, this function sets the fields initial_length_size
and offset_size in cu_header to the values appropriate for the
length field. (The format of the initial length field determines
- the width of file offsets to be fetched later with fetch_offset().)
+ the width of file offsets to be fetched later with read_offset().)
[ Note: read_initial_length() and read_offset() are based on the
document entitled "DWARF Debugging Information Format", revision
@@ -5872,43 +5875,41 @@ static LONGEST
read_initial_length (bfd *abfd, char *buf, struct comp_unit_head *cu_header,
int *bytes_read)
{
- LONGEST retval = 0;
-
- retval = bfd_get_32 (abfd, (bfd_byte *) buf);
+ LONGEST length = bfd_get_32 (abfd, (bfd_byte *) buf);
- if (retval == 0xffffffff)
+ if (length == 0xffffffff)
{
- retval = bfd_get_64 (abfd, (bfd_byte *) buf + 4);
+ length = bfd_get_64 (abfd, (bfd_byte *) buf + 4);
*bytes_read = 12;
- if (cu_header != NULL)
- {
- cu_header->initial_length_size = 12;
- cu_header->offset_size = 8;
- }
}
- else if (retval == 0)
+ else if (length == 0)
{
- /* Handle (non-standard) 64-bit DWARF2 formats such as that used
- by IRIX. */
- retval = bfd_get_64 (abfd, (bfd_byte *) buf);
+ /* Handle the (non-standard) 64-bit DWARF2 format used by IRIX. */
+ length = bfd_get_64 (abfd, (bfd_byte *) buf);
*bytes_read = 8;
- if (cu_header != NULL)
- {
- cu_header->initial_length_size = 8;
- cu_header->offset_size = 8;
- }
}
else
{
*bytes_read = 4;
- if (cu_header != NULL)
- {
- cu_header->initial_length_size = 4;
- cu_header->offset_size = 4;
- }
}
- return retval;
+ if (cu_header)
+ {
+ gdb_assert (cu_header->initial_length_size == 0
+ || cu_header->initial_length_size == 4
+ || cu_header->initial_length_size == 8
+ || cu_header->initial_length_size == 12);
+
+ if (cu_header->initial_length_size != 0
+ && cu_header->initial_length_size != *bytes_read)
+ complaint (&symfile_complaints,
+ "intermixed 32-bit and 64-bit DWARF sections");
+
+ cu_header->initial_length_size = *bytes_read;
+ cu_header->offset_size = (*bytes_read == 4) ? 4 : 8;
+ }
+
+ return length;
}
/* Read an offset from the data stream. The size of the offset is
@@ -6286,7 +6287,8 @@ dwarf_decode_line_header (unsigned int o
line_ptr = dwarf2_per_objfile->line_buffer + offset;
/* Read in the header. */
- lh->total_length = read_initial_length (abfd, line_ptr, NULL, &bytes_read);
+ lh->total_length =
+ read_initial_length (abfd, line_ptr, &cu->header, &bytes_read);
line_ptr += bytes_read;
if (line_ptr + lh->total_length > (dwarf2_per_objfile->line_buffer
+ dwarf2_per_objfile->line_size))
^ permalink raw reply [flat|nested] 5+ messages in thread* Re: [PING PING] Deal with intermixed 32-bit and 64-bit DWARF sections]
2005-01-25 21:07 ` [PING PING] " Mark Kettenis
@ 2005-02-24 20:35 ` Daniel Jacobowitz
[not found] ` <7320016418918119@weblx058.utsp.utwente.nl>
0 siblings, 1 reply; 5+ messages in thread
From: Daniel Jacobowitz @ 2005-02-24 20:35 UTC (permalink / raw)
To: Mark Kettenis; +Cc: ezannoni, gdb-patches
On Tue, Jan 25, 2005 at 10:06:53PM +0100, Mark Kettenis wrote:
> [ Second ping ]
>
> [ Elena, I never saw a reaction of you on this. Could you please
> review it? ]
>
> Date: Wed, 10 Nov 2004 22:28:46 +0100 (CET)
> From: Mark Kettenis <kettenis@gnu.org>
>
> Currently GDB crashes hard when we encounter both 32-bit anbd 64-bit
> DWARF sections within the same compilation unit. Keeping the mantra
> "Be liberal what you accept, but complain loudly", this patch fixes
> that.
Mark,
Did you mean to check in the test case without the fix? Not only does
it fail, it divides by zero, triggering the "infinite SIGFPE" bug
elsewhere reported in our bug database, and adding about ten minutes to
all of my testsuite runs.
--
Daniel Jacobowitz
CodeSourcery, LLC
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2005-02-26 6:07 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-01-16 19:47 [PING] Deal with intermixed 32-bit and 64-bit DWARF sections] Mark Kettenis
2005-01-25 21:07 ` [PING PING] " Mark Kettenis
2005-02-24 20:35 ` Daniel Jacobowitz
[not found] ` <7320016418918119@weblx058.utsp.utwente.nl>
2005-02-26 9:40 ` Elena Zannoni
2005-02-26 11:48 ` Daniel Jacobowitz
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox