https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85801
--- Comment #2 from H.J. Lu <hjl.tools at gmail dot com> --- (In reply to Richard Biener from comment #1) > I think this is valid from an ELF perspective. But ca you really expect > char *progname to resolve to the library copy? In fact the linker resolution > here is > > 1 > t2.o 4 > 207 b42c927210240321 PREVAILING_DEF main > 349 b42c927210240321 PREVAILING_DEF_IRONLY_EXP progname > 351 b42c927210240321 RESOLVED_DYN stderr > 347 b42c927210240321 UNDEF my_name > > and thus it correctly(?) resolves to a non-exported local copy > (GNU ld 2.30 branch). Note that without --as-needed I get This looks normal to me and works on x86. Linker plugin determined that program is defined in IR and visible externally: /* This is the prevailing definition of the symbol, with no references from regular objects. It is only referenced from IR code, but the symbol is exported and may be referenced from a dynamic object (not seen at link time). */ LDPR_PREVAILING_DEF_IRONLY_EXP The final resolution is performed by the non-LTO part of linker. Since program is COMMOM, the definition in libxfs.so is used. It sounds like a linker backend bug.