Re: [PATCH] lto: Set resolution to LDPR_PREVAILING_DEF for non-IR common symbol

"H.J. Lu" <[email protected]>
Newsgroups gmane.comp.gnu.binutils
Message-ID <CAMe9rOoVb6pY-a7OE3iz7tgfpR3Cg3WOdhHBi5bRRQof6Y7+2w@mail.gmail.com>
On Thu, Aug 27, 2026 at 10:28 PM Jan Beulich <[email protected]> wrote:
>
> On 27.08.2026 14:04, H.J. Lu wrote:
> > On Thu, Aug 27, 2026 at 7:52 PM Jan Beulich <[email protected]> wrote:
> >>
> >> On 27.08.2026 10:31, H.J. Lu wrote:
> >>> Since size or alignment of common symbol may be overridden by another
> >>> common symbol, set symbol resolution to LDPR_PREVAILING_DEF, instead of
> >>> LDPR_RESOLVED_EXEC, for common symbol in regular object when seeing an
> >>> undefined or common symbol from an IR object.
> >>
> >> Is this correct for the LDPK_COMMON case that's also covered by the if()
> >> that you alter in get_symbols()?
> >
> > My patch covers the case of
> >
> > syms[n].def == LDPK_COMMON && blhe->type == bfd_link_hash_common.
> >
> > which wasn't handled before.
>
> Right, but that doesn't answer my question, hinting towards a situation where
> two instances of a common symbol collide. And I can't really resolve that for
> myself because ...
>
> >> Adding to the (my?) confusion is that after said
> >>
> >>       if (syms[n].def == LDPK_UNDEF
> >>           || syms[n].def == LDPK_WEAKUNDEF
> >>           || syms[n].def == LDPK_COMMON)
> >>

It has everything to do with

     if (syms[n].def == LDPK_UNDEF
          || syms[n].def == LDPK_WEAKUNDEF
          || syms[n].def == LDPK_COMMON)

In its else clause, syms[n].def is LDPK_DEF or LDPK_WEAKDEF.
Linker plugin tells linker that originally def, weakdef, or common,
has been pre-empted.

> >> there's an "else if" with this comment:
> >>
> >>       /* Was originally def, weakdef, or common, but has been pre-empted.  */
> >>
> >> With the cited if(), no originally common symbol can make it there, can it?
>
> ... there's this comment which irritates me.
>
> > My patch covers
> >
> >       if (syms[n].def == LDPK_UNDEF
> >           || syms[n].def == LDPK_WEAKUNDEF
> >           || syms[n].def == LDPK_COMMON)
> >         {
> >              ...
> >
> > It has nothing to do with the else clause.
>
> Correct, and I didn't mean to say anything to the contrary.
>
> Jan



-- 
H.J.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.