[PATCH] handle large deltas with DWARF fixed_advance_pc

Bob Wilson bwilson@tensilica.com
Tue Jan 8 15:02:00 GMT 2008

DWARF's DW_LNS_fixed_advance_pc opcode has a 16-bit operand to specify the 
address delta between lines.  When I added the DWARF2_USE_FIXED_ADVANCE_PC flag 
to enable using these opcodes, I didn't think about what would happen when there 
is more than 64K between lines.  (The assembler dies.)

This patch fixes the problem by checking for an address delta that is close to 
the limit and using a DW_LNE_set_address opcode.  The check is conservative 
because the whole point of using fix_advance_pc opcodes is to handle linker 
relaxation that changes the code offsets.  I arbitrarily picked a value of 
50,000 as the cutoff, but I don't have a strong opinion on the exact value.  I 
don't expect linker relaxation to make big changes in the offsets, but on the 
other hand, such large address deltas won't occur often so it doesn't hurt to be 

This patch is more complicated than the old code because the size of the debug 
info and the kind of fix records that are generated depend on the address 
values, so they have to be handled as part of relaxation.

I needed some code to emit a fix record for an address and didn't want to 
hardcode the address size.  Instead I split out some existing code from 
emit_expr into a new function.

Is this OK?

2008-01-07  Bob Wilson  <bob.wilson@acm.org>

	* dwarf2dbg.c (out_sleb128): Delete.
	(size_fixed_inc_line_addr, emit_fixed_inc_line_addr): New.
	(out_fixed_inc_line_addr): Delete.
	(relax_inc_line_addr, dwarf2dbg_estimate_size_before_relax): Call new
	size_fixed_inc_line_addr if DWARF2_USE_FIXED_ADVANCE_PC is set.
	(dwarf2dbg_convert_frag): Likewise for emit_fixed_inc_line_addr.
	(process_entries): Remove calls to out_fixed_inc_line_addr.  When
	DWARF2_USE_FIXED_ADVANCE_PC is set, call relax_inc_line_addr.
	* read.h (emit_expr_fix): New prototype.
	* read.c (emit_expr): Move code to emit_expr_fix and use it here.
	(emit_expr_fix): New.

	* gas/lns/lns.exp: Run new lns-big-delta test for targets that set
	* gas/lns/lns-big-delta.s: New.
	* gas/lns/lns-big-delta.d: New.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: gas-dwarf-overflow.patch
Type: text/x-diff
Size: 11549 bytes
Desc: not available
URL: <https://sourceware.org/pipermail/binutils/attachments/20080108/0f6208da/attachment.bin>

More information about the Binutils mailing list