This is the mail archive of the binutils@sourceware.org mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[gold patch] Add incremental link support for debug sections


Debug sections are a problem for incremental linking because the
debugger and other consumers expect the .debug_info, .debug_types, and
.debug_line sections to contain a sequence of compile units, one after
the other. When adding patch space or leaving unused space in the
middle of a section during an incremental update, the resulting hole
makes the debug info unreadable. This patch fixes this by synthesizing
dummy compile unit headers in each hole. In order to guarantee that
any particular hole is large enough to hold a dummy header, I changed
the allocation method so that any chunk of free space left from an
allocation had to be a minimum size. (That, in turn, necessitated
adding some extra patch space to most of the incremental test cases.)

The dummy compile units for .debug_info and .debug_types work for
readelf/objdump, but not for gdb -- gdb insists on a
DW_TAG_compile_unit (or type_unit) DIE after each header, and I'm
generating a completely empty DIE tree. I'll submit a patch for gdb to
deal with that. (I prefer the empty DIE tree so that I don't have to
synthesize a fake debug abbrev table, too.) The dummy compile units
for .debug_line are filled with DW_LNS_set_basic_block opcodes --
basically no-ops as long as no row-creating opcodes are used.
(Technically, no consumer is supposed to read a .debug_line section
serially, but many do anyway -- they should instead follow the
DW_AT_stmt_list attribute from a compile_unit DIE.)

OK?

-cary

	* gold/layout.cc (Free_list::allocate): Provide guarantee of minimum
	remaining hole size when allocating.
	(Layout::make_output_section): Set fill methods for debug sections.
	* gold/layout.h (Free_list::Free_list_node): Move from private to
	public.
	(Free_list::set_min_hole_size): New function.
	(Free_list::begin, Free_list::end): New functions.
	(Free_list::min_hole_): New data member.
	* gold/output.cc: Include dwarf.h.
	(Output_fill_debug_info::do_minimum_hole_size): New function.
	(Output_fill_debug_info::do_write): New function.
	(Output_fill_debug_line::do_minimum_hole_size): New function.
	(Output_fill_debug_line::do_write): New function.
	(Output_section::Output_section): Initialize new data member.
	(Output_section::set_final_data_size): Ensure patch space is larger
	than minimum hole size.
	(Output_section::do_write): Fill holes in debug sections.
	* gold/output.h (Output_fill): New class.
	(Output_fill_debug_info): New class.
	(Output_fill_debug_line): New class.
	(Output_section::set_free_space_fill): New function.
	(Output_section::free_space_fill_): New data member.
	* gold/testsuite/Makefile.am (incremental_test_3): Add
	--incremental-patch option.
	(incremental_test_4): Likewise.
	(incremental_test_5): Likewise.
	(incremental_test_6): Likewise.
	(incremental_copy_test): Likewise.
	(incremental_common_test_1): Likewise.
	* gold/testsuite/Makefile.in: Regenerate.

Attachment: incr-debug-patch.txt
Description: Text document


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]