This is the mail archive of the
binutils@sources.redhat.com
mailing list for the binutils project.
Re: gas dwarf2 assert failure for misaligned sections?
> I guess we should be emitting a normal error here rather than using
> an assert.
I tried to get the right file/line info, but by the time we're
encoding dwarf2 info (esp wrt relaxing the dwarf2 frags), we've lost
track of where the error really occurred. This patch at least prints
a user-readable error, and simplifies the existing code a bit too. I
don't like the message text, but it's the best I could come up with.
2002-11-26 DJ Delorie <dj@redhat.com.
* dwarf2dbg.c (scale_addr_delta): New.
(size_inc_line_addr): Use it.
(emit_inc_line_addr): Use it.
Index: dwarf2dbg.c
===================================================================
RCS file: /cvs/src/src/gas/dwarf2dbg.c,v
retrieving revision 1.55
diff -p -3 -r1.55 dwarf2dbg.c
*** dwarf2dbg.c 18 Nov 2002 21:08:52 -0000 1.55
--- dwarf2dbg.c 26 Nov 2002 21:15:42 -0000
*************** static void out_debug_line PARAMS ((segT
*** 174,179 ****
--- 174,180 ----
static void out_debug_aranges PARAMS ((segT, segT));
static void out_debug_abbrev PARAMS ((segT));
static void out_debug_info PARAMS ((segT, segT, segT));
+ static void scale_addr_delta PARAMS ((int *));
/* Find or create an entry for SEG+SUBSEG in ALL_SEGS. */
*************** out_set_addr (seg, frag, ofs)
*** 596,601 ****
--- 597,623 ----
emit_expr (&expr, sizeof_address);
}
+ #if DWARF2_LINE_MIN_INSN_LENGTH > 1
+ static void
+ scale_addr_delta (addr_delta)
+ int *addr_delta;
+ {
+ static int printed_this = 0;
+ if (*addr_delta % DWARF2_LINE_MIN_INSN_LENGTH != 0)
+ {
+ if (!printed_this)
+ as_bad("unaligned opcodes detected in executable segment");
+ printed_this = 1;
+ /* This just lets us continue processing, to catch other errors
+ and such. */
+ *addr_delta -= *addr_delta % DWARF2_LINE_MIN_INSN_LENGTH;
+ }
+ *addr_delta /= DWARF2_LINE_MIN_INSN_LENGTH;
+ }
+ #else
+ #define scale_addr_delta(A)
+ #endif
+
/* Encode a pair of line and address skips as efficiently as possible.
Note that the line skip is signed, whereas the address skip is unsigned.
*************** size_inc_line_addr (line_delta, addr_del
*** 612,621 ****
int len = 0;
/* Scale the address delta by the minimum instruction length. */
! #if DWARF2_LINE_MIN_INSN_LENGTH > 1
! assert (addr_delta % DWARF2_LINE_MIN_INSN_LENGTH == 0);
! addr_delta /= DWARF2_LINE_MIN_INSN_LENGTH;
! #endif
/* INT_MAX is a signal that this is actually a DW_LNE_end_sequence.
We cannot use special opcodes here, since we want the end_sequence
--- 634,640 ----
int len = 0;
/* Scale the address delta by the minimum instruction length. */
! scale_addr_delta (&addr_delta);
/* INT_MAX is a signal that this is actually a DW_LNE_end_sequence.
We cannot use special opcodes here, since we want the end_sequence
*************** emit_inc_line_addr (line_delta, addr_del
*** 678,688 ****
int need_copy = 0;
char *end = p + len;
- #if DWARF2_LINE_MIN_INSN_LENGTH > 1
/* Scale the address delta by the minimum instruction length. */
! assert (addr_delta % DWARF2_LINE_MIN_INSN_LENGTH == 0);
! addr_delta /= DWARF2_LINE_MIN_INSN_LENGTH;
! #endif
/* INT_MAX is a signal that this is actually a DW_LNE_end_sequence.
We cannot use special opcodes here, since we want the end_sequence
to emit the matrix entry. */
--- 697,705 ----
int need_copy = 0;
char *end = p + len;
/* Scale the address delta by the minimum instruction length. */
! scale_addr_delta (&addr_delta);
!
/* INT_MAX is a signal that this is actually a DW_LNE_end_sequence.
We cannot use special opcodes here, since we want the end_sequence
to emit the matrix entry. */