public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/63435] New: Bad code with weak vs localalias on AIX
@ 2014-10-01 23:13 gcc at dixie dot net.nz
  2014-10-01 23:17 ` [Bug c/63435] " gcc at dixie dot net.nz
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: gcc at dixie dot net.nz @ 2014-10-01 23:13 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63435

            Bug ID: 63435
           Summary: Bad code with weak vs localalias on AIX
           Product: gcc
           Version: 4.9.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: gcc at dixie dot net.nz
              Host: powerpc-ibm-aix7.1.0.0
            Target: powerpc-ibm-aix7.1.0.0
             Build: powerpc-ibm-aix7.1.0.0

Created attachment 33638
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=33638&action=edit
testcase

Consider attached testcase.

The recvfrom function is generated as a weak symbol,
symtab_node::noninterposable_alias creates a localalias.
        .weak   recvfrom[DS]
        .weak   .recvfrom
        .csect recvfrom[DS]
recvfrom:
        .long .recvfrom, TOC[tc0], 0
        .csect .text[PR]
.recvfrom:

-------

gcc-4.9.1 generates local alias to the weak symbol:
        .lglobl .recvfrom.localalias.0
        .lglobl recvfrom.localalias.0
        .set    .recvfrom.localalias.0,.recvfrom
        .set recvfrom.localalias.0,recvfrom

-------

This local alias is called with local calling convention (missing nop):
        bl .recvfrom.localalias.0
        mr 9,3

-------

The linker discards the weak local recvfrom symbol, and chooses recvfrom from
libc.
The recvfrom in libc is remote and needs a nop instruction.

The linker correctly issues a diagnostic about this:
ld: 0711-768 WARNING: Object myrecvfrom.o, section 1, function .recvfrom:
        The branch at address 0xc8 is not followed by a recognized no-op
        or TOC-reload instruction. The unrecognized instruction is 0x7C691B78.

At runtime this results in corrupt TOC pointer (possibly requires larger
testcase to observe problems).


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

end of thread, other threads:[~2021-07-18 21:21 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-10-01 23:13 [Bug c/63435] New: Bad code with weak vs localalias on AIX gcc at dixie dot net.nz
2014-10-01 23:17 ` [Bug c/63435] " gcc at dixie dot net.nz
2014-10-02 22:02 ` [Bug target/63435] " hubicka at ucw dot cz
2014-10-05 21:09 ` gcc at dixie dot net.nz
2014-10-06 19:01 ` hubicka at ucw dot cz
2021-07-18 21:21 ` pinskia at gcc dot gnu.org

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).