[PATCH] Linker: Replace overridden subprograms
David Blaikie
dblaikie at gmail.com
Tue Dec 16 10:00:16 PST 2014
On Tue, Dec 16, 2014 at 9:48 AM, Rafael EspĂndola <
rafael.espindola at gmail.com> wrote:
>
> > It's possible to put DWARF subprogram definitions for linkonce_odr
> functions
> > into comdat groups so they are dropped along with the linkonce_odr
> function,
> > but Clang (& I don't think GCC by default) does that (there's some
> overhead
> > to that representational choice, etc). But yes, it can be done. I think
> > today, for both GCC and Clang, you'd end up with two subprogram
> definitions
> > (one in each DWARF compile unit) each pointing to the same
> high_pc/low_pc to
> > describe the function.
>
> I thought this was part of a special case for dwarf in linkers (and
> the missing feature why lld produced binaries are much larger in -g
> builds).
>
To the best of my knowledge, at least the usual Linux linkers (gold and
binutils-ld) don't have any special cases for DWARF (well, gold has some
magic to generate a GDB debug info index, maybe), it's just sections and
relocations like any other data in an object file. /maybe/ dsymutil on
MacOS does, but I've not heard about it. (& possibly dwz - a debug
info-aware compression tool could do that trick, it's designed to eliminate
redundancy in debug info)
A basic test case shows roughly what I described. (attached dwarfdump, if
you're curious - you can see what the source would've looked like from the
DWARF there (inline function in a header, two translation units that
instantiate the inline function, etc))
>
> > (but yeah, vaguely sounds like what you're suggesting would make sense -
> I
> > haven't looked at the initial proposed patch yet, though)
>
> Cheers,
> Rafael
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20141216/ca19bb09/attachment.html>
-------------- next part --------------
a.out: file format ELF64-x86-64
.debug_info contents:
0x00000000: Compile Unit: length = 0x0000006a version = 0x0004 abbr_offset = 0x0000 addr_size = 0x08 (next unit at 0x0000006e)
0x0000000b: DW_TAG_compile_unit [1] *
DW_AT_producer [DW_FORM_strp] ( .debug_str[0x00000000] = "GNU C++ 4.8.2 -mtune=generic -march=x86-64 -g -fstack-protector")
DW_AT_language [DW_FORM_data1] (DW_LANG_C_plus_plus)
DW_AT_name [DW_FORM_strp] ( .debug_str[0x00000040] = "f1.cpp")
DW_AT_comp_dir [DW_FORM_strp] ( .debug_str[0x00000055] = "/tmp/dbginfo")
DW_AT_ranges [DW_FORM_sec_offset] (0x00000000
[0x000000000040057d - 0x0000000000400588)
[0x0000000000400588 - 0x000000000040058e))
DW_AT_low_pc [DW_FORM_addr] (0x0000000000000000)
DW_AT_stmt_list [DW_FORM_sec_offset] (0x00000000)
0x00000029: DW_TAG_subprogram [2]
DW_AT_external [DW_FORM_flag_present] (true)
DW_AT_name [DW_FORM_strp] ( .debug_str[0x00000050] = "func")
DW_AT_decl_file [DW_FORM_data1] ("/tmp/dbginfo/f.h")
DW_AT_decl_line [DW_FORM_data1] (1)
DW_AT_linkage_name [DW_FORM_strp] ( .debug_str[0x00000047] = "_Z4funcv")
DW_AT_low_pc [DW_FORM_addr] (0x0000000000400588)
DW_AT_high_pc [DW_FORM_data8] (0x0000000000000006)
DW_AT_frame_base [DW_FORM_exprloc] (<0x1> 9c )
DW_AT_Unknown_2117 [DW_FORM_flag_present] (true)
0x00000046: DW_TAG_subroutine_type [3]
0x00000047: DW_TAG_subprogram [4]
DW_AT_external [DW_FORM_flag_present] (true)
DW_AT_name [DW_FORM_string] ("f1")
DW_AT_decl_file [DW_FORM_data1] ("/tmp/dbginfo/f1.cpp")
DW_AT_decl_line [DW_FORM_data1] (2)
DW_AT_linkage_name [DW_FORM_strp] ( .debug_str[0x00000062] = "_Z2f1v")
DW_AT_type [DW_FORM_ref4] (cu + 0x0067 => {0x00000067})
DW_AT_low_pc [DW_FORM_addr] (0x000000000040057d)
DW_AT_high_pc [DW_FORM_data8] (0x000000000000000b)
DW_AT_frame_base [DW_FORM_exprloc] (<0x1> 9c )
DW_AT_Unknown_2117 [DW_FORM_flag_present] (true)
0x00000067: DW_TAG_pointer_type [5]
DW_AT_byte_size [DW_FORM_data1] (0x08)
DW_AT_type [DW_FORM_ref4] (cu + 0x0046 => {0x00000046})
0x0000006d: NULL
0x0000006e: Compile Unit: length = 0x0000008e version = 0x0004 abbr_offset = 0x0054 addr_size = 0x08 (next unit at 0x00000100)
0x00000079: DW_TAG_compile_unit [1] *
DW_AT_producer [DW_FORM_strp] ( .debug_str[0x00000000] = "GNU C++ 4.8.2 -mtune=generic -march=x86-64 -g -fstack-protector")
DW_AT_language [DW_FORM_data1] (DW_LANG_C_plus_plus)
DW_AT_name [DW_FORM_strp] ( .debug_str[0x00000070] = "f2.cpp")
DW_AT_comp_dir [DW_FORM_strp] ( .debug_str[0x00000055] = "/tmp/dbginfo")
DW_AT_ranges [DW_FORM_sec_offset] (0x00000030
[0x000000000040058e - 0x00000000004005a4)
[0x0000000000400588 - 0x000000000040058e))
DW_AT_low_pc [DW_FORM_addr] (0x0000000000000000)
DW_AT_stmt_list [DW_FORM_sec_offset] (0x00000055)
0x00000097: DW_TAG_subprogram [2]
DW_AT_external [DW_FORM_flag_present] (true)
DW_AT_name [DW_FORM_strp] ( .debug_str[0x00000050] = "func")
DW_AT_decl_file [DW_FORM_data1] ("/tmp/dbginfo/f.h")
DW_AT_decl_line [DW_FORM_data1] (1)
DW_AT_linkage_name [DW_FORM_strp] ( .debug_str[0x00000047] = "_Z4funcv")
DW_AT_low_pc [DW_FORM_addr] (0x0000000000400588)
DW_AT_high_pc [DW_FORM_data8] (0x0000000000000006)
DW_AT_frame_base [DW_FORM_exprloc] (<0x1> 9c )
DW_AT_Unknown_2117 [DW_FORM_flag_present] (true)
0x000000b4: DW_TAG_subroutine_type [3]
0x000000b5: DW_TAG_subprogram [4]
DW_AT_external [DW_FORM_flag_present] (true)
DW_AT_name [DW_FORM_string] ("f2")
DW_AT_decl_file [DW_FORM_data1] ("/tmp/dbginfo/f2.cpp")
DW_AT_decl_line [DW_FORM_data1] (2)
DW_AT_linkage_name [DW_FORM_strp] ( .debug_str[0x00000069] = "_Z2f2v")
DW_AT_type [DW_FORM_ref4] (cu + 0x0067 => {0x000000d5})
DW_AT_low_pc [DW_FORM_addr] (0x000000000040058e)
DW_AT_high_pc [DW_FORM_data8] (0x000000000000000b)
DW_AT_frame_base [DW_FORM_exprloc] (<0x1> 9c )
DW_AT_Unknown_2117 [DW_FORM_flag_present] (true)
0x000000d5: DW_TAG_pointer_type [5]
DW_AT_byte_size [DW_FORM_data1] (0x08)
DW_AT_type [DW_FORM_ref4] (cu + 0x0046 => {0x000000b4})
0x000000db: DW_TAG_subprogram [6]
DW_AT_external [DW_FORM_flag_present] (true)
DW_AT_name [DW_FORM_strp] ( .debug_str[0x00000077] = "main")
DW_AT_decl_file [DW_FORM_data1] ("/tmp/dbginfo/f2.cpp")
DW_AT_decl_line [DW_FORM_data1] (5)
DW_AT_type [DW_FORM_ref4] (cu + 0x008a => {0x000000f8})
DW_AT_low_pc [DW_FORM_addr] (0x0000000000400599)
DW_AT_high_pc [DW_FORM_data8] (0x000000000000000b)
DW_AT_frame_base [DW_FORM_exprloc] (<0x1> 9c )
DW_AT_Unknown_2117 [DW_FORM_flag_present] (true)
0x000000f8: DW_TAG_base_type [7]
DW_AT_byte_size [DW_FORM_data1] (0x04)
DW_AT_encoding [DW_FORM_data1] (DW_ATE_signed)
DW_AT_name [DW_FORM_string] ("int")
0x000000ff: NULL
More information about the llvm-commits
mailing list