[Bug ld/11791] Garbage collection for STT_GNU_IFUNC symbols

2011-01-06 Thread hjl.tools at gmail dot com
http://sourceware.org/bugzilla/show_bug.cgi?id=11791

H.J. Lu hjl.tools at gmail dot com changed:

   What|Removed |Added

 Blocks||12371

-- 
Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email
--- You are receiving this mail because: ---
You are on the CC list for the bug.

___
bug-binutils mailing list
bug-binutils@gnu.org
http://lists.gnu.org/mailman/listinfo/bug-binutils


[Bug ld/12371] New: Garbage collection for STT_GNU_IFUNC symbols in shared library

2011-01-06 Thread hjl.tools at gmail dot com
http://sourceware.org/bugzilla/show_bug.cgi?id=12371

   Summary: Garbage collection for STT_GNU_IFUNC symbols in shared
library
   Product: binutils
   Version: 2.22 (HEAD)
Status: NEW
  Severity: normal
  Priority: P2
 Component: ld
AssignedTo: unassig...@sources.redhat.com
ReportedBy: hjl.to...@gmail.com
CC: hjl.to...@gmail.com, bug-binutils@gnu.org,
stephen.cla...@st.com, christian.br...@st.com
Depends on: 11791
  Host: i686-pc-linux-gnu
Target: i686-pc-linux-gnu
 Build: i686-pc-linux-gnu


+++ This bug was initially created as a clone of Bug #11791 +++

[...@gnu-6 intel64-2]$ cat foo.s
.section .text.foo,ax,@progbits
.type foo, @function
foo:
movl if...@gotpcrel(%rip), %eax
movl ifunc(%rip), %eax
call if...@plt
call ifunc
movl xxx(%rip), %eax
ret

.section .text.bar,ax,@progbits
.type bar, @function
bar:
.global bar
ret

.section .text.ifunc,ax,@progbits
.type ifunc, @gnu_indirect_function
ifunc:
ret

.section .data.foo,aw,@progbits
xxx:
.quad ifunc 
[...@gnu-6 intel64-2]$ make LD=ld
as  -o foo.o foo.s
ld -shared -e bar --gc-sections -o foo  foo.o
make: *** [foo] Segmentation fault
make: *** Deleting file `foo'

-- 
Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email
--- You are receiving this mail because: ---
You are on the CC list for the bug.

___
bug-binutils mailing list
bug-binutils@gnu.org
http://lists.gnu.org/mailman/listinfo/bug-binutils


[Bug ld/12366] assertion failure with STT_GNU_IFUNC symbols on x86_64

2011-01-06 Thread cvs-commit at gcc dot gnu.org
http://sourceware.org/bugzilla/show_bug.cgi?id=12366

--- Comment #1 from cvs-commit at gcc dot gnu.org cvs-commit at gcc dot 
gnu.org 2011-01-06 18:45:09 UTC ---
CVSROOT:/cvs/src
Module name:src
Changes by:h...@sourceware.org2011-01-06 18:45:05

Modified files:
bfd: ChangeLog elf-ifunc.c elf32-i386.c 
 elf64-x86-64.c 
ld/testsuite   : ChangeLog 
ld/testsuite/ld-ifunc: ifunc-10-i386.s ifunc-10-x86-64.s 
   ifunc-11-i386.s ifunc-11-x86-64.s 
Added files:
ld/testsuite/ld-ifunc: ifunc-12-i386.d ifunc-12-i386.s 
   ifunc-12-x86-64.d ifunc-12-x86-64.s 
   ifunc-13-i386.d ifunc-13-x86-64.d 
   ifunc-13a-i386.s ifunc-13a-x86-64.s 
   ifunc-13b-i386.s ifunc-13b-x86-64.s 

Log message:
Handle STT_GNU_IFUNC symols when building shared library.

bfd/

2012-01-06  H.J. Lu  hongjiu...@intel.com

PR ld/12366
PR ld/12371
* elf-ifunc.c (_bfd_elf_allocate_ifunc_dyn_relocs): Properly
handle symbols marked with regular reference, but not non-GOT
reference when building shared library.

* elf32-i386.c (elf_i386_gc_sweep_hook): Properly handle
local and global STT_GNU_IFUNC symols when building shared
library.
* elf64-x86-64.c (elf_x86_64_gc_sweep_hook): Likewise.

ld/testsuite/

2012-01-06  H.J. Lu  hongjiu...@intel.com

PR ld/12366
PR ld/12371
* ld-ifunc/ifunc-10-i386.s: Add more tests.
* ld-ifunc/ifunc-10-x86-64.s: Likewise.
* ld-ifunc/ifunc-11-i386.s: Likewise.
* ld-ifunc/ifunc-11-x86-64.s: Likewise.

* ld-ifunc/ifunc-12-i386.d: New.
* ld-ifunc/ifunc-12-i386.s: Likewise.
* ld-ifunc/ifunc-12-x86-64.d: Likewise.
* ld-ifunc/ifunc-12-x86-64.s: Likewise.
* ld-ifunc/ifunc-13-i386.d: Likewise.
* ld-ifunc/ifunc-13-x86-64.d: Likewise.
* ld-ifunc/ifunc-13a-i386.s: Likewise.
* ld-ifunc/ifunc-13a-x86-64.s: Likewise.
* ld-ifunc/ifunc-13b-i386.s: Likewise.
* ld-ifunc/ifunc-13b-x86-64.s: Likewise.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/src/bfd/ChangeLog.diff?cvsroot=srcr1=1.5223r2=1.5224
http://sourceware.org/cgi-bin/cvsweb.cgi/src/bfd/elf-ifunc.c.diff?cvsroot=srcr1=1.4r2=1.5
http://sourceware.org/cgi-bin/cvsweb.cgi/src/bfd/elf32-i386.c.diff?cvsroot=srcr1=1.241r2=1.242
http://sourceware.org/cgi-bin/cvsweb.cgi/src/bfd/elf64-x86-64.c.diff?cvsroot=srcr1=1.204r2=1.205
http://sourceware.org/cgi-bin/cvsweb.cgi/src/ld/testsuite/ChangeLog.diff?cvsroot=srcr1=1.1348r2=1.1349
http://sourceware.org/cgi-bin/cvsweb.cgi/src/ld/testsuite/ld-ifunc/ifunc-12-i386.d.diff?cvsroot=srcr1=NONEr2=1.1
http://sourceware.org/cgi-bin/cvsweb.cgi/src/ld/testsuite/ld-ifunc/ifunc-12-i386.s.diff?cvsroot=srcr1=NONEr2=1.1
http://sourceware.org/cgi-bin/cvsweb.cgi/src/ld/testsuite/ld-ifunc/ifunc-12-x86-64.d.diff?cvsroot=srcr1=NONEr2=1.1
http://sourceware.org/cgi-bin/cvsweb.cgi/src/ld/testsuite/ld-ifunc/ifunc-12-x86-64.s.diff?cvsroot=srcr1=NONEr2=1.1
http://sourceware.org/cgi-bin/cvsweb.cgi/src/ld/testsuite/ld-ifunc/ifunc-13-i386.d.diff?cvsroot=srcr1=NONEr2=1.1
http://sourceware.org/cgi-bin/cvsweb.cgi/src/ld/testsuite/ld-ifunc/ifunc-13-x86-64.d.diff?cvsroot=srcr1=NONEr2=1.1
http://sourceware.org/cgi-bin/cvsweb.cgi/src/ld/testsuite/ld-ifunc/ifunc-13a-i386.s.diff?cvsroot=srcr1=NONEr2=1.1
http://sourceware.org/cgi-bin/cvsweb.cgi/src/ld/testsuite/ld-ifunc/ifunc-13a-x86-64.s.diff?cvsroot=srcr1=NONEr2=1.1
http://sourceware.org/cgi-bin/cvsweb.cgi/src/ld/testsuite/ld-ifunc/ifunc-13b-i386.s.diff?cvsroot=srcr1=NONEr2=1.1
http://sourceware.org/cgi-bin/cvsweb.cgi/src/ld/testsuite/ld-ifunc/ifunc-13b-x86-64.s.diff?cvsroot=srcr1=NONEr2=1.1
http://sourceware.org/cgi-bin/cvsweb.cgi/src/ld/testsuite/ld-ifunc/ifunc-10-i386.s.diff?cvsroot=srcr1=1.1r2=1.2
http://sourceware.org/cgi-bin/cvsweb.cgi/src/ld/testsuite/ld-ifunc/ifunc-10-x86-64.s.diff?cvsroot=srcr1=1.1r2=1.2
http://sourceware.org/cgi-bin/cvsweb.cgi/src/ld/testsuite/ld-ifunc/ifunc-11-i386.s.diff?cvsroot=srcr1=1.1r2=1.2
http://sourceware.org/cgi-bin/cvsweb.cgi/src/ld/testsuite/ld-ifunc/ifunc-11-x86-64.s.diff?cvsroot=srcr1=1.1r2=1.2

-- 
Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email
--- You are receiving this mail because: ---
You are on the CC list for the bug.

___
bug-binutils mailing list
bug-binutils@gnu.org
http://lists.gnu.org/mailman/listinfo/bug-binutils


[Bug ld/12371] Garbage collection for STT_GNU_IFUNC symbols in shared library

2011-01-06 Thread hjl.tools at gmail dot com
http://sourceware.org/bugzilla/show_bug.cgi?id=12371

H.J. Lu hjl.tools at gmail dot com changed:

   What|Removed |Added

 Status|NEW |RESOLVED
 Resolution||FIXED

--- Comment #2 from H.J. Lu hjl.tools at gmail dot com 2011-01-06 18:47:33 
UTC ---
Fixed.

-- 
Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email
--- You are receiving this mail because: ---
You are on the CC list for the bug.

___
bug-binutils mailing list
bug-binutils@gnu.org
http://lists.gnu.org/mailman/listinfo/bug-binutils


[Bug ld/12366] assertion failure with STT_GNU_IFUNC symbols on x86_64

2011-01-06 Thread hjl.tools at gmail dot com
http://sourceware.org/bugzilla/show_bug.cgi?id=12366

H.J. Lu hjl.tools at gmail dot com changed:

   What|Removed |Added

 Status|NEW |RESOLVED
 Resolution||FIXED

--- Comment #2 from H.J. Lu hjl.tools at gmail dot com 2011-01-06 18:48:15 
UTC ---
Fixed.

-- 
Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email
--- You are receiving this mail because: ---
You are on the CC list for the bug.

___
bug-binutils mailing list
bug-binutils@gnu.org
http://lists.gnu.org/mailman/listinfo/bug-binutils


[Bug gold/12372] New: Segfault with STT_GNU_IFUNC symbols on x86_64

2011-01-06 Thread hjl.tools at gmail dot com
http://sourceware.org/bugzilla/show_bug.cgi?id=12372

   Summary: Segfault with STT_GNU_IFUNC symbols on x86_64
   Product: binutils
   Version: 2.22 (HEAD)
Status: NEW
  Severity: normal
  Priority: P2
 Component: gold
AssignedTo: i...@airs.com
ReportedBy: hjl.to...@gmail.com
CC: hjl.to...@gmail.com, richard.sandif...@linaro.org
Depends on: 12366


+++ This bug was initially created as a clone of Bug #12366 +++

The x86 and x86_64 IFUNC code assumes that check_relocs can rely on def_regular
being set for all regular definitions.  That's not true, because def_regular is
set by the same pass that calls check_relocs, and doesn't therefore take into
account regular definitions in later objects.  Everything works if the regular
definition comes before the regular use, but not the other way round.
+++

[...@gnu-6 pr12366-1]$ make LD=ld.gold
/export/build/gnu/gcc/build-x86_64-linux/gcc/xgcc
-B/export/build/gnu/gcc/build-x86_64-linux/gcc/ -fPIC-c -o main.o main.c
/export/build/gnu/gcc/build-x86_64-linux/gcc/xgcc
-B/export/build/gnu/gcc/build-x86_64-linux/gcc/ -fPIC-c -o bar.o bar.c
/export/build/gnu/gcc/build-x86_64-linux/gcc/xgcc
-B/export/build/gnu/gcc/build-x86_64-linux/gcc/ -fPIC-c -o foo.o foo.c
ld.gold  -shared -o libfoo.so bar.o foo.o
/export/build/gnu/gcc/build-x86_64-linux/gcc/xgcc
-B/export/build/gnu/gcc/build-x86_64-linux/gcc/ -o main main.o libfoo.so
-Wl,-rpath,.
./main
make: *** [all] Segmentation fault
[...@gnu-6 pr12366-1]$ 

GNU linker works:

[...@gnu-6 pr12366-1]$ make clean
rm -f a.out *.o *.so
[...@gnu-6 pr12366-1]$ make
/export/build/gnu/gcc/build-x86_64-linux/gcc/xgcc
-B/export/build/gnu/gcc/build-x86_64-linux/gcc/ -fPIC-c -o main.o main.c
/export/build/gnu/gcc/build-x86_64-linux/gcc/xgcc
-B/export/build/gnu/gcc/build-x86_64-linux/gcc/ -fPIC-c -o bar.o bar.c
/export/build/gnu/gcc/build-x86_64-linux/gcc/xgcc
-B/export/build/gnu/gcc/build-x86_64-linux/gcc/ -fPIC-c -o foo.o foo.c
./ld  -shared -o libfoo.so bar.o foo.o
/export/build/gnu/gcc/build-x86_64-linux/gcc/xgcc
-B/export/build/gnu/gcc/build-x86_64-linux/gcc/ -o main main.o libfoo.so
-Wl,-rpath,.
./main
Hello, world!
[...@gnu-6 pr12366-1]$

-- 
Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email
--- You are receiving this mail because: ---
You are on the CC list for the bug.

___
bug-binutils mailing list
bug-binutils@gnu.org
http://lists.gnu.org/mailman/listinfo/bug-binutils


[Bug ld/12371] Garbage collection for STT_GNU_IFUNC symbols in shared library

2011-01-06 Thread cvs-commit at gcc dot gnu.org
http://sourceware.org/bugzilla/show_bug.cgi?id=12371

--- Comment #1 from cvs-commit at gcc dot gnu.org cvs-commit at gcc dot 
gnu.org 2011-01-06 18:45:09 UTC ---
CVSROOT:/cvs/src
Module name:src
Changes by:h...@sourceware.org2011-01-06 18:45:05

Modified files:
bfd: ChangeLog elf-ifunc.c elf32-i386.c 
 elf64-x86-64.c 
ld/testsuite   : ChangeLog 
ld/testsuite/ld-ifunc: ifunc-10-i386.s ifunc-10-x86-64.s 
   ifunc-11-i386.s ifunc-11-x86-64.s 
Added files:
ld/testsuite/ld-ifunc: ifunc-12-i386.d ifunc-12-i386.s 
   ifunc-12-x86-64.d ifunc-12-x86-64.s 
   ifunc-13-i386.d ifunc-13-x86-64.d 
   ifunc-13a-i386.s ifunc-13a-x86-64.s 
   ifunc-13b-i386.s ifunc-13b-x86-64.s 

Log message:
Handle STT_GNU_IFUNC symols when building shared library.

bfd/

2012-01-06  H.J. Lu  hongjiu...@intel.com

PR ld/12366
PR ld/12371
* elf-ifunc.c (_bfd_elf_allocate_ifunc_dyn_relocs): Properly
handle symbols marked with regular reference, but not non-GOT
reference when building shared library.

* elf32-i386.c (elf_i386_gc_sweep_hook): Properly handle
local and global STT_GNU_IFUNC symols when building shared
library.
* elf64-x86-64.c (elf_x86_64_gc_sweep_hook): Likewise.

ld/testsuite/

2012-01-06  H.J. Lu  hongjiu...@intel.com

PR ld/12366
PR ld/12371
* ld-ifunc/ifunc-10-i386.s: Add more tests.
* ld-ifunc/ifunc-10-x86-64.s: Likewise.
* ld-ifunc/ifunc-11-i386.s: Likewise.
* ld-ifunc/ifunc-11-x86-64.s: Likewise.

* ld-ifunc/ifunc-12-i386.d: New.
* ld-ifunc/ifunc-12-i386.s: Likewise.
* ld-ifunc/ifunc-12-x86-64.d: Likewise.
* ld-ifunc/ifunc-12-x86-64.s: Likewise.
* ld-ifunc/ifunc-13-i386.d: Likewise.
* ld-ifunc/ifunc-13-x86-64.d: Likewise.
* ld-ifunc/ifunc-13a-i386.s: Likewise.
* ld-ifunc/ifunc-13a-x86-64.s: Likewise.
* ld-ifunc/ifunc-13b-i386.s: Likewise.
* ld-ifunc/ifunc-13b-x86-64.s: Likewise.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/src/bfd/ChangeLog.diff?cvsroot=srcr1=1.5223r2=1.5224
http://sourceware.org/cgi-bin/cvsweb.cgi/src/bfd/elf-ifunc.c.diff?cvsroot=srcr1=1.4r2=1.5
http://sourceware.org/cgi-bin/cvsweb.cgi/src/bfd/elf32-i386.c.diff?cvsroot=srcr1=1.241r2=1.242
http://sourceware.org/cgi-bin/cvsweb.cgi/src/bfd/elf64-x86-64.c.diff?cvsroot=srcr1=1.204r2=1.205
http://sourceware.org/cgi-bin/cvsweb.cgi/src/ld/testsuite/ChangeLog.diff?cvsroot=srcr1=1.1348r2=1.1349
http://sourceware.org/cgi-bin/cvsweb.cgi/src/ld/testsuite/ld-ifunc/ifunc-12-i386.d.diff?cvsroot=srcr1=NONEr2=1.1
http://sourceware.org/cgi-bin/cvsweb.cgi/src/ld/testsuite/ld-ifunc/ifunc-12-i386.s.diff?cvsroot=srcr1=NONEr2=1.1
http://sourceware.org/cgi-bin/cvsweb.cgi/src/ld/testsuite/ld-ifunc/ifunc-12-x86-64.d.diff?cvsroot=srcr1=NONEr2=1.1
http://sourceware.org/cgi-bin/cvsweb.cgi/src/ld/testsuite/ld-ifunc/ifunc-12-x86-64.s.diff?cvsroot=srcr1=NONEr2=1.1
http://sourceware.org/cgi-bin/cvsweb.cgi/src/ld/testsuite/ld-ifunc/ifunc-13-i386.d.diff?cvsroot=srcr1=NONEr2=1.1
http://sourceware.org/cgi-bin/cvsweb.cgi/src/ld/testsuite/ld-ifunc/ifunc-13-x86-64.d.diff?cvsroot=srcr1=NONEr2=1.1
http://sourceware.org/cgi-bin/cvsweb.cgi/src/ld/testsuite/ld-ifunc/ifunc-13a-i386.s.diff?cvsroot=srcr1=NONEr2=1.1
http://sourceware.org/cgi-bin/cvsweb.cgi/src/ld/testsuite/ld-ifunc/ifunc-13a-x86-64.s.diff?cvsroot=srcr1=NONEr2=1.1
http://sourceware.org/cgi-bin/cvsweb.cgi/src/ld/testsuite/ld-ifunc/ifunc-13b-i386.s.diff?cvsroot=srcr1=NONEr2=1.1
http://sourceware.org/cgi-bin/cvsweb.cgi/src/ld/testsuite/ld-ifunc/ifunc-13b-x86-64.s.diff?cvsroot=srcr1=NONEr2=1.1
http://sourceware.org/cgi-bin/cvsweb.cgi/src/ld/testsuite/ld-ifunc/ifunc-10-i386.s.diff?cvsroot=srcr1=1.1r2=1.2
http://sourceware.org/cgi-bin/cvsweb.cgi/src/ld/testsuite/ld-ifunc/ifunc-10-x86-64.s.diff?cvsroot=srcr1=1.1r2=1.2
http://sourceware.org/cgi-bin/cvsweb.cgi/src/ld/testsuite/ld-ifunc/ifunc-11-i386.s.diff?cvsroot=srcr1=1.1r2=1.2
http://sourceware.org/cgi-bin/cvsweb.cgi/src/ld/testsuite/ld-ifunc/ifunc-11-x86-64.s.diff?cvsroot=srcr1=1.1r2=1.2

-- 
Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email
--- You are receiving this mail because: ---
You are on the CC list for the bug.

___
bug-binutils mailing list
bug-binutils@gnu.org
http://lists.gnu.org/mailman/listinfo/bug-binutils


[Bug ld/12366] assertion failure with STT_GNU_IFUNC symbols on x86_64

2011-01-06 Thread hjl.tools at gmail dot com
http://sourceware.org/bugzilla/show_bug.cgi?id=12366

H.J. Lu hjl.tools at gmail dot com changed:

   What|Removed |Added

 Blocks||12372

-- 
Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email
--- You are receiving this mail because: ---
You are on the CC list for the bug.

___
bug-binutils mailing list
bug-binutils@gnu.org
http://lists.gnu.org/mailman/listinfo/bug-binutils


[Bug ld/12366] assertion failure with STT_GNU_IFUNC symbols on x86_64

2011-01-06 Thread hjl.tools at gmail dot com
http://sourceware.org/bugzilla/show_bug.cgi?id=12366

--- Comment #3 from H.J. Lu hjl.tools at gmail dot com 2011-01-07 02:06:39 
UTC ---
(In reply to comment #0)
 Created attachment 5181 [details]
 Shell script to reproduce bug
 
 The x86 and x86_64 IFUNC code assumes that check_relocs can rely on 
 def_regular
 being set for all regular definitions.  That's not true, because def_regular 
 is
 set by the same pass that calls check_relocs, and doesn't therefore take into
 account regular definitions in later objects.

We handle relocations against local STT_GNU_IFUNC symbols by
faking a STT_GNU_IFUNC symbol. def_regular is true for
those symbols.

My fix in _bfd_elf_allocate_ifunc_dyn_relocs handles
the case where a symbol is marked with regular reference,
but not non-GOT reference.  It may happen if we didn't
see STT_GNU_IFUNC symbol when checking relocations.

-- 
Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email
--- You are receiving this mail because: ---
You are on the CC list for the bug.

___
bug-binutils mailing list
bug-binutils@gnu.org
http://lists.gnu.org/mailman/listinfo/bug-binutils