[Bug ld/10911] New: ld -s -static breaks IRELATIVE relocations

View: New views
6 Messages — Rating Filter:   Alert me  

[Bug ld/10911] New: ld -s -static breaks IRELATIVE relocations

by Bugzilla from sourceware-bugzilla@sourceware.org :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

.text
.type foo, @gnu_indirect_function
.globl foo
foo:
leaq __foo(%rip), %rax
retq
.type __foo, @function
__foo:
retq
.type _start, @function
.globl _start
_start:
call foo
1: jmp 1b

$ as -o t.o t.s
$ ld -static -o t t.o
$ readelf -Wr t
Relocation section '.rela.plt' at offset 0xb0 contains 1 entries:
    Offset             Info             Type               Symbol's Value
Symbol's Name + Addend
00000000006000e8  0000000000000025 R_X86_64_IRELATIVE                          
  00000000004000d8
$ strip t
$ readelf -Wr t
Relocation section '.rela.plt' at offset 0xb0 contains 1 entries:
    Offset             Info             Type               Symbol's Value
Symbol's Name + Addend
00000000006000e8  0000000000000025 R_X86_64_IRELATIVE                          
  00000000004000d8
$ ld -static -s -o t t.o
Relocation section '.rela.plt' at offset 0xb0 contains 1 entries:
    Offset             Info             Type               Symbol's Value
Symbol's Name + Addend
0000000000000000  0000000000000000 R_X86_64_NONE                                
  0000000000000000

While this minimal testcase won't work in any case, when actually linking a real
program (say replace _start with main and link with -lc), the program will die
because of unexpected reloc type in statically linked binary.

--
           Summary: ld -s -static breaks IRELATIVE relocations
           Product: binutils
           Version: unspecified
            Status: NEW
          Severity: normal
          Priority: P2
         Component: ld
        AssignedTo: unassigned at sources dot redhat dot com
        ReportedBy: jakub at redhat dot com
                CC: bug-binutils at gnu dot org
GCC target triplet: x86_64-linux


http://sourceware.org/bugzilla/show_bug.cgi?id=10911

------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.


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

[Bug ld/10911] ld -s -static breaks IRELATIVE relocations

by Bugzilla from sourceware-bugzilla@sourceware.org :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message



--
           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |hjl dot tools at gmail dot
                   |                            |com


http://sourceware.org/bugzilla/show_bug.cgi?id=10911

------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.


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

[Bug ld/10911] ld -s -static breaks IRELATIVE relocations

by Bugzilla from sourceware-bugzilla@sourceware.org :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


------- Additional Comments From hjl dot tools at gmail dot com  2009-11-08 23:03 -------
This patch should work:

diff --git a/bfd/elflink.c b/bfd/elflink.c
index cd016b7..0153411 100644
--- a/bfd/elflink.c
+++ b/bfd/elflink.c
@@ -8639,9 +8639,11 @@ elf_link_output_extsym (struct elf_link_hash_entry *h,
void *data)
     strip = FALSE;

   /* If we're stripping it, and it's not a dynamic symbol, there's
-     nothing else to do unless it is a forced local symbol.  */
+     nothing else to do unless it is a forced local symbol or a
+     STT_GNU_IFUNC symbol.  */
   if (strip
       && h->dynindx == -1
+      && h->type != STT_GNU_IFUNC
       && !h->forced_local)
     return TRUE;


I will submit one with a testcase.

--


http://sourceware.org/bugzilla/show_bug.cgi?id=10911

------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.


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

[Bug ld/10911] ld -s -static breaks IRELATIVE relocations

by Bugzilla from sourceware-bugzilla@sourceware.org :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


------- Additional Comments From hjl dot tools at gmail dot com  2009-11-09 00:33 -------
A patch is posted at:

http://sourceware.org/ml/binutils/2009-11/msg00146.html

--


http://sourceware.org/bugzilla/show_bug.cgi?id=10911

------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.


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

[Bug ld/10911] ld -s -static breaks IRELATIVE relocations

by Bugzilla from sourceware-bugzilla@sourceware.org :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


------- Additional Comments From cvs-commit at gcc dot gnu dot org  2009-11-09 14:37 -------
Subject: Bug 10911

CVSROOT: /cvs/src
Module name: src
Changes by: hjl@... 2009-11-09 14:37:16

Modified files:
        bfd            : ChangeLog elflink.c
        ld/testsuite   : ChangeLog
Added files:
        ld/testsuite/ld-ifunc: ifunc-4a-x86.d

Log message:
        Don't return on STT_GNU_IFUNC symbol when stripping.
       
        bfd/
       
        2009-11-09  H.J. Lu  <hongjiu.lu@...>
       
        PR ld/10911
        * elflink.c (elf_link_output_extsym): Don't return on
        STT_GNU_IFUNC symbol when stripping.
       
        ld/testsuite/
       
        2009-11-09  H.J. Lu  <hongjiu.lu@...>
       
        PR ld/10911
        * ld-ifunc/ifunc-4a-x86.d: New.

Patches:
http://sources.redhat.com/cgi-bin/cvsweb.cgi/src/bfd/ChangeLog.diff?cvsroot=src&r1=1.4831&r2=1.4832
http://sources.redhat.com/cgi-bin/cvsweb.cgi/src/bfd/elflink.c.diff?cvsroot=src&r1=1.359&r2=1.360
http://sources.redhat.com/cgi-bin/cvsweb.cgi/src/ld/testsuite/ChangeLog.diff?cvsroot=src&r1=1.1190&r2=1.1191
http://sources.redhat.com/cgi-bin/cvsweb.cgi/src/ld/testsuite/ld-ifunc/ifunc-4a-x86.d.diff?cvsroot=src&r1=NONE&r2=1.1



--


http://sourceware.org/bugzilla/show_bug.cgi?id=10911

------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.


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

[Bug ld/10911] ld -s -static breaks IRELATIVE relocations

by Bugzilla from sourceware-bugzilla@sourceware.org :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


------- Additional Comments From hjl dot tools at gmail dot com  2009-11-09 14:56 -------
Fixed.

--
           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |FIXED
            Version|unspecified                 |2.21 (HEAD)


http://sourceware.org/bugzilla/show_bug.cgi?id=10911

------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.


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