+2002-11-18 Kevin Buettner <kevinb@redhat.com>
+
+ * 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 <aoliva@redhat.com>
* config/tc-mips.c (s_change_section): Make sure input buffer
-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;
+}
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 */
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
#include "dwarf2dbg.h"
+#ifndef DWARF2_FORMAT
+#define DWARF2_FORMAT() dwarf2_format_32bit
+#endif
+
#ifdef BFD_ASSEMBLER
#include "subsegs.h"
symbolS *prologue_end;
symbolS *line_end;
struct line_seg *s;
+ enum dwarf2_format d2f;
+ int sizeof_offset;
subseg_set (line_seg, 0);
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);
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);
symbolS *info_end;
char *p;
int len;
+ enum dwarf2_format d2f;
+ int sizeof_offset;
subseg_set (info_seg, 0);
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);
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);
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 */