This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug debug/15810] New: DWARF2 does not emit 64 bit offsets when in 64 bit mode
- From: "bdavis at macraigor dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 3 Jun 2004 20:21:23 -0000
- Subject: [Bug debug/15810] New: DWARF2 does not emit 64 bit offsets when in 64 bit mode
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
gcc -v:
Configured with: /rel/share/gnu/src/gcc-3.4.0/configure --host=i686-pc-cygwin -
-target=mips-elf --disable-nls --with-stabs --disable-install-libiberty --
disable-install-libbfd --disable-dependency-tracking --enable-64-bit-bfd --
enable-languages=c,c++ --with-gnu-as --with-gnu-ld
Thread model: single
gcc version 3.4.0
The code generated by gcc/dwarf2out.c doesn't generate 64 bit offsets when the
compiler is compiling for a 64 bit target. For example:
test.c:
int
main(int argc, char **argv)
{
int a, b;
b=1;
a=b+1;
return a;
}
then compile with:
mips-elf-gcc -g -EB -c -mips64 -mabi=64 test.c
Then look at debugging information (.debug_info):
mips-elf-objdump -xdgGrts test.o
You'll notice that the .debug_info section starts with
a 32 bit length.
However, when you link this .o with other 64 bit modules,
ld will insert an escaped 'ffffffff' 64-bit length at the
beginning of .debug_info.
This will cause gdb to mess up when it tries to parse .debug_info.
I created a simple source patch that works for me, though it may
not be general enough (I don't know):
*** gcc-3.4.0/gcc/dwarf2out.c Thu Mar 18 13:29:32 2004
--- gcc-3.4.0-macraigor1/gcc/dwarf2out.c Thu Jun 3 15:12:39 2004
***************
*** 271,277 ****
as PTR_SIZE. */
#ifndef DWARF_OFFSET_SIZE
! #define DWARF_OFFSET_SIZE 4
#endif
/* According to the (draft) DWARF 3 specification, the initial length
--- 271,277 ----
as PTR_SIZE. */
#ifndef DWARF_OFFSET_SIZE
! #define DWARF_OFFSET_SIZE DWARF2_ADDR_SIZE
#endif
/* According to the (draft) DWARF 3 specification, the initial length
***************
*** 286,291 ****
--- 286,295 ----
#define DWARF_INITIAL_LENGTH_SIZE (DWARF_OFFSET_SIZE == 4 ? 4 : 12)
#endif
+ #ifndef DWARF_CIE_OFFSET_SIZE
+ #define DWARF_CIE_OFFSET_SIZE 4
+ #endif
+
#define DWARF_VERSION 2
/* Round SIZE up to the nearest BOUNDARY. */
***************
*** 1975,1987 ****
/* Output the CIE. */
ASM_GENERATE_INTERNAL_LABEL (l1, CIE_AFTER_SIZE_LABEL, for_eh);
ASM_GENERATE_INTERNAL_LABEL (l2, CIE_END_LABEL, for_eh);
! dw2_asm_output_delta (for_eh ? 4 : DWARF_OFFSET_SIZE, l2, l1,
"Length of Common Information Entry");
ASM_OUTPUT_LABEL (asm_out_file, l1);
/* Now that the CIE pointer is PC-relative for EH,
use 0 to identify the CIE. */
! dw2_asm_output_data ((for_eh ? 4 : DWARF_OFFSET_SIZE),
(for_eh ? 0 : DW_CIE_ID),
"CIE Identifier Tag");
--- 1979,1991 ----
/* Output the CIE. */
ASM_GENERATE_INTERNAL_LABEL (l1, CIE_AFTER_SIZE_LABEL, for_eh);
ASM_GENERATE_INTERNAL_LABEL (l2, CIE_END_LABEL, for_eh);
! dw2_asm_output_delta (for_eh ? 4 : DWARF_CIE_OFFSET_SIZE, l2, l1,
"Length of Common Information Entry");
ASM_OUTPUT_LABEL (asm_out_file, l1);
/* Now that the CIE pointer is PC-relative for EH,
use 0 to identify the CIE. */
! dw2_asm_output_data ((for_eh ? 4 : DWARF_CIE_OFFSET_SIZE),
(for_eh ? 0 : DW_CIE_ID),
"CIE Identifier Tag");
***************
*** 2100,2113 ****
(*targetm.asm_out.internal_label) (asm_out_file, FDE_LABEL, for_eh + i
* 2);
ASM_GENERATE_INTERNAL_LABEL (l1, FDE_AFTER_SIZE_LABEL, for_eh + i * 2);
ASM_GENERATE_INTERNAL_LABEL (l2, FDE_END_LABEL, for_eh + i * 2);
! dw2_asm_output_delta (for_eh ? 4 : DWARF_OFFSET_SIZE, l2, l1,
"FDE Length");
ASM_OUTPUT_LABEL (asm_out_file, l1);
if (for_eh)
dw2_asm_output_delta (4, l1, section_start_label, "FDE CIE offset");
else
! dw2_asm_output_offset (DWARF_OFFSET_SIZE, section_start_label,
"FDE CIE offset");
if (for_eh)
--- 2104,2117 ----
(*targetm.asm_out.internal_label) (asm_out_file, FDE_LABEL, for_eh + i
* 2);
ASM_GENERATE_INTERNAL_LABEL (l1, FDE_AFTER_SIZE_LABEL, for_eh + i * 2);
ASM_GENERATE_INTERNAL_LABEL (l2, FDE_END_LABEL, for_eh + i * 2);
! dw2_asm_output_delta (for_eh ? 4 : DWARF_CIE_OFFSET_SIZE, l2, l1,
"FDE Length");
ASM_OUTPUT_LABEL (asm_out_file, l1);
if (for_eh)
dw2_asm_output_delta (4, l1, section_start_label, "FDE CIE offset");
else
! dw2_asm_output_offset (DWARF_CIE_OFFSET_SIZE, section_start_label,
"FDE CIE offset");
if (for_eh)
--
Summary: DWARF2 does not emit 64 bit offsets when in 64 bit mode
Product: gcc
Version: 3.4.0
Status: UNCONFIRMED
Severity: normal
Priority: P2
Component: debug
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: bdavis at macraigor dot com
CC: gcc-bugs at gcc dot gnu dot org
GCC host triplet: i686-pc-cygwin
GCC target triplet: mips-unknown-elf
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=15810