Bug 18718 - -fno-plt doesn't work with symbol versioning
Summary: -fno-plt doesn't work with symbol versioning
Status: RESOLVED FIXED
Alias: None
Product: binutils
Classification: Unclassified
Component: ld (show other bugs)
Version: 2.26
: P2 normal
Target Milestone: 2.26
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-07-24 23:03 UTC by H.J. Lu
Modified: 2015-07-27 17:14 UTC (History)
0 users

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


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description H.J. Lu 2015-07-24 23:03:31 UTC
[hjl@gnu-6 plt-2]$ cat x.c
extern void foo ();

void
new_foo()
{
}

__asm__(".symver new_foo, foo@@VERS_2.0");

int
main()
{
  foo();
  return 0;
}
[hjl@gnu-6 plt-2]$ make
/export/build/gnu/gcc/build-x86_64-linux/gcc/xgcc -B/export/build/gnu/gcc/build-x86_64-linux/gcc/ -O2 -fno-plt -S -o x.s x.c
/export/build/gnu/gcc/build-x86_64-linux/gcc/xgcc -B/export/build/gnu/gcc/build-x86_64-linux/gcc/  -o x x.s
/usr/local/bin/ld: x: No symbol version section for versioned symbol `foo@@VERS_2.0'
/usr/local/bin/ld: final link failed: Nonrepresentable section on output
collect2: error: ld returned 1 exit status
Makefile:19: recipe for target 'x' failed
make: *** [x] Error 1
[hjl@gnu-6 plt-2]$
Comment 1 cvs-commit@gcc.gnu.org 2015-07-25 15:08:24 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=1659f720b0818d6666570f79bef53ac461b2b22f

commit 1659f720b0818d6666570f79bef53ac461b2b22f
Author: H.J. Lu <hjl.tools@gmail.com>
Date:   Sat Jul 25 07:56:18 2015 -0700

    Skip missing symbol version section check for executable
    
    Missing symbol version section is a run-time problem only if it will
    be referenced dynamically at run-time.  We should skip the check for
    locally defined symbol, which isn't referenced by shared library, when
    linking executable.
    
    bfd/
    
    	PR ld/18718
    	* elflink.c (elf_link_output_extsym): Check symbol version
    	section check only if not linking executable, the symbol is
    	referenced by shared library or not locally defined.
    
    ld/testsuite/
    
    	PR ld/18718
    	* ld-elf/pr18718.c: New file.
    	* ld-elf/shared.exp: Run tests for PR ld/18718.
Comment 2 H.J. Lu 2015-07-25 15:13:10 UTC
Fixed.
Comment 3 cvs-commit@gcc.gnu.org 2015-07-26 21:56:33 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=edcab5e8bdaafdb96b182693a5c8eab020ba3e5c

commit edcab5e8bdaafdb96b182693a5c8eab020ba3e5c
Author: H.J. Lu <hjl.tools@gmail.com>
Date:   Sun Jul 26 14:55:39 2015 -0700

    Compile PR ld/18718 tests with -O2
    
    	PR ld/18718
    	* ld-elf/shared.exp: Compile PR ld/18718 tests with -O2.
Comment 4 cvs-commit@gcc.gnu.org 2015-07-27 17:14:26 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=c45bd4fd43e5eb0cbad8ec410504e4778c64c65d

commit c45bd4fd43e5eb0cbad8ec410504e4778c64c65d
Author: H.J. Lu <hjl.tools@gmail.com>
Date:   Mon Jul 27 10:04:31 2015 -0700

    Check address of versined symbol
    
    Since GCC 5 folds symbol address comparison, assuming each symbol has a
    different address, &foo == &bar is always false for GCC 5.  This patch
    adds check_ptr_eq if 2 addresses are the same and uses it to check the
    address of versined symbol.
    
    	PR ld/18718
    	* ld-elf/check-ptr-eq.c: New file.
    	* ld-elf/pr18718.c (main): Call check_ptr_eq.
    	* ld-elf/shared.exp: Add check-ptr-eq.c to PR ld/18718 tests.