This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Re: PR12760 plugin vs. warning syms
On Mon, May 16, 2011 at 7:58 AM, Alan Modra <amodra@gmail.com> wrote:
> On Mon, May 16, 2011 at 07:42:44AM -0700, H.J. Lu wrote:
>> On Mon, May 16, 2011 at 7:12 AM, Alan Modra <amodra@gmail.com> wrote:
>> > On Mon, May 16, 2011 at 05:48:42AM -0700, H.J. Lu wrote:
>> >> On Mon, May 16, 2011 at 1:29 AM, Alan Modra <amodra@gmail.com> wrote:
>> >> > On Sun, May 15, 2011 at 06:37:58PM -0700, H.J. Lu wrote:
>> >> >> We must call bfd_link_repair_undef_list when we change symbol
>> >> >> type to bfd_link_hash_undefweak. ?Otherwise, assert may fail in:
>> >> >>
>> >> >> void
>> >> >> bfd_link_add_undef (struct bfd_link_hash_table *table,
>> >> >> ? ? ? ? ? ? ? ? ? ? struct bfd_link_hash_entry *h)
>> >> >> {
>> >> >> ? BFD_ASSERT (h->u.undef.next == NULL);
>> >> >
>> >> > How could that happen? ?We know the new symbol is a definition.
>> >> >
>> >>
>> >> After we turned a definition into an undefweak, we may see a reference in
>> >> LTO output, which will call bfd_link_add_undef.
>> >
>> > No, because the undefweak doesn't last. ?When plugin_notice returns to
>> > _bfd_generic_link_add_one_symbol we'll turn it into a defined,
>> > defweak, or common.
>> >
>>
>> If linker sees undefined reference from an LTO output first, linker
>> will turn undefweak into undefined, which will trigger the assert.
>
> plugin_notice won't be changing syms (very temporarily) to undefweak
> in that case.
>
The sequence is
(gdb) bt
#0 plugin_notice (info=0x7c5a40, h=0x92ae90, abfd=0xe9c570,
section=0x13eb778, value=0)
at /export/gnu/import/git/binutils-lto/ld/plugin.c:957
#1 0x000000000045137f in _bfd_generic_link_add_one_symbol (info=0x7c5a40,
abfd=0xe9c570, name=0xe82089 "____ilog2_NaN", flags=4096,
section=0x13eb778, value=0, string=0xdfb030 "", copy=0, collect=0,
hashp=0x0) at /export/gnu/import/git/binutils-lto/bfd/linker.c:1610
#2 0x000000000048b1ed in elf_link_add_object_symbols (abfd=0xe9c570,
info=0x7c5a40) at /export/gnu/import/git/binutils-lto/bfd/elflink.c:3481
#3 0x000000000048f0ea in bfd_elf_link_add_symbols (abfd=0xe9c570,
info=0x7c5a40) at /export/gnu/import/git/binutils-lto/bfd/elflink.c:5150
#4 0x000000000041036c in load_symbols (entry=0x25341e0, place=0x7fffffffd920)
at /export/gnu/import/git/binutils-lto/ld/ldlang.c:2822
#5 0x0000000000410f25 in open_input_bfds (s=0x25341e0, mode=OPEN_BFD_NORMAL)
at /export/gnu/import/git/binutils-lto/ld/ldlang.c:3269
#6 0x0000000000416d41 in lang_process ()
at /export/gnu/import/git/binutils-lto/ld/ldlang.c:6565
#7 0x000000000041c8b5 in main (argc=51, argv=0x7fffffffdb68)
at /export/gnu/import/git/binutils-lto/ld/ldmain.c:438
(gdb) f 0
#0 plugin_notice (info=0x7c5a40, h=0x92ae90, abfd=0xe9c570,
section=0x13eb778, value=0)
at /export/gnu/import/git/binutils-lto/ld/plugin.c:957
957 h->type = bfd_link_hash_undefweak;
(gdb) p *h
$11 = {root = {next = 0x0, string = 0x91e17d "____ilog2_NaN",
hash = 183158111}, type = bfd_link_hash_defined, non_ir_ref = 0, u = {
undef = {next = 0x92b1b0, abfd = 0x11dce58}, def = {next = 0x92b1b0,
section = 0x11dce58, value = 0}, i = {next = 0x92b1b0, link = 0x11dce58,
warning = 0x0}, c = {next = 0x92b1b0, p = 0x11dce58, size = 0}}}
(gdb) p *section
$12 = {name = 0xe8207c ".gnu.warning.____ilog2_NaN", id = 60492, index = 11,
next = 0x13eb8a8, prev = 0x13eb648, flags = 264, user_set_vma = 1,
linker_mark = 0, linker_has_input = 0, gc_mark = 0, compress_status = 0,
segment_mark = 0, sec_info_type = 0, use_rela_p = 1, sec_flg0 = 0,
sec_flg1 = 0, sec_flg2 = 0, sec_flg3 = 0, sec_flg4 = 0, sec_flg5 = 0,
vma = 0, lma = 0, size = 0, rawsize = 0, compressed_size = 0, relax = 0x0,
relax_count = 0, output_offset = 0, output_section = 0x0,
alignment_power = 0, relocation = 0x0, orelocation = 0x0, reloc_count = 0,
filepos = 591785, rel_filepos = 0, line_filepos = 0, userdata = 0x0,
contents = 0x0, lineno = 0x0, lineno_count = 0, entsize = 0,
kept_section = 0x0, moving_line_filepos = 0, target_index = 0,
used_by_bfd = 0xc77870, constructor_chain = 0x0, owner = 0xe9c570,
symbol = 0x10211b0, symbol_ptr_ptr = 0x13eb870, map_head = {
link_order = 0x0, s = 0x0}, map_tail = {link_order = 0x0, s = 0x0}}
(gdb) p *abfd
$13 = {id = 79, filename = 0x15cdf40 "/tmp/ccKdXWcW.ltrans0.ltrans.o",
xvec = 0x58f7a0, iostream = 0xe85420, iovec = 0x57e120, lru_prev = 0x7f9e10,
lru_next = 0x15cd580, where = 743493, mtime = 0, ifd = 0,
format = bfd_object, direction = read_direction, flags = 65553, origin = 0,
proxy_origin = 0, section_htab = {table = 0xaa4d80,
newfunc = 0x44bd00 <bfd_section_hash_newfunc>, memory = 0xea0ca0,
size = 4051, count = 39, entsize = 304, frozen = 0}, sections = 0x13eaa68,
section_last = 0xf8e2c8, object_only_section = 0x0, section_count = 39,
start_address = 0, symcount = 0, outsymbols = 0x0, dynsymcount = 0,
arch_info = 0x5a0740, arelt_data = 0x0, my_archive = 0x0,
archive_next = 0x0, archive_head = 0x0, nested_archives = 0x0,
link_next = 0x0, archive_pass = 0, tdata = {aout_data = 0x1617530,
aout_ar_data = 0x1617530, oasys_obj_data = 0x1617530,
oasys_ar_data = 0x1617530, coff_obj_data = 0x1617530,
pe_obj_data = 0x1617530, xcoff_obj_data = 0x1617530,
ecoff_obj_data = 0x1617530, ieee_data = 0x1617530,
ieee_ar_data = 0x1617530, srec_data = 0x1617530, verilog_data = 0x1617530,
ihex_data = 0x1617530, tekhex_data = 0x1617530, elf_obj_data = 0x1617530,
nlm_obj_data = 0x1617530, bout_data = 0x1617530, mmo_data = 0x1617530,
sun_core_data = 0x1617530, sco5_core_data = 0x1617530,
trad_core_data = 0x1617530, som_data = 0x1617530,
hpux_core_data = 0x1617530, hppabsd_core_data = 0x1617530,
sgi_core_data = 0x1617530, lynx_core_data = 0x1617530,
---Type <return> to continue, or q <return> to quit---
osf_core_data = 0x1617530, cisco_core_data = 0x1617530,
versados_data = 0x1617530, netbsd_core_data = 0x1617530,
mach_o_data = 0x1617530, mach_o_fat_data = 0x1617530,
plugin_data = 0x1617530, pef_data = 0x1617530, pef_xlib_data = 0x1617530,
sym_data = 0x1617530, any = 0x1617530}, usrdata = 0x25341e0,
memory = 0x1a9e170, cacheable = 1, target_defaulted = 0, opened_once = 1,
mtime_set = 0, no_export = 0, output_has_begun = 0, has_armap = 0,
is_thin_archive = 0, selective_search = 0, lto_type = 1}
(gdb)
[hjl@gnu-mic-1 pr12760-2]$ readelf -r -s -S --wide
/tmp/ccKdXWcW.ltrans0.ltrans.o | grep ____ilog2_NaN
[22] .gnu.warning.____ilog2_NaN PROGBITS 0000000000000000
0907a9 000000 00 0 0 1
0000000000016ec3 000006e800000002 R_X86_64_PC32
0000000000000000 ____ilog2_NaN - 4
000000000001737b 000006e800000002 R_X86_64_PC32
0000000000000000 ____ilog2_NaN - 4
1768: 0000000000000000 0 NOTYPE GLOBAL HIDDEN UND ____ilog2_NaN
[hjl@gnu-mic-1 pr12760-2]$
We turn ____ilog2_NaN into undefweak when we try to issue a warning for
.gnu.warning. ____ilog2_NaN. But ____ilog2_NaN isn't defined, but referenced.
Things go downhill from there. Then we get
#0 bfd_assert (
file=0x58a990 "/export/gnu/import/git/binutils-lto/bfd/linker.c", line=630)
at /export/gnu/import/git/binutils-lto/bfd/bfd.c:959
#1 0x00000000004500e1 in bfd_link_add_undef (table=0x7ea7d0, h=0x92ae90)
at /export/gnu/import/git/binutils-lto/bfd/linker.c:630
#2 0x0000000000451420 in _bfd_generic_link_add_one_symbol (info=0x7c5a40,
abfd=0xe9c570, name=0xd22350 "____ilog2_NaN", flags=0, section=0x7bd2c0,
value=0, string=0x0, copy=0, collect=0, hashp=0xcaa368)
at /export/gnu/import/git/binutils-lto/bfd/linker.c:1636
#3 0x000000000048cde9 in elf_link_add_object_symbols (abfd=0xe9c570,
info=0x7c5a40) at /export/gnu/import/git/binutils-lto/bfd/elflink.c:4191
#4 0x000000000048f0ea in bfd_elf_link_add_symbols (abfd=0xe9c570,
info=0x7c5a40) at /export/gnu/import/git/binutils-lto/bfd/elflink.c:5150
#5 0x000000000041036c in load_symbols (entry=0x25341e0, place=0x7fffffffd920)
at /export/gnu/import/git/binutils-lto/ld/ldlang.c:2822
#6 0x0000000000410f25 in open_input_bfds (s=0x25341e0, mode=OPEN_BFD_NORMAL)
at /export/gnu/import/git/binutils-lto/ld/ldlang.c:3269
#7 0x0000000000416d41 in lang_process ()
at /export/gnu/import/git/binutils-lto/ld/ldlang.c:6565
#8 0x000000000041c8b5 in main (argc=51, argv=0x7fffffffdb68)
at /export/gnu/import/git/binutils-lto/ld/ldmain.c:438
(gdb)
--
H.J.