Bug 18628 - gold IFUNC testsuite failures with GCC 5
Summary: gold IFUNC testsuite failures with GCC 5
Status: RESOLVED FIXED
Alias: None
Product: binutils
Classification: Unclassified
Component: gold (show other bugs)
Version: 2.26
: P2 normal
Target Milestone: 2.26
Assignee: Cary Coutant
URL:
Keywords:
Depends on:
Blocks: 18521
  Show dependency treegraph
 
Reported: 2015-07-06 17:33 UTC by H.J. Lu
Modified: 2015-07-22 10:44 UTC (History)
3 users (show)

See Also:
Host:
Target:
Build:
Last reconfirmed:


Attachments
A patch (326 bytes, patch)
2015-07-13 20:06 UTC, H.J. Lu
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description H.J. Lu 2015-07-06 17:33:17 UTC
On Fedora 22/x86-64, gold on master branch at

commit 8a13d42d99390c36d5e7884b509e6bb92ec72e3c
Author: Simon Marchi <simon.marchi@ericsson.com>
Date:   Mon Jul 6 13:10:56 2015 -0400

    search_struct_field: remove OFFSET parameter

is miscompiled by GCC 5, gcc version 5.1.1 20150618 (Red Hat 5.1.1-4) (GCC):

FAIL: script_test_1
FAIL: script_test_11
FAIL: ifuncmain1
FAIL: ifuncmain1pic
FAIL: ifuncmain1vispic
FAIL: ifuncmain1vis
FAIL: ifuncmain1pie
FAIL: ifuncmain1vispie
FAIL: ifuncmain3

GCC 4.8.4 generates working gold.
Comment 1 Alan Modra 2015-07-08 09:33:14 UTC
This isn't a miscompilation of gold itself, but rather of the testcases.  You can prove this quite easily by building gold with gcc-5, running "make check" to reproduce the test failures, then "rm testsuite/script_test_1* testsuite/ifunc*" before running "make check" with an older gcc.
Comment 2 H.J. Lu 2015-07-13 20:04:24 UTC
I opened PR 18663 to track:

FAIL: script_test_1
FAIL: script_test_11

The IFUNC test issue is

[hjl@gnu-6 pr18628]$ readelf -r ifuncmod1.so

Relocation section '.rela.dyn' at offset 0x390 contains 7 entries:
  Offset          Info           Type           Sym. Value    Sym. Name + Addend
000000001828  000100000006 R_X86_64_GLOB_DAT foo()            foo + 0
000000001838  000200000006 R_X86_64_GLOB_DAT foo_hidden()     foo_hidden + 0
000000001848  000300000006 R_X86_64_GLOB_DAT foo_protected()  foo_protected + 0
000000001818  000400000006 R_X86_64_GLOB_DAT 0000000000001880 global + 0
000000001820  000600000006 R_X86_64_GLOB_DAT 0000000000000000 ret_foo + 0
000000001830  000800000006 R_X86_64_GLOB_DAT 0000000000000000 ret_foo_hidden + 0
000000001840  000a00000006 R_X86_64_GLOB_DAT 0000000000000000 ret_foo_protected + 0

Relocation section '.rela.plt' at offset 0x438 contains 3 entries:
  Offset          Info           Type           Sym. Value    Sym. Name + Addend
000000001868  000100000007 R_X86_64_JUMP_SLO foo()            foo + 0
000000001870  000000000025 R_X86_64_IRELATIV                    520
000000001878  000000000025 R_X86_64_IRELATIV                    550
[hjl@gnu-6 pr18628]$ readelf -s ifuncmod1.so | grep global
     4: 0000000000001880     4 OBJECT  GLOBAL PROTECTED   12 global
    10: 0000000000001880     4 OBJECT  GLOBAL PROTECTED   12 global
[hjl@gnu-6 pr18628]$ 

GCC 5 will generate relocation for protected symbol:

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

It is undefined to access protected symbol in IFUNC selector function
inside a DSO.
Comment 3 H.J. Lu 2015-07-13 20:06:23 UTC
Created attachment 8434 [details]
A patch

This works for me.
Comment 4 Cary Coutant 2015-07-22 02:14:38 UTC
Duplicate of PR 18521.

*** This bug has been marked as a duplicate of bug 18521 ***
Comment 5 H.J. Lu 2015-07-22 02:17:13 UTC
Reopen
Comment 6 H.J. Lu 2015-07-22 02:17:55 UTC
*** Bug 18521 has been marked as a duplicate of this bug. ***
Comment 7 H.J. Lu 2015-07-22 02:19:20 UTC
This bug report has analysis and a patch is posted at

https://sourceware.org/ml/binutils/2015-07/msg00098.html
Comment 8 cvs-commit@gcc.gnu.org 2015-07-22 10:41:47 UTC
The master branch has been updated by H.J. Lu <hjl@sourceware.org>:

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=cd78ea777c35c497fcc0f20d162789296dc0a44d

commit cd78ea777c35c497fcc0f20d162789296dc0a44d
Author: H.J. Lu <hjl.tools@gmail.com>
Date:   Wed Jul 22 03:35:47 2015 -0700

    Mark global with hidden attribute
    
    GCC 5 will generate a relocation for protected symbol:
    
    https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65248
    
    when compiling for a shared library.  It is undefined to access protected
    symbol in IFUNC selector function inside a shared library.
    
    	PR gold/18628
    	* testsuite/ifuncdep2.c (global): Change protected to hidden.
    	* testsuite/ifuncmod1.c (global): Likewise.
    	* testsuite/ifuncmod5.c (global): Likewise.
Comment 9 H.J. Lu 2015-07-22 10:44:43 UTC
Fixed.