public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
* PR12760 plugin vs. warning syms
@ 2011-05-16  0:55 Alan Modra
  2011-05-16  1:38 ` H.J. Lu
  0 siblings, 1 reply; 10+ messages in thread
From: Alan Modra @ 2011-05-16  0:55 UTC (permalink / raw)
  To: binutils; +Cc: H.J. Lu

I've committed this version of HJ's patch to fix the segfault caused
by having a NULL u.undef.abfd.  I think this should be done even
though it's not a full fix for warning symbols.

	PR ld/12760
	* plugin.c (plugin_notice): Set u.undef.abfd for symbols made
	undefweak.

Index: ld/plugin.c
===================================================================
RCS file: /cvs/src/src/ld/plugin.c,v
retrieving revision 1.33
diff -u -p -r1.33 plugin.c
--- ld/plugin.c	24 Apr 2011 10:02:14 -0000	1.33
+++ ld/plugin.c	15 May 2011 13:18:27 -0000
@@ -912,6 +912,8 @@ plugin_notice (struct bfd_link_info *inf
 {
   if (h != NULL)
     {
+      bfd *sym_bfd;
+
       /* No further processing if this def/ref is from an IR dummy BFD.  */
       if (is_ir_dummy_bfd (abfd))
 	return TRUE;
@@ -928,10 +930,13 @@ plugin_notice (struct bfd_link_info *inf
 	 to be undefined.  */
       else if (((h->type == bfd_link_hash_defweak
 		 || h->type == bfd_link_hash_defined)
-		&& is_ir_dummy_bfd (h->u.def.section->owner))
+		&& is_ir_dummy_bfd (sym_bfd = h->u.def.section->owner))
 	       || (h->type == bfd_link_hash_common
-		   && is_ir_dummy_bfd (h->u.c.p->section->owner)))
-	h->type = bfd_link_hash_undefweak;
+		   && is_ir_dummy_bfd (sym_bfd = h->u.c.p->section->owner)))
+	{
+	  h->type = bfd_link_hash_undefweak;
+	  h->u.undef.abfd = sym_bfd;
+	}
     }
 
   /* Continue with cref/nocrossref/trace-sym processing.  */

-- 
Alan Modra
Australia Development Lab, IBM

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: PR12760 plugin vs. warning syms
  2011-05-16  0:55 PR12760 plugin vs. warning syms Alan Modra
@ 2011-05-16  1:38 ` H.J. Lu
  2011-05-16  8:29   ` Alan Modra
  0 siblings, 1 reply; 10+ messages in thread
From: H.J. Lu @ 2011-05-16  1:38 UTC (permalink / raw)
  To: Binutils

On Sun, May 15, 2011 at 5:55 PM, Alan Modra <amodra@gmail.com> wrote:
> I've committed this version of HJ's patch to fix the segfault caused
> by having a NULL u.undef.abfd.  I think this should be done even
> though it's not a full fix for warning symbols.
>
>        PR ld/12760
>        * plugin.c (plugin_notice): Set u.undef.abfd for symbols made
>        undefweak.
>
> Index: ld/plugin.c
> ===================================================================
> RCS file: /cvs/src/src/ld/plugin.c,v
> retrieving revision 1.33
> diff -u -p -r1.33 plugin.c
> --- ld/plugin.c 24 Apr 2011 10:02:14 -0000      1.33
> +++ ld/plugin.c 15 May 2011 13:18:27 -0000
> @@ -912,6 +912,8 @@ plugin_notice (struct bfd_link_info *inf
>  {
>   if (h != NULL)
>     {
> +      bfd *sym_bfd;
> +
>       /* No further processing if this def/ref is from an IR dummy BFD.  */
>       if (is_ir_dummy_bfd (abfd))
>        return TRUE;
> @@ -928,10 +930,13 @@ plugin_notice (struct bfd_link_info *inf
>         to be undefined.  */
>       else if (((h->type == bfd_link_hash_defweak
>                 || h->type == bfd_link_hash_defined)
> -               && is_ir_dummy_bfd (h->u.def.section->owner))
> +               && is_ir_dummy_bfd (sym_bfd = h->u.def.section->owner))
>               || (h->type == bfd_link_hash_common
> -                  && is_ir_dummy_bfd (h->u.c.p->section->owner)))
> -       h->type = bfd_link_hash_undefweak;
> +                  && is_ir_dummy_bfd (sym_bfd = h->u.c.p->section->owner)))
> +       {
> +         h->type = bfd_link_hash_undefweak;
> +         h->u.undef.abfd = sym_bfd;
> +       }
>     }
>

This isn't enough.  My current version is

      else if ((h->type == bfd_link_hash_defweak
                 || h->type == bfd_link_hash_defined)
                && is_ir_dummy_bfd (h->u.def.section->owner))
        {
          h->u.undef.abfd = h->u.def.section->owner;
          h->type = bfd_link_hash_undefweak;
          if (h->u.undef.next != NULL
              || link_info.hash->undefs_tail == h)
            bfd_link_repair_undef_list (link_info.hash);
        }
      else if (h->type == bfd_link_hash_common
               && is_ir_dummy_bfd (h->u.c.p->section->owner))
        {
          h->u.undef.abfd = h->u.c.p->section->owner;
          h->type = bfd_link_hash_undefweak;
          if (h->u.undef.next != NULL
              || link_info.hash->undefs_tail == h)
            bfd_link_repair_undef_list (link_info.hash);
        }

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);
  if (table->undefs_tail != NULL)
    table->undefs_tail->u.undef.next = h;
  if (table->undefs == NULL)
    table->undefs = h;
  table->undefs_tail = h;
}


-- 
H.J.

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: PR12760 plugin vs. warning syms
  2011-05-16  1:38 ` H.J. Lu
@ 2011-05-16  8:29   ` Alan Modra
  2011-05-16 12:48     ` H.J. Lu
  0 siblings, 1 reply; 10+ messages in thread
From: Alan Modra @ 2011-05-16  8:29 UTC (permalink / raw)
  To: H.J. Lu; +Cc: Binutils

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.

-- 
Alan Modra
Australia Development Lab, IBM

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: PR12760 plugin vs. warning syms
  2011-05-16  8:29   ` Alan Modra
@ 2011-05-16 12:48     ` H.J. Lu
  2011-05-16 14:12       ` Alan Modra
  0 siblings, 1 reply; 10+ messages in thread
From: H.J. Lu @ 2011-05-16 12:48 UTC (permalink / raw)
  To: Binutils

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.


-- 
H.J.

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: PR12760 plugin vs. warning syms
  2011-05-16 12:48     ` H.J. Lu
@ 2011-05-16 14:12       ` Alan Modra
  2011-05-16 14:43         ` H.J. Lu
  0 siblings, 1 reply; 10+ messages in thread
From: Alan Modra @ 2011-05-16 14:12 UTC (permalink / raw)
  To: H.J. Lu; +Cc: Binutils

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.

-- 
Alan Modra
Australia Development Lab, IBM

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: PR12760 plugin vs. warning syms
  2011-05-16 14:12       ` Alan Modra
@ 2011-05-16 14:43         ` H.J. Lu
  2011-05-16 14:58           ` Alan Modra
  0 siblings, 1 reply; 10+ messages in thread
From: H.J. Lu @ 2011-05-16 14:43 UTC (permalink / raw)
  To: Binutils

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.

Also, there are

/* The undefs list was designed so that in normal use we don't need to
   remove entries.  However, if symbols on the list are changed from
   bfd_link_hash_undefined to either bfd_link_hash_undefweak or
   bfd_link_hash_new for some reason, then they must be removed from the
   list.  Failure to do so might result in the linker attempting to add
   the symbol to the list again at a later stage.  */

void
bfd_link_repair_undef_list (struct bfd_link_hash_table *table)


-- 
H.J.

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: PR12760 plugin vs. warning syms
  2011-05-16 14:43         ` H.J. Lu
@ 2011-05-16 14:58           ` Alan Modra
  2011-05-16 20:14             ` H.J. Lu
  0 siblings, 1 reply; 10+ messages in thread
From: Alan Modra @ 2011-05-16 14:58 UTC (permalink / raw)
  To: H.J. Lu; +Cc: Binutils

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.

-- 
Alan Modra
Australia Development Lab, IBM

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: PR12760 plugin vs. warning syms
  2011-05-16 14:58           ` Alan Modra
@ 2011-05-16 20:14             ` H.J. Lu
  2011-05-17  1:45               ` Alan Modra
  0 siblings, 1 reply; 10+ messages in thread
From: H.J. Lu @ 2011-05-16 20:14 UTC (permalink / raw)
  To: Binutils

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.

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: PR12760 plugin vs. warning syms
  2011-05-16 20:14             ` H.J. Lu
@ 2011-05-17  1:45               ` Alan Modra
  2011-05-17 13:01                 ` Alan Modra
  0 siblings, 1 reply; 10+ messages in thread
From: Alan Modra @ 2011-05-17  1:45 UTC (permalink / raw)
  To: H.J. Lu; +Cc: Binutils

On Mon, May 16, 2011 at 01:13:41PM -0700, H.J. Lu wrote:
> The sequence is

Light dawns..  If we are making a warning sym, then we won't be
turning the undefweak back into a defined, defweak or common when we
return to _bfd_generic_link_add_one_symbol.  Instead we get an
indirection.

I'll look into fixing that, and BSF_INDIRECT symbols.

-- 
Alan Modra
Australia Development Lab, IBM

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: PR12760 plugin vs. warning syms
  2011-05-17  1:45               ` Alan Modra
@ 2011-05-17 13:01                 ` Alan Modra
  0 siblings, 0 replies; 10+ messages in thread
From: Alan Modra @ 2011-05-17 13:01 UTC (permalink / raw)
  To: H.J. Lu, Binutils

On Tue, May 17, 2011 at 11:15:20AM +0930, Alan Modra wrote:
> Light dawns..  If we are making a warning sym, then we won't be
> turning the undefweak back into a defined, defweak or common when we
> return to _bfd_generic_link_add_one_symbol.  Instead we get an
> indirection.
> 
> I'll look into fixing that, and BSF_INDIRECT symbols.

include/
	* bfdlink.h (struct bfd_link_callbacks <notice>): Add "flags" and
	"string" param.
bfd/
	* coff-aux.c (coff_m68k_aux_link_add_one_symbol): Adjust "notice" call.
	* elflink.c (elf_link_add_object_symbols): Likewise.
	* linker.c (_bfd_generic_link_add_one_symbol): Likewise.
ld/
	* ldmain.c (notice): Add "flags" and "string" param.
	* plugin.c (plugin_notice): Likewise.  Handle indirect, warning
	and constructor syms.

Index: include/bfdlink.h
===================================================================
RCS file: /cvs/src/src/include/bfdlink.h,v
retrieving revision 1.86
diff -u -p -r1.86 bfdlink.h
--- include/bfdlink.h	15 May 2011 23:44:06 -0000	1.86
+++ include/bfdlink.h	17 May 2011 05:39:01 -0000
@@ -573,10 +573,13 @@ struct bfd_link_callbacks
   /* A function which is called when a symbol in notice_hash is
      defined or referenced.  H is the symbol.  ABFD, SECTION and
      ADDRESS are the (new) value of the symbol.  If SECTION is
-     bfd_und_section, this is a reference.  */
+     bfd_und_section, this is a reference.  FLAGS are the symbol
+     BSF_* flags.  STRING is the name of the symbol to indirect to if
+     the sym is indirect, or the warning string if a warning sym.  */
   bfd_boolean (*notice)
     (struct bfd_link_info *, struct bfd_link_hash_entry *h,
-     bfd *abfd, asection *section, bfd_vma address);
+     bfd *abfd, asection *section, bfd_vma address, flagword flags,
+     const char *string);
   /* Error or warning link info message.  */
   void (*einfo)
     (const char *fmt, ...);
Index: bfd/coff-aux.c
===================================================================
RCS file: /cvs/src/src/bfd/coff-aux.c,v
retrieving revision 1.11
diff -u -p -r1.11 coff-aux.c
--- bfd/coff-aux.c	24 Apr 2011 10:02:13 -0000	1.11
+++ bfd/coff-aux.c	17 May 2011 05:38:12 -0000
@@ -105,7 +105,8 @@ coff_m68k_aux_link_add_one_symbol (info,
 	  && (bfd_hash_lookup (info->notice_hash, name, FALSE, FALSE)
 	      != (struct bfd_hash_entry *) NULL))
 	{
-	  if (! (*info->callbacks->notice) (info, h, abfd, section, value))
+	  if (! (*info->callbacks->notice) (info, h, abfd, section, value,
+					    flags, string))
 	    return FALSE;
 	}
 
Index: bfd/elflink.c
===================================================================
RCS file: /cvs/src/src/bfd/elflink.c,v
retrieving revision 1.403
diff -u -p -r1.403 elflink.c
--- bfd/elflink.c	7 May 2011 14:12:59 -0000	1.403
+++ bfd/elflink.c	17 May 2011 05:38:29 -0000
@@ -3814,7 +3814,7 @@ error_free_dyn:
       /* Make a special call to the linker "notice" function to
 	 tell it that we are about to handle an as-needed lib.  */
       if (!(*info->callbacks->notice) (info, NULL, abfd, NULL,
-				       notice_as_needed))
+				       notice_as_needed, 0, NULL))
 	goto error_free_vers;
 
       /* Clone the symbol table and sym hashes.  Remember some
@@ -4561,7 +4561,7 @@ error_free_dyn:
       /* Make a special call to the linker "notice" function to
 	 tell it that symbols added for crefs may need to be removed.  */
       if (!(*info->callbacks->notice) (info, NULL, abfd, NULL,
-				       notice_not_needed))
+				       notice_not_needed, 0, NULL))
 	goto error_free_vers;
 
       free (old_tab);
@@ -4575,7 +4575,7 @@ error_free_dyn:
   if (old_tab != NULL)
     {
       if (!(*info->callbacks->notice) (info, NULL, abfd, NULL,
-				       notice_needed))
+				       notice_needed, 0, NULL))
 	goto error_free_vers;
       free (old_tab);
       old_tab = NULL;
Index: bfd/linker.c
===================================================================
RCS file: /cvs/src/src/bfd/linker.c,v
retrieving revision 1.82
diff -u -p -r1.82 linker.c
--- bfd/linker.c	15 May 2011 23:44:07 -0000	1.82
+++ bfd/linker.c	17 May 2011 05:38:35 -0000
@@ -1607,7 +1607,8 @@ _bfd_generic_link_add_one_symbol (struct
       || (info->notice_hash != NULL
 	  && bfd_hash_lookup (info->notice_hash, name, FALSE, FALSE) != NULL))
     {
-      if (! (*info->callbacks->notice) (info, h, abfd, section, value))
+      if (! (*info->callbacks->notice) (info, h,
+					abfd, section, value, flags, string))
 	return FALSE;
     }
 
Index: ld/ldmain.c
===================================================================
RCS file: /cvs/src/src/ld/ldmain.c,v
retrieving revision 1.154
diff -u -p -r1.154 ldmain.c
--- ld/ldmain.c	24 Apr 2011 10:02:14 -0000	1.154
+++ ld/ldmain.c	17 May 2011 05:39:02 -0000
@@ -151,7 +151,7 @@ static bfd_boolean unattached_reloc
   (struct bfd_link_info *, const char *, bfd *, asection *, bfd_vma);
 static bfd_boolean notice
   (struct bfd_link_info *, struct bfd_link_hash_entry *,
-   bfd *, asection *, bfd_vma);
+   bfd *, asection *, bfd_vma, flagword, const char *);
 
 static struct bfd_link_callbacks link_callbacks =
 {
@@ -1483,7 +1483,9 @@ notice (struct bfd_link_info *info,
 	struct bfd_link_hash_entry *h,
 	bfd *abfd,
 	asection *section,
-	bfd_vma value)
+	bfd_vma value,
+	flagword flags ATTRIBUTE_UNUSED,
+	const char *string ATTRIBUTE_UNUSED)
 {
   const char *name;
 
Index: ld/plugin.c
===================================================================
RCS file: /cvs/src/src/ld/plugin.c,v
retrieving revision 1.34
diff -u -p -r1.34 plugin.c
--- ld/plugin.c	16 May 2011 00:58:11 -0000	1.34
+++ ld/plugin.c	17 May 2011 12:42:18 -0000
@@ -125,9 +125,9 @@ static const enum ld_plugin_tag tv_heade
 static const size_t tv_header_size = ARRAY_SIZE (tv_header_tags);
 
 /* Forward references.  */
-static bfd_boolean plugin_notice (struct bfd_link_info *info,
-				  struct bfd_link_hash_entry *h, bfd *abfd,
-				  asection *section, bfd_vma value);
+static bfd_boolean plugin_notice (struct bfd_link_info *,
+				  struct bfd_link_hash_entry *, bfd *,
+				  asection *, bfd_vma, flagword, const char *);
 
 #if !defined (HAVE_DLFCN_H) && defined (HAVE_WINDOWS_H)
 
@@ -908,7 +908,9 @@ plugin_notice (struct bfd_link_info *inf
 	       struct bfd_link_hash_entry *h,
 	       bfd *abfd,
 	       asection *section,
-	       bfd_vma value)
+	       bfd_vma value,
+	       flagword flags,
+	       const char *string)
 {
   if (h != NULL)
     {
@@ -918,8 +920,33 @@ plugin_notice (struct bfd_link_info *inf
       if (is_ir_dummy_bfd (abfd))
 	return TRUE;
 
+      /* Making an indirect symbol counts as a reference unless this
+	 is a brand new symbol.  */
+      if (bfd_is_ind_section (section)
+	  || (flags & BSF_INDIRECT) != 0)
+	{
+	  if (h->type != bfd_link_hash_new)
+	    {
+	      struct bfd_link_hash_entry *inh;
+
+	      h->non_ir_ref = TRUE;
+	      inh = bfd_wrapped_link_hash_lookup (abfd, info, string, FALSE,
+						  FALSE, FALSE);
+	      if (inh != NULL)
+		inh->non_ir_ref = TRUE;
+	    }
+	}
+
+      /* Nothing to do here for warning symbols.  */
+      else if ((flags & BSF_WARNING) != 0)
+	;
+
+      /* Nothing to do here for constructor symbols.  */
+      else if ((flags & BSF_CONSTRUCTOR) != 0)
+	;
+
       /* If this is a ref, set non_ir_ref.  */
-      if (bfd_is_und_section (section))
+      else if (bfd_is_und_section (section))
 	h->non_ir_ref = TRUE;
 
       /* Otherwise, it must be a new def.  Ensure any symbol defined
@@ -945,6 +972,7 @@ plugin_notice (struct bfd_link_info *inf
       || (info->notice_hash != NULL
 	  && bfd_hash_lookup (info->notice_hash, h->root.string,
 			      FALSE, FALSE) != NULL))
-    return (*orig_callbacks->notice) (info, h, abfd, section, value);
+    return (*orig_callbacks->notice) (info, h,
+				      abfd, section, value, flags, string);
   return TRUE;
 }

-- 
Alan Modra
Australia Development Lab, IBM

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2011-05-17 13:01 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-05-16  0:55 PR12760 plugin vs. warning syms Alan Modra
2011-05-16  1:38 ` H.J. Lu
2011-05-16  8:29   ` Alan Modra
2011-05-16 12:48     ` H.J. Lu
2011-05-16 14:12       ` Alan Modra
2011-05-16 14:43         ` H.J. Lu
2011-05-16 14:58           ` Alan Modra
2011-05-16 20:14             ` H.J. Lu
2011-05-17  1:45               ` Alan Modra
2011-05-17 13:01                 ` Alan Modra

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).