From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 12413 invoked by alias); 1 Oct 2014 23:13:09 -0000 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org Received: (qmail 12384 invoked by uid 48); 1 Oct 2014 23:13:03 -0000 From: "gcc at dixie dot net.nz" To: gcc-bugs@gcc.gnu.org Subject: [Bug c/63435] New: Bad code with weak vs localalias on AIX Date: Wed, 01 Oct 2014 23:13:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c X-Bugzilla-Version: 4.9.1 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: gcc at dixie dot net.nz X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter cf_gcchost cf_gcctarget cf_gccbuild attachments.created Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-SW-Source: 2014-10/txt/msg00096.txt.bz2 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).