From 14e777e044ce425c1799f10cb92a641847064915 Mon Sep 17 00:00:00 2001 From: Kevin Buettner Date: Mon, 18 Nov 2002 21:08:54 +0000 Subject: Add support for 64-bit DWARF 2 formats to gas. --- gas/ChangeLog | 10 ++++++++ gas/config/tc-mips.c | 9 +++++++ gas/config/tc-mips.h | 3 +++ gas/doc/internals.texi | 21 ++++++++++++++++ gas/dwarf2dbg.c | 66 +++++++++++++++++++++++++++++++++++++++++++++----- gas/dwarf2dbg.h | 13 ++++++++++ 6 files changed, 116 insertions(+), 6 deletions(-) (limited to 'gas') diff --git a/gas/ChangeLog b/gas/ChangeLog index 4a5b671..5f7e79b 100644 --- a/gas/ChangeLog +++ b/gas/ChangeLog @@ -1,3 +1,13 @@ +2002-11-18 Kevin Buettner + + * dwarf2dbg.h (dwarf2_format): New enum. + * dwarf2dbg.c (DWARF2_FORMAT): Provide default definition. + (out_debug_line, out_debug_info): Add code for handling 64-bit + DWARF 2 formats. + * config/tc-mips.h (mips_dwarf2_format): Declare. + * config/tc-mips.c (mips_dwarf2_format): New function. + * doc/internals.texi (DWARF2_FORMAT): Document. + 2002-11-18 Alexandre Oliva * config/tc-mips.c (s_change_section): Make sure input buffer diff --git a/gas/config/tc-mips.c b/gas/config/tc-mips.c index 02e9e9f..c17e70a 100644 --- a/gas/config/tc-mips.c +++ b/gas/config/tc-mips.c @@ -14550,3 +14550,12 @@ MIPS options:\n\ -64 create 64 ABI object file\n")); #endif } + +enum dwarf2_format +mips_dwarf2_format () +{ + if (mips_abi == N64_ABI) + return dwarf2_format_64bit_irix; + else + return dwarf2_format_32bit; +} diff --git a/gas/config/tc-mips.h b/gas/config/tc-mips.h index 76c13dc..2c0f3fa 100644 --- a/gas/config/tc-mips.h +++ b/gas/config/tc-mips.h @@ -182,4 +182,7 @@ extern void mips_flush_pending_output PARAMS ((void)); extern void mips_enable_auto_align PARAMS ((void)); #define md_elf_section_change_hook() mips_enable_auto_align() +extern enum dwarf2_format mips_dwarf2_format PARAMS ((void)); +#define DWARF2_FORMAT() mips_dwarf2_format () + #endif /* TC_MIPS */ diff --git a/gas/doc/internals.texi b/gas/doc/internals.texi index 6d38790..23f2fce 100644 --- a/gas/doc/internals.texi +++ b/gas/doc/internals.texi @@ -1482,6 +1482,27 @@ The COFF @code{.section} directive will use the value of this macro to set a new section's attributes when a directive has no valid flags or when the flag is @code{w}. The default value of the macro is @code{SEC_LOAD | SEC_DATA}. +@item DWARF2_FORMAT () +@cindex DWARF2_FORMAT +If you define this, it should return one of @code{dwarf2_format_32bit}, +@code{dwarf2_format_64bit}, or @code{dwarf2_format_64bit_irix} to indicate +the size of internal DWARF section offsets and the format of the DWARF initial +length fields. When @code{dwarf2_format_32bit} is returned, the initial +length field will be 4 bytes long and section offsets are 32 bits in size. +For @code{dwarf2_format_64bit} and @code{dwarf2_format_64bit_irix}, section +offsets are 64 bits in size, but the initial length field differs. An 8 byte +initial length is indicated by @code{dwarf2_format_64bit_irix} and +@code{dwarf2_format_64bit} indicates a 12 byte initial length field in +which the first four bytes are 0xffffffff and the next 8 bytes are +the section's length. + +If you don't define this, @code{dwarf2_format_32bit} will be used as +the default. + +This define only affects @code{.debug_info} and @code{.debug_line} +sections generated by the assembler. DWARF 2 sections generated by +other tools will be unaffected by this setting. + @end table @node Object format backend diff --git a/gas/dwarf2dbg.c b/gas/dwarf2dbg.c index 7f78606..ff1624b 100644 --- a/gas/dwarf2dbg.c +++ b/gas/dwarf2dbg.c @@ -43,6 +43,10 @@ #include "dwarf2dbg.h" +#ifndef DWARF2_FORMAT +#define DWARF2_FORMAT() dwarf2_format_32bit +#endif + #ifdef BFD_ASSEMBLER #include "subsegs.h" @@ -999,6 +1003,8 @@ out_debug_line (line_seg) symbolS *prologue_end; symbolS *line_end; struct line_seg *s; + enum dwarf2_format d2f; + int sizeof_offset; subseg_set (line_seg, 0); @@ -1010,8 +1016,31 @@ out_debug_line (line_seg) expr.X_op = O_subtract; expr.X_add_symbol = line_end; expr.X_op_symbol = line_start; - expr.X_add_number = -4; - emit_expr (&expr, 4); + + d2f = DWARF2_FORMAT (); + if (d2f == dwarf2_format_32bit) + { + expr.X_add_number = -4; + emit_expr (&expr, 4); + sizeof_offset = 4; + } + else if (d2f == dwarf2_format_64bit) + { + expr.X_add_number = -12; + out_four (-1); + emit_expr (&expr, 8); + sizeof_offset = 8; + } + else if (d2f == dwarf2_format_64bit_irix) + { + expr.X_add_number = -8; + emit_expr (&expr, 8); + sizeof_offset = 8; + } + else + { + as_fatal (_("internal error: unknown dwarf2 format")); + } /* Version. */ out_two (2); @@ -1021,7 +1050,7 @@ out_debug_line (line_seg) expr.X_add_symbol = prologue_end; expr.X_op_symbol = line_start; expr.X_add_number = - (4 + 2 + 4); - emit_expr (&expr, 4); + emit_expr (&expr, sizeof_offset); /* Parameters of the state machine. */ out_byte (DWARF2_LINE_MIN_INSN_LENGTH); @@ -1174,6 +1203,8 @@ out_debug_info (info_seg, abbrev_seg, line_seg) symbolS *info_end; char *p; int len; + enum dwarf2_format d2f; + int sizeof_offset; subseg_set (info_seg, 0); @@ -1184,8 +1215,31 @@ out_debug_info (info_seg, abbrev_seg, line_seg) expr.X_op = O_subtract; expr.X_add_symbol = info_end; expr.X_op_symbol = info_start; - expr.X_add_number = -4; - emit_expr (&expr, 4); + + d2f = DWARF2_FORMAT (); + if (d2f == dwarf2_format_32bit) + { + expr.X_add_number = -4; + emit_expr (&expr, 4); + sizeof_offset = 4; + } + else if (d2f == dwarf2_format_64bit) + { + expr.X_add_number = -12; + out_four (-1); + emit_expr (&expr, 8); + sizeof_offset = 8; + } + else if (d2f == dwarf2_format_64bit_irix) + { + expr.X_add_number = -8; + emit_expr (&expr, 8); + sizeof_offset = 8; + } + else + { + as_fatal (_("internal error: unknown dwarf2 format")); + } /* DWARF version. */ out_two (2); @@ -1194,7 +1248,7 @@ out_debug_info (info_seg, abbrev_seg, line_seg) expr.X_op = O_symbol; expr.X_add_symbol = section_symbol (abbrev_seg); expr.X_add_number = 0; - emit_expr (&expr, 4); + emit_expr (&expr, sizeof_offset); /* Target address size. */ out_byte (sizeof_address); diff --git a/gas/dwarf2dbg.h b/gas/dwarf2dbg.h index 62fc020..d60d087 100644 --- a/gas/dwarf2dbg.h +++ b/gas/dwarf2dbg.h @@ -69,4 +69,17 @@ extern int dwarf2dbg_estimate_size_before_relax PARAMS ((fragS *)); extern int dwarf2dbg_relax_frag PARAMS ((fragS *)); extern void dwarf2dbg_convert_frag PARAMS ((fragS *)); +/* An enumeration which describes the sizes of offsets (to DWARF sections) + and the mechanism by which the size is indicated. */ +enum dwarf2_format { + /* 32-bit format: the initial length field is 4 bytes long. */ + dwarf2_format_32bit, + /* DWARF3 64-bit format: the representation of the initial length + (of a DWARF section) is 0xffffffff (4 bytes) followed by eight + bytes indicating the actual length. */ + dwarf2_format_64bit, + /* SGI extension to DWARF2: The initial length is eight bytes. */ + dwarf2_format_64bit_irix +}; + #endif /* AS_DWARF2DBG_H */ -- cgit v1.1