[Bug gas/10677] New: incorrect code generated with asm function pointers when compiled with -fPIC on x84_64
This problem only occurs on x86_64, not i686. Example code (a.c): #include extern void my_asm_func(void); asm(".text\n" \ "my_asm_func:\n" \ " mov 1234,%rax\n" \ " ret\n" \ ".previous\n"); int my_c_func() { return 1; } int main() { void *fred; fred=(void *)my_asm_func; printf("function = %p\n",fred); fred=(void *)my_c_func; printf("function = %p\n",fred); return 0; } if this is compiled with the line: gcc -c -g -o a.o a.c The assemble code for the two "fred=" function pointer assignments are correct: fred=(void *)my_asm_func; 1c: 48 c7 45 f8 00 00 00movq $0x0,-0x8(%rbp) 23: 00 fred=(void *)my_c_func; 37: 48 c7 45 f8 00 00 00movq $0x0,-0x8(%rbp) 3e: 00 as expected. However, when used with -fPIC: gcc -fPIC -c -g -o a.o a.c we get : fred=(void *)my_asm_func; 1c: 48 8b 05 dd ff ff ffmov-0x23(%rip),%rax# 0 23: 48 89 45 f8 mov%rax,-0x8(%rbp) fred=(void *)my_c_func; 3c: 48 8b 05 00 00 00 00mov0x0(%rip),%rax# 43 43: 48 89 45 f8 mov%rax,-0x8(%rbp) For some reason the asm function pointer has already been fixed up with a value, which is actually the location the of the function, but it will move the value at that address into rax, not the address itself. Looking at the intermediate .s file: movq my_asm_f...@gotpcrel(%rip), %rax movq my_c_f...@gotpcrel(%rip), %rax Both functions have the same fixup type (assuming that is the correct terminology). However, they produce different code. If I add a .global to the assembler then it works, however, I don't think that I should need to, and on i686 it works fine. I have reproduced this problem on gcc 4.3.2 and 4.4.1, both with binutils 2.19.1. I have only given objdump -S output for the relevant sections of code. If you require more information please let me know. This problem was actually found while compiling valgrind for a 64 bit x86 target machine. -- Summary: incorrect code generated with asm function pointers when compiled with -fPIC on x84_64 Product: binutils Version: 2.19 Status: NEW Severity: normal Priority: P2 Component: gas AssignedTo: unassigned at sources dot redhat dot com ReportedBy: scott dot sourceware dot 2009 at scottrix dot co dot uk CC: bug-binutils at gnu dot org http://sourceware.org/bugzilla/show_bug.cgi?id=10677 --- 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@gnu.org http://lists.gnu.org/mailman/listinfo/bug-binutils
[Bug binutils/10478] "File format not recognized" for some solaris libraries
--- Additional Comments From niki dot waibel at gmx dot net 2009-09-21 15:52 --- any idea related to this? it should be as easy to fix as for solaris/sparc ... -- http://sourceware.org/bugzilla/show_bug.cgi?id=10478 --- 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@gnu.org http://lists.gnu.org/mailman/listinfo/bug-binutils
[Bug ld/10681] New: [Regression] FAIL: ld-elf/eh6
On Linux/x86-64, as of Mon Sep 21 09:10:30 PDT 2009, I got regexp_diff match failure regexp "^ Augmentation data: 80 .* 1b$" line " Augmentation data: 90 26 00 20 00 00 00 00 00 1b" FAIL: ld-elf/eh6 -- Summary: [Regression] FAIL: ld-elf/eh6 Product: binutils Version: 2.21 (HEAD) Status: NEW Severity: normal Priority: P2 Component: ld AssignedTo: unassigned at sources dot redhat dot com ReportedBy: hjl dot tools at gmail dot com CC: bug-binutils at gnu dot org http://sourceware.org/bugzilla/show_bug.cgi?id=10681 --- 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@gnu.org http://lists.gnu.org/mailman/listinfo/bug-binutils
[Bug ld/10681] [Regression] FAIL: ld-elf/eh6
--- Additional Comments From hjl dot tools at gmail dot com 2009-09-21 16:15 --- It is caused by http://sourceware.org/ml/binutils-cvs/2009-09/msg00238.html -- What|Removed |Added CC||rsandifo at sourceware dot ||org http://sourceware.org/bugzilla/show_bug.cgi?id=10681 --- 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@gnu.org http://lists.gnu.org/mailman/listinfo/bug-binutils
[Bug ld/10681] [Regression] FAIL: ld-elf/eh6
--- Additional Comments From hjl dot tools at gmail dot com 2009-09-21 16:25 --- It also failed on Linux/ia32: regexp_diff match failure regexp "^ Augmentation data: 80 .* 1b$" line " Augmentation data: 90 1a 10 00 00 1b" FAIL: ld-elf/eh6 -- http://sourceware.org/bugzilla/show_bug.cgi?id=10681 --- 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@gnu.org http://lists.gnu.org/mailman/listinfo/bug-binutils
[Bug ld/10681] [Regression] FAIL: ld-elf/eh6
--- Additional Comments From cvs-commit at gcc dot gnu dot org 2009-09-21 19:12 --- Subject: Bug 10681 CVSROOT:/cvs/src Module name:src Changes by: rsand...@sourceware.org 2009-09-21 19:11:50 Modified files: ld/testsuite/ld-elf: eh6.d ld/testsuite : ChangeLog Log message: ld/testsuite/ PR ld/10681 * ld-elf/eh6.d: Expect absolute pointers in shared libraries to be converted into PC-relative form. Patches: http://sources.redhat.com/cgi-bin/cvsweb.cgi/src/ld/testsuite/ld-elf/eh6.d.diff?cvsroot=src&r1=1.2&r2=1.3 http://sources.redhat.com/cgi-bin/cvsweb.cgi/src/ld/testsuite/ChangeLog.diff?cvsroot=src&r1=1.1169&r2=1.1170 -- http://sourceware.org/bugzilla/show_bug.cgi?id=10681 --- 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@gnu.org http://lists.gnu.org/mailman/listinfo/bug-binutils