public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug target/49833] New: PIC doesn't work
@ 2011-07-25 1:49 hjl.tools at gmail dot com
2011-07-25 13:59 ` [Bug target/49833] [x32] " hjl.tools at gmail dot com
` (21 more replies)
0 siblings, 22 replies; 23+ messages in thread
From: hjl.tools at gmail dot com @ 2011-07-25 1:49 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49833
Summary: PIC doesn't work
Product: gcc
Version: 4.7.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: target
AssignedTo: unassigned@gcc.gnu.org
ReportedBy: hjl.tools@gmail.com
CC: ubizjak@gmail.com
Target: x32
[hjl@gnu-6 ilp32-6]$ cat l.i
static unsigned char foo[256];
arc4_init(void)
{
int n;
for (n = 0; n < 256; n++)
foo[n] = n;
}
[hjl@gnu-6 ilp32-6]$ make l.s
/export/build/gnu/gcc-x32/build-x86_64-linux/gcc/xgcc
-B/export/build/gnu/gcc-x32/build-x86_64-linux/gcc/ -S -o l.s -mx32 -O -fPIC
l.i
l.i: In function \u2018arc4_init\u2019:
l.i:9:1: error: unrecognizable insn:
(insn 66 48 50 3 (set (reg/f:DI 1 dx [104])
(zero_extend:DI (plus:SI (reg/v:SI 0 ax [orig:102 n ] [102])
(symbol_ref:SI ("foo") [flags 0x2] <var_decl 0x7fe54663e140
foo>)))) l.i:8 -1
(nil))
l.i:9:1: internal compiler error: in extract_insn, at recog.c:2115
Please submit a full bug report,
with preprocessed source if appropriate.
See <http://gcc.gnu.org/bugs.html> for instructions.
make: *** [l.s] Error 1
[hjl@gnu-6 ilp32-6]$
^ permalink raw reply [flat|nested] 23+ messages in thread
* [Bug target/49833] [x32] PIC doesn't work
2011-07-25 1:49 [Bug target/49833] New: PIC doesn't work hjl.tools at gmail dot com
@ 2011-07-25 13:59 ` hjl.tools at gmail dot com
2011-07-25 14:37 ` hjl.tools at gmail dot com
` (20 subsequent siblings)
21 siblings, 0 replies; 23+ messages in thread
From: hjl.tools at gmail dot com @ 2011-07-25 13:59 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49833
--- Comment #1 from H.J. Lu <hjl.tools at gmail dot com> 2011-07-25 13:59:10 UTC ---
X32 dynamic linker is miscompiled:
Program received signal SIGSEGV, Segmentation fault.
0x00114821 in elf_machine_rela_relative (reloc_addr_arg=<optimized out>,
l_addr=1114112, reloc=<optimized out>)
at ../sysdeps/x86_64/dl-machine.h:483
483 *reloc_addr = l_addr + reloc->r_addend;
(gdb) disass 0x00114808, 0x0011482c
Dump of assembler code from 0x114808 to 0x11482c:
0x00114808 <_dl_start+968>: lea (%rsi,%rdx,1),%edx
0x0011480b <_dl_start+971>: mov -0xc(%rdx),%edx
0x0011480e <_dl_start+974>: add %r13d,%edx
0x00114811 <_dl_start+977>: cmpb $0x8,0x4(%rax)
0x00114815 <_dl_start+981>: jne 0x114901 <_dl_start+1217>
0x0011481b <_dl_start+987>: mov 0x8(%rax),%ecx
0x0011481e <_dl_start+990>: add %r13d,%ecx
=> 0x00114821 <_dl_start+993>: mov %ecx,(%rdx)
0x00114823 <_dl_start+995>: lea 0xc(%rax),%edx
0x00114826 <_dl_start+998>: cmp %edx,%ebx
0x00114828 <_dl_start+1000>: mov %edx,%eax
0x0011482a <_dl_start+1002>: ja 0x114808 <_dl_start+968>
End of assembler dump.
(gdb) p/x $rdx
$1 = 0x111724
(gdb)
Working one:
The program being debugged has been started already.
Start it from the beginning? (y or n) y
Starting program: /export/build/gnu/glibc-x32/build-x86_64-linux/sunrpc/rpcgen
Breakpoint 1, elf_machine_rela_relative (reloc_addr_arg=<optimized out>,
l_addr=1114112, reloc=<optimized out>)
at ../sysdeps/x86_64/dl-machine.h:483
483 *reloc_addr = l_addr + reloc->r_addend;
(gdb) disass 0x00114768, 0x00114789
Dump of assembler code from 0x114768 to 0x114789:
0x00114768 <_dl_start+968>: add %esi,%edx
0x0011476a <_dl_start+970>: mov -0xc(%rdx),%edx
0x0011476d <_dl_start+973>: add %r13d,%edx
0x00114770 <_dl_start+976>: cmpb $0x8,0x4(%rax)
0x00114774 <_dl_start+980>: jne 0x114859 <_dl_start+1209>
=> 0x0011477a <_dl_start+986>: mov 0x8(%rax),%ecx
0x0011477d <_dl_start+989>: add %r13d,%ecx
0x00114780 <_dl_start+992>: mov %ecx,(%rdx)
0x00114782 <_dl_start+994>: lea 0xc(%rax),%edx
0x00114785 <_dl_start+997>: cmp %edx,%ebx
0x00114787 <_dl_start+999>: mov %edx,%eax
End of assembler dump.
(gdb) p/x $rdx
$3 = 0x32ed40
(gdb)
^ permalink raw reply [flat|nested] 23+ messages in thread
* [Bug target/49833] [x32] PIC doesn't work
2011-07-25 1:49 [Bug target/49833] New: PIC doesn't work hjl.tools at gmail dot com
2011-07-25 13:59 ` [Bug target/49833] [x32] " hjl.tools at gmail dot com
@ 2011-07-25 14:37 ` hjl.tools at gmail dot com
2011-07-25 14:52 ` ubizjak at gmail dot com
` (19 subsequent siblings)
21 siblings, 0 replies; 23+ messages in thread
From: hjl.tools at gmail dot com @ 2011-07-25 14:37 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49833
--- Comment #2 from H.J. Lu <hjl.tools at gmail dot com> 2011-07-25 14:36:23 UTC ---
The miscompiled function is
auto inline void
__attribute ((always_inline))
elf_machine_rela_relative (ElfW(Addr) l_addr, const ElfW(Rela) *reloc,
void *const reloc_addr_arg)
{
ElfW(Addr) *const reloc_addr = reloc_addr_arg;
assert (ELF32_R_TYPE (reloc->r_info) == R_X86_64_RELATIVE);
*reloc_addr = l_addr + reloc->r_addend;
}
^ permalink raw reply [flat|nested] 23+ messages in thread
* [Bug target/49833] [x32] PIC doesn't work
2011-07-25 1:49 [Bug target/49833] New: PIC doesn't work hjl.tools at gmail dot com
2011-07-25 13:59 ` [Bug target/49833] [x32] " hjl.tools at gmail dot com
2011-07-25 14:37 ` hjl.tools at gmail dot com
@ 2011-07-25 14:52 ` ubizjak at gmail dot com
2011-07-25 15:21 ` ubizjak at gmail dot com
` (18 subsequent siblings)
21 siblings, 0 replies; 23+ messages in thread
From: ubizjak at gmail dot com @ 2011-07-25 14:52 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49833
--- Comment #3 from Uros Bizjak <ubizjak at gmail dot com> 2011-07-25 14:52:12 UTC ---
(In reply to comment #2)
> The miscompiled function is
Er, not a testcase ...
^ permalink raw reply [flat|nested] 23+ messages in thread
* [Bug target/49833] [x32] PIC doesn't work
2011-07-25 1:49 [Bug target/49833] New: PIC doesn't work hjl.tools at gmail dot com
` (2 preceding siblings ...)
2011-07-25 14:52 ` ubizjak at gmail dot com
@ 2011-07-25 15:21 ` ubizjak at gmail dot com
2011-07-25 16:15 ` hjl.tools at gmail dot com
` (17 subsequent siblings)
21 siblings, 0 replies; 23+ messages in thread
From: ubizjak at gmail dot com @ 2011-07-25 15:21 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49833
--- Comment #4 from Uros Bizjak <ubizjak at gmail dot com> 2011-07-25 15:20:42 UTC ---
A shot-in-the-dark change:
(define_insn "*add<mode>_1"
[(set (match_operand:SWI48 0 "nonimmediate_operand" "=r,rm,r,r")
(plus:SWI48
(match_operand:SWI48 1 "nonimmediate_operand" "%0,0,r,r")
(match_operand:SWI48 2 "<add_operand>" "rme,re,0,le")))
(clobber (reg:CC FLAGS_REG))]
and
(define_insn "addsi_1_zext"
[(set (match_operand:DI 0 "register_operand" "=r,r,r")
(zero_extend:DI
(plus:SI (match_operand:SI 1 "nonimmediate_operand" "%0,r,r")
(match_operand:SI 2 "addsi_operand" "rme,0,le"))))
(clobber (reg:CC FLAGS_REG))]
The constraints of operand 2 now fully follow addsi_operand predicate.
^ permalink raw reply [flat|nested] 23+ messages in thread
* [Bug target/49833] [x32] PIC doesn't work
2011-07-25 1:49 [Bug target/49833] New: PIC doesn't work hjl.tools at gmail dot com
` (4 preceding siblings ...)
2011-07-25 16:15 ` hjl.tools at gmail dot com
@ 2011-07-25 16:15 ` hjl.tools at gmail dot com
2011-07-25 16:24 ` ubizjak at gmail dot com
` (15 subsequent siblings)
21 siblings, 0 replies; 23+ messages in thread
From: hjl.tools at gmail dot com @ 2011-07-25 16:15 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49833
--- Comment #5 from H.J. Lu <hjl.tools at gmail dot com> 2011-07-25 16:15:10 UTC ---
Created attachment 24831
--> http://gcc.gnu.org/bugzilla/attachment.cgi?id=24831
A testcase
elf/rtld.c in glibc is miscompiled by
-std=gnu99 -fgnu89-inline -O2 -fPIC
^ permalink raw reply [flat|nested] 23+ messages in thread
* [Bug target/49833] [x32] PIC doesn't work
2011-07-25 1:49 [Bug target/49833] New: PIC doesn't work hjl.tools at gmail dot com
` (3 preceding siblings ...)
2011-07-25 15:21 ` ubizjak at gmail dot com
@ 2011-07-25 16:15 ` hjl.tools at gmail dot com
2011-07-25 16:15 ` hjl.tools at gmail dot com
` (16 subsequent siblings)
21 siblings, 0 replies; 23+ messages in thread
From: hjl.tools at gmail dot com @ 2011-07-25 16:15 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49833
--- Comment #6 from H.J. Lu <hjl.tools at gmail dot com> 2011-07-25 16:15:31 UTC ---
(In reply to comment #4)
> A shot-in-the-dark change:
>
> (define_insn "*add<mode>_1"
> [(set (match_operand:SWI48 0 "nonimmediate_operand" "=r,rm,r,r")
> (plus:SWI48
> (match_operand:SWI48 1 "nonimmediate_operand" "%0,0,r,r")
> (match_operand:SWI48 2 "<add_operand>" "rme,re,0,le")))
> (clobber (reg:CC FLAGS_REG))]
>
> and
>
> (define_insn "addsi_1_zext"
> [(set (match_operand:DI 0 "register_operand" "=r,r,r")
> (zero_extend:DI
> (plus:SI (match_operand:SI 1 "nonimmediate_operand" "%0,r,r")
> (match_operand:SI 2 "addsi_operand" "rme,0,le"))))
> (clobber (reg:CC FLAGS_REG))]
>
> The constraints of operand 2 now fully follow addsi_operand predicate.
It doesn't work.
^ permalink raw reply [flat|nested] 23+ messages in thread
* [Bug target/49833] [x32] PIC doesn't work
2011-07-25 1:49 [Bug target/49833] New: PIC doesn't work hjl.tools at gmail dot com
` (5 preceding siblings ...)
2011-07-25 16:15 ` hjl.tools at gmail dot com
@ 2011-07-25 16:24 ` ubizjak at gmail dot com
2011-07-25 16:42 ` hjl.tools at gmail dot com
` (14 subsequent siblings)
21 siblings, 0 replies; 23+ messages in thread
From: ubizjak at gmail dot com @ 2011-07-25 16:24 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49833
--- Comment #7 from Uros Bizjak <ubizjak at gmail dot com> 2011-07-25 16:24:03 UTC ---
(In reply to comment #1)
> X32 dynamic linker is miscompiled:
BTW: These two functions look the same to me.
"lea (%rsi,%rdx,1),%edx" is the same as "add %esi,%edx".
Can you please post the values of %rsi and %rdx before the insn and %rdx and
%r13d after the insn?
The %rdx value you posted was from "mov -0xc(%rdx),%edx"
^ permalink raw reply [flat|nested] 23+ messages in thread
* [Bug target/49833] [x32] PIC doesn't work
2011-07-25 1:49 [Bug target/49833] New: PIC doesn't work hjl.tools at gmail dot com
` (6 preceding siblings ...)
2011-07-25 16:24 ` ubizjak at gmail dot com
@ 2011-07-25 16:42 ` hjl.tools at gmail dot com
2011-07-25 16:59 ` ubizjak at gmail dot com
` (13 subsequent siblings)
21 siblings, 0 replies; 23+ messages in thread
From: hjl.tools at gmail dot com @ 2011-07-25 16:42 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49833
--- Comment #8 from H.J. Lu <hjl.tools at gmail dot com> 2011-07-25 16:41:36 UTC ---
(In reply to comment #7)
> (In reply to comment #1)
> > X32 dynamic linker is miscompiled:
>
> BTW: These two functions look the same to me.
>
> "lea (%rsi,%rdx,1),%edx" is the same as "add %esi,%edx".
>
> Can you please post the values of %rsi and %rdx before the insn and %rdx and
> %r13d after the insn?
>
> The %rdx value you posted was from "mov -0xc(%rdx),%edx"
Working ld.so sets EDX properly with:
0x0011470a <+922>: lea (%rdx,%rdx,2),%edx
0x0011470d <+925>: lea (%rcx,%rdx,4),%eax
0x00114710 <+928>: cmp %eax,%ecx
0x00114712 <+930>: mov %eax,%ebx
0x00114714 <+932>: jae 0x11475b <_dl_start+1003>
0x00114716 <+934>: cmpb $0x8,0x4(%r8)
0x0011471b <+939>: mov (%r8),%edx
Bad ld.so sets EDX with
0x001147ca <+922>: lea (%rdx,%rdx,2),%eax
0x001147cd <+925>: lea (%rcx,%rax,4),%eax
0x001147d0 <+928>: cmp %eax,%ecx
0x001147d2 <+930>: mov %eax,%ebx
0x001147d4 <+932>: jae 0x11481c <_dl_start+1004>
0x001147d6 <+934>: cmpb $0x8,0x4(%r8)
0x001147db <+939>: mov (%r8),%eax
0x001147de <+942>: jne 0x1148f1 <_dl_start+1217>
0x001147e4 <+948>: lea 0xc(%r8),%esi
0x001147e8 <+952>: lea 0x0(%r13,%rax,1),%edx
^ permalink raw reply [flat|nested] 23+ messages in thread
* [Bug target/49833] [x32] PIC doesn't work
2011-07-25 1:49 [Bug target/49833] New: PIC doesn't work hjl.tools at gmail dot com
` (7 preceding siblings ...)
2011-07-25 16:42 ` hjl.tools at gmail dot com
@ 2011-07-25 16:59 ` ubizjak at gmail dot com
2011-07-25 18:04 ` hjl.tools at gmail dot com
` (12 subsequent siblings)
21 siblings, 0 replies; 23+ messages in thread
From: ubizjak at gmail dot com @ 2011-07-25 16:59 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49833
--- Comment #9 from Uros Bizjak <ubizjak at gmail dot com> 2011-07-25 16:58:49 UTC ---
(In reply to comment #8)
> Working ld.so sets EDX properly with:
Sorry, I need a testcase to debug this...
^ permalink raw reply [flat|nested] 23+ messages in thread
* [Bug target/49833] [x32] PIC doesn't work
2011-07-25 1:49 [Bug target/49833] New: PIC doesn't work hjl.tools at gmail dot com
` (8 preceding siblings ...)
2011-07-25 16:59 ` ubizjak at gmail dot com
@ 2011-07-25 18:04 ` hjl.tools at gmail dot com
2011-07-25 18:28 ` hjl.tools at gmail dot com
` (11 subsequent siblings)
21 siblings, 0 replies; 23+ messages in thread
From: hjl.tools at gmail dot com @ 2011-07-25 18:04 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49833
--- Comment #10 from H.J. Lu <hjl.tools at gmail dot com> 2011-07-25 18:03:51 UTC ---
(In reply to comment #5)
> Created attachment 24831 [details]
> A testcase
>
> elf/rtld.c in glibc is miscompiled by
>
> -std=gnu99 -fgnu89-inline -O2 -fPIC
GCC generates many relocations in .text section:
Relocation section '.rela.text' at offset 0x5e8 contains 15 entries:
Offset Info Type Sym.Value Sym. Name + Addend
00001714 00000008 R_X86_64_RELATIVE 00001150
00002557 00000008 R_X86_64_RELATIVE 0021f5f8
readelf -r elf/rtld.os
000005c4 0000ab0a R_X86_64_32 00000000 _start + 0
00001407 0000ae0a R_X86_64_32 00000000 _rtld_local + 5b8
0000141d 0000ae0a R_X86_64_32 00000000 _rtld_local + 5b8
00001d58 0000ae0a R_X86_64_32 00000000 _rtld_local + 5b8
00002e42 0000ae0a R_X86_64_32 00000000 _rtld_local + 5b8
^ permalink raw reply [flat|nested] 23+ messages in thread
* [Bug target/49833] [x32] PIC doesn't work
2011-07-25 1:49 [Bug target/49833] New: PIC doesn't work hjl.tools at gmail dot com
` (9 preceding siblings ...)
2011-07-25 18:04 ` hjl.tools at gmail dot com
@ 2011-07-25 18:28 ` hjl.tools at gmail dot com
2011-07-25 18:29 ` hjl.tools at gmail dot com
` (10 subsequent siblings)
21 siblings, 0 replies; 23+ messages in thread
From: hjl.tools at gmail dot com @ 2011-07-25 18:28 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49833
--- Comment #11 from H.J. Lu <hjl.tools at gmail dot com> 2011-07-25 18:28:22 UTC ---
[hjl@gnu-6 gcc]$ cat /tmp/foo.c
typedef unsigned int Elf32_Addr;
extern void _start (void) __attribute__ ((visibility ("hidden")));
int
dl_main ( Elf32_Addr *user_entry)
{
if (*user_entry == (Elf32_Addr) _start)
return 0;
else
return 1;
}
[hjl@gnu-6 gcc]$ ./xgcc -B./ -S -O2 -fPIC /tmp/foo.c -mx32 -std=gnu99 -dp
[hjl@gnu-6 gcc]$ cat foo.s
.file "foo.c"
.text
.p2align 4,,15
.globl dl_main
.type dl_main, @function
dl_main:
.LFB0:
.cfi_startproc
xorl %eax, %eax # 26 *movsi_xor [length = 2]
cmpl $_start, (%rdi) # 27 *cmpsi_1/1 [length = 6]
setne %al # 28 *setcc_qi_slp [length = 3]
ret # 24 return_internal [length = 1]
.cfi_endproc
.LFE0:
.size dl_main, .-dl_main
.hidden _start
.ident "GCC: (GNU) 4.7.0 20110725 (experimental)"
.section .note.GNU-stack,"",@progbits
[hjl@gnu-6 gcc]$
^ permalink raw reply [flat|nested] 23+ messages in thread
* [Bug target/49833] [x32] PIC doesn't work
2011-07-25 1:49 [Bug target/49833] New: PIC doesn't work hjl.tools at gmail dot com
` (10 preceding siblings ...)
2011-07-25 18:28 ` hjl.tools at gmail dot com
@ 2011-07-25 18:29 ` hjl.tools at gmail dot com
2011-07-25 19:19 ` pluto at agmk dot net
` (9 subsequent siblings)
21 siblings, 0 replies; 23+ messages in thread
From: hjl.tools at gmail dot com @ 2011-07-25 18:29 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49833
--- Comment #12 from H.J. Lu <hjl.tools at gmail dot com> 2011-07-25 18:29:08 UTC ---
Working x32 GCC generates:
[hjl@gnu-6 gcc]$ cat foo.s
.file "foo.c"
.text
.p2align 4,,15
.globl dl_main
.type dl_main, @function
dl_main:
.LFB0:
.cfi_startproc
leal _start(%rip), %eax # 6 *movsi_internal/1 [length = 6]
cmpl %eax, (%rdi) # 7 *cmpsi_1/1 [length = 2]
setne %al # 21 *setcc_qi [length = 3]
movzbl %al, %eax # 22 *zero_extendqisi2_movzbl [length = 3]
ret # 25 return_internal [length = 1]
.cfi_endproc
.LFE0:
.size dl_main, .-dl_main
.hidden _start
.ident "GCC: (GNU) 4.7.0 20110723 (experimental)"
.section .note.GNU-stack,"",@progbits
[hjl@gnu-6 gcc]$
^ permalink raw reply [flat|nested] 23+ messages in thread
* [Bug target/49833] [x32] PIC doesn't work
2011-07-25 1:49 [Bug target/49833] New: PIC doesn't work hjl.tools at gmail dot com
` (11 preceding siblings ...)
2011-07-25 18:29 ` hjl.tools at gmail dot com
@ 2011-07-25 19:19 ` pluto at agmk dot net
2011-07-25 19:40 ` hjl.tools at gmail dot com
` (8 subsequent siblings)
21 siblings, 0 replies; 23+ messages in thread
From: pluto at agmk dot net @ 2011-07-25 19:19 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49833
Pawel Sikora <pluto at agmk dot net> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |pluto at agmk dot net
--- Comment #13 from Pawel Sikora <pluto at agmk dot net> 2011-07-25 19:18:16 UTC ---
(In reply to comment #11)
> [hjl@gnu-6 gcc]$ cat /tmp/foo.c
> typedef unsigned int Elf32_Addr;
> extern void _start (void) __attribute__ ((visibility ("hidden")));
> int
> dl_main ( Elf32_Addr *user_entry)
> {
> if (*user_entry == (Elf32_Addr) _start)
> return 0;
> else
> return 1;
> }
PR32219 reincarnation?
^ permalink raw reply [flat|nested] 23+ messages in thread
* [Bug target/49833] [x32] PIC doesn't work
2011-07-25 1:49 [Bug target/49833] New: PIC doesn't work hjl.tools at gmail dot com
` (12 preceding siblings ...)
2011-07-25 19:19 ` pluto at agmk dot net
@ 2011-07-25 19:40 ` hjl.tools at gmail dot com
2011-07-25 19:52 ` ubizjak at gmail dot com
` (7 subsequent siblings)
21 siblings, 0 replies; 23+ messages in thread
From: hjl.tools at gmail dot com @ 2011-07-25 19:40 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49833
--- Comment #14 from H.J. Lu <hjl.tools at gmail dot com> 2011-07-25 19:39:27 UTC ---
Another problem:
[hjl@gnu-6 gcc]$ cat /tmp/bar.c
typedef unsigned int Elf32_Addr;
extern void _start (void);
int
dl_main ( Elf32_Addr *user_entry)
{
if (*user_entry == (Elf32_Addr) _start)
return 0;
else
return 1;
}
[hjl@gnu-6 gcc]$ ./xgcc -B./ -S -O2 -fPIC /tmp/bar.c -mx32 -std=gnu99 -dp
/tmp/bar.c: In function ‘dl_main’:
/tmp/bar.c:10:1: error: unrecognizable insn:
(insn 6 5 7 3 (set (reg:SI 67)
(symbol_ref:SI ("_start") [flags 0x41] <function_decl 0x7faad972ff00
_start>)) /tmp/bar.c:6 -1
(nil))
/tmp/bar.c:10:1: internal compiler error: in extract_insn, at recog.c:2115
Please submit a full bug report,
with preprocessed source if appropriate.
See <http://gcc.gnu.org/bugs.html> for instructions.
[hjl@gnu-6 gcc]$
^ permalink raw reply [flat|nested] 23+ messages in thread
* [Bug target/49833] [x32] PIC doesn't work
2011-07-25 1:49 [Bug target/49833] New: PIC doesn't work hjl.tools at gmail dot com
` (13 preceding siblings ...)
2011-07-25 19:40 ` hjl.tools at gmail dot com
@ 2011-07-25 19:52 ` ubizjak at gmail dot com
2011-07-25 19:59 ` hjl.tools at gmail dot com
` (6 subsequent siblings)
21 siblings, 0 replies; 23+ messages in thread
From: ubizjak at gmail dot com @ 2011-07-25 19:52 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49833
--- Comment #15 from Uros Bizjak <ubizjak at gmail dot com> 2011-07-25 19:51:52 UTC ---
(In reply to comment #14)
> Another problem:
> /tmp/bar.c:10:1: error: unrecognizable insn:
> (insn 6 5 7 3 (set (reg:SI 67)
> (symbol_ref:SI ("_start") [flags 0x41] <function_decl 0x7faad972ff00
> _start>)) /tmp/bar.c:6 -1
> (nil))
What does these flags mean?
^ permalink raw reply [flat|nested] 23+ messages in thread
* [Bug target/49833] [x32] PIC doesn't work
2011-07-25 1:49 [Bug target/49833] New: PIC doesn't work hjl.tools at gmail dot com
` (14 preceding siblings ...)
2011-07-25 19:52 ` ubizjak at gmail dot com
@ 2011-07-25 19:59 ` hjl.tools at gmail dot com
2011-07-25 20:01 ` hjl.tools at gmail dot com
` (5 subsequent siblings)
21 siblings, 0 replies; 23+ messages in thread
From: hjl.tools at gmail dot com @ 2011-07-25 19:59 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49833
--- Comment #16 from H.J. Lu <hjl.tools at gmail dot com> 2011-07-25 19:59:00 UTC ---
(In reply to comment #15)
> (In reply to comment #14)
> > Another problem:
>
> > /tmp/bar.c:10:1: error: unrecognizable insn:
> > (insn 6 5 7 3 (set (reg:SI 67)
> > (symbol_ref:SI ("_start") [flags 0x41] <function_decl 0x7faad972ff00
> > _start>)) /tmp/bar.c:6 -1
> > (nil))
>
> What does these flags mean?
SYMBOL_REF_FLAGS (in_rtx);
^ permalink raw reply [flat|nested] 23+ messages in thread
* [Bug target/49833] [x32] PIC doesn't work
2011-07-25 1:49 [Bug target/49833] New: PIC doesn't work hjl.tools at gmail dot com
` (15 preceding siblings ...)
2011-07-25 19:59 ` hjl.tools at gmail dot com
@ 2011-07-25 20:01 ` hjl.tools at gmail dot com
2011-07-25 20:11 ` hjl.tools at gmail dot com
` (4 subsequent siblings)
21 siblings, 0 replies; 23+ messages in thread
From: hjl.tools at gmail dot com @ 2011-07-25 20:01 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49833
--- Comment #17 from H.J. Lu <hjl.tools at gmail dot com> 2011-07-25 20:00:45 UTC ---
(In reply to comment #16)
> (In reply to comment #15)
> > (In reply to comment #14)
> > > Another problem:
> >
> > > /tmp/bar.c:10:1: error: unrecognizable insn:
> > > (insn 6 5 7 3 (set (reg:SI 67)
> > > (symbol_ref:SI ("_start") [flags 0x41] <function_decl 0x7faad972ff00
> > > _start>)) /tmp/bar.c:6 -1
> > > (nil))
> >
> > What does these flags mean?
>
> SYMBOL_REF_FLAGS (in_rtx);
/* Set if this symbol is a function. */
#define SYMBOL_FLAG_FUNCTION (1 << 0)
/* Set if this symbol is not defined in this translation unit. */
#define SYMBOL_FLAG_EXTERNAL (1 << 6)
^ permalink raw reply [flat|nested] 23+ messages in thread
* [Bug target/49833] [x32] PIC doesn't work
2011-07-25 1:49 [Bug target/49833] New: PIC doesn't work hjl.tools at gmail dot com
` (16 preceding siblings ...)
2011-07-25 20:01 ` hjl.tools at gmail dot com
@ 2011-07-25 20:11 ` hjl.tools at gmail dot com
2011-07-25 20:13 ` hjl.tools at gmail dot com
` (3 subsequent siblings)
21 siblings, 0 replies; 23+ messages in thread
From: hjl.tools at gmail dot com @ 2011-07-25 20:11 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49833
--- Comment #18 from H.J. Lu <hjl.tools at gmail dot com> 2011-07-25 20:10:27 UTC ---
(In reply to comment #14)
> Another problem:
>
> [hjl@gnu-6 gcc]$ cat /tmp/bar.c
> typedef unsigned int Elf32_Addr;
> extern void _start (void);
> int
> dl_main ( Elf32_Addr *user_entry)
> {
> if (*user_entry == (Elf32_Addr) _start)
> return 0;
> else
> return 1;
> }
> [hjl@gnu-6 gcc]$ ./xgcc -B./ -S -O2 -fPIC /tmp/bar.c -mx32 -std=gnu99 -dp
> /tmp/bar.c: In function ‘dl_main’:
> /tmp/bar.c:10:1: error: unrecognizable insn:
> (insn 6 5 7 3 (set (reg:SI 67)
> (symbol_ref:SI ("_start") [flags 0x41] <function_decl 0x7faad972ff00
> _start>)) /tmp/bar.c:6 -1
> (nil))
> /tmp/bar.c:10:1: internal compiler error: in extract_insn, at recog.c:2115
> Please submit a full bug report,
> with preprocessed source if appropriate.
> See <http://gcc.gnu.org/bugs.html> for instructions.
> [hjl@gnu-6 gcc]$
On x32 branch, I got
.file "bar.c"
.text
.p2align 4,,15
.globl dl_main
.type dl_main, @function
dl_main:
.LFB0:
.cfi_startproc
movl _start@GOTPCREL(%rip), %eax # 22 *movsi_internal/1 [length
= 6]
cmpl %eax, (%rdi) # 8 *cmpsi_1/1 [length = 2]
setne %al # 23 *setcc_qi [length = 3]
movzbl %al, %eax # 24 *zero_extendqisi2_movzbl [length = 3]
ret # 27 return_internal [length = 1]
.cfi_endproc
.LFE0:
.size dl_main, .-dl_main
.ident "GCC: (GNU) 4.7.0 20110723 (experimental)"
.section .note.GNU-stack,"",@progbits
^ permalink raw reply [flat|nested] 23+ messages in thread
* [Bug target/49833] [x32] PIC doesn't work
2011-07-25 1:49 [Bug target/49833] New: PIC doesn't work hjl.tools at gmail dot com
` (17 preceding siblings ...)
2011-07-25 20:11 ` hjl.tools at gmail dot com
@ 2011-07-25 20:13 ` hjl.tools at gmail dot com
2011-07-26 12:01 ` uros at gcc dot gnu.org
` (2 subsequent siblings)
21 siblings, 0 replies; 23+ messages in thread
From: hjl.tools at gmail dot com @ 2011-07-25 20:13 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49833
--- Comment #19 from H.J. Lu <hjl.tools at gmail dot com> 2011-07-25 20:13:13 UTC ---
(In reply to comment #18)
> (In reply to comment #14)
> > Another problem:
> >
> > [hjl@gnu-6 gcc]$ cat /tmp/bar.c
> > typedef unsigned int Elf32_Addr;
> > extern void _start (void);
> > int
> > dl_main ( Elf32_Addr *user_entry)
> > {
> > if (*user_entry == (Elf32_Addr) _start)
> > return 0;
> > else
> > return 1;
> > }
> > [hjl@gnu-6 gcc]$ ./xgcc -B./ -S -O2 -fPIC /tmp/bar.c -mx32 -std=gnu99 -dp
> > /tmp/bar.c: In function ‘dl_main’:
> > /tmp/bar.c:10:1: error: unrecognizable insn:
> > (insn 6 5 7 3 (set (reg:SI 67)
> > (symbol_ref:SI ("_start") [flags 0x41] <function_decl 0x7faad972ff00
> > _start>)) /tmp/bar.c:6 -1
> > (nil))
> > /tmp/bar.c:10:1: internal compiler error: in extract_insn, at recog.c:2115
> > Please submit a full bug report,
> > with preprocessed source if appropriate.
> > See <http://gcc.gnu.org/bugs.html> for instructions.
> > [hjl@gnu-6 gcc]$
>
> On x32 branch, I got
>
> .file "bar.c"
> .text
> .p2align 4,,15
> .globl dl_main
> .type dl_main, @function
> dl_main:
> .LFB0:
> .cfi_startproc
> movl _start@GOTPCREL(%rip), %eax # 22 *movsi_internal/1 [length
> = 6]
> cmpl %eax, (%rdi) # 8 *cmpsi_1/1 [length = 2]
> setne %al # 23 *setcc_qi [length = 3]
> movzbl %al, %eax # 24 *zero_extendqisi2_movzbl [length = 3]
> ret # 27 return_internal [length = 1]
> .cfi_endproc
> .LFE0:
> .size dl_main, .-dl_main
> .ident "GCC: (GNU) 4.7.0 20110723 (experimental)"
> .section .note.GNU-stack,"",@progbits
I have a patch for this.
^ permalink raw reply [flat|nested] 23+ messages in thread
* [Bug target/49833] [x32] PIC doesn't work
2011-07-25 1:49 [Bug target/49833] New: PIC doesn't work hjl.tools at gmail dot com
` (18 preceding siblings ...)
2011-07-25 20:13 ` hjl.tools at gmail dot com
@ 2011-07-26 12:01 ` uros at gcc dot gnu.org
2011-07-26 12:13 ` ubizjak at gmail dot com
2011-07-29 16:01 ` hjl at gcc dot gnu.org
21 siblings, 0 replies; 23+ messages in thread
From: uros at gcc dot gnu.org @ 2011-07-26 12:01 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49833
--- Comment #20 from uros at gcc dot gnu.org 2011-07-26 12:00:36 UTC ---
Author: uros
Date: Tue Jul 26 12:00:33 2011
New Revision: 176788
URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=176788
Log:
PR target/47381
PR target/49832
PR target/49833
* config/i386/i386.md (i): Change SImode attribute to "e".
(g): Change SImode attribute to "rme".
(di): Change SImode attribute to "nF".
(general_operand): Change SImode attribute to x86_64_general_operand.
(general_szext_operand): Change SImode attribute to
x86_64_szext_general_operand.
(immediate_operand): Change SImode attribute to
x86_64_immediate_operand.
(nonmemory_operand): Change SImode attribute to
x86_64_nonmemory_operand.
(*movdi_internal_rex64): Remove mode from pic_32bit_operand check.
(*movsi_internal): Ditto. Use "e" constraint in alternative 2.
(*lea_1): Use SWI48 mode iterator.
(*lea_1_zext): New insn pattern.
(testsi_ccno_1): Use x86_64_nonmemory_operand predicate for operand 2.
(*bt<mode>): Ditto.
(*add<mode>1): Use x86_64_general_operand predicate for operand 2.
Update operand constraints.
(addsi_1_zext): Ditto.
(*add<mode>2): Ditto.
(*addsi_3_zext): Ditto.
(*subsi_1_zext): Ditto.
(*subsi_2_zext): Ditto.
(*subsi_3_zext): Ditto.
(*addsi3_carry_zext): Ditto.
(*<plusminus_insn>si3_zext_cc_overflow): Ditto.
(*mulsi3_1_zext): Ditto.
(*andsi_1): Ditto.
(*andsi_1_zext): Ditto.
(*andsi_2_zext): Ditto.
(*<any_or:code>si_1_zext): Ditto.
(*<any_or:code>si_2_zext): Ditto.
(*test<mode>_1): Use <general_operand> predicate for operand 1.
(*and<mode>_2): Ditto.
(mov<mode>cc): Use <general_operand> predicate for operands 1 and 2.
(add->lea splitter): Check operand modes in insn constraint. Extend
operands less than SImode wide to SImode.
(add->lea zext splitter): Do not extend input operands to DImode.
(*lea_general_1): Handle only QImode and HImode operands.
(*lea_general_2): Ditto.
(*lea_general_3): Ditto.
(*lea_general_1_zext): Remove.
(*lea_general_2_zext): Ditto.
(*lea_general_3_zext): Ditto.
(*lea_general_4): Check operand modes in insn constraint. Extend
operands less than SImode wide to SImode.
(ashift->lea splitter): Ditto.
* config/i386/i386.c (ix86_print_operand_address): Print address
registers with 'q' modifier on 64bit targets.
* config/i386/predicates.md (pic_32bit_opreand): Define as special
predicate. Reject non-SI and non-DI modes.
Modified:
trunk/gcc/ChangeLog
trunk/gcc/config/i386/i386.c
trunk/gcc/config/i386/i386.md
trunk/gcc/config/i386/predicates.md
^ permalink raw reply [flat|nested] 23+ messages in thread
* [Bug target/49833] [x32] PIC doesn't work
2011-07-25 1:49 [Bug target/49833] New: PIC doesn't work hjl.tools at gmail dot com
` (19 preceding siblings ...)
2011-07-26 12:01 ` uros at gcc dot gnu.org
@ 2011-07-26 12:13 ` ubizjak at gmail dot com
2011-07-29 16:01 ` hjl at gcc dot gnu.org
21 siblings, 0 replies; 23+ messages in thread
From: ubizjak at gmail dot com @ 2011-07-26 12:13 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49833
Uros Bizjak <ubizjak at gmail dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |RESOLVED
URL| |http://gcc.gnu.org/ml/gcc-p
| |atches/2011-07/msg02249.htm
| |l
Resolution| |FIXED
Target Milestone|--- |4.7.0
--- Comment #21 from Uros Bizjak <ubizjak at gmail dot com> 2011-07-26 12:13:26 UTC ---
Fixed, please open new PR for external function symbol problem.
^ permalink raw reply [flat|nested] 23+ messages in thread
* [Bug target/49833] [x32] PIC doesn't work
2011-07-25 1:49 [Bug target/49833] New: PIC doesn't work hjl.tools at gmail dot com
` (20 preceding siblings ...)
2011-07-26 12:13 ` ubizjak at gmail dot com
@ 2011-07-29 16:01 ` hjl at gcc dot gnu.org
21 siblings, 0 replies; 23+ messages in thread
From: hjl at gcc dot gnu.org @ 2011-07-29 16:01 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49833
--- Comment #22 from hjl at gcc dot gnu.org <hjl at gcc dot gnu.org> 2011-07-29 16:00:48 UTC ---
Author: hjl
Date: Fri Jul 29 16:00:41 2011
New Revision: 176932
URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=176932
Log:
Rewrite x86 lea support for x32.
2011-07-26 Uros Bizjak <ubizjak@gmail.com>
H.J. Lu <hongjiu.lu@intel.com>
PR target/47381
PR target/49832
PR target/49833
* config/i386/i386.md (i): Change SImode attribute to "e".
(g): Change SImode attribute to "rme".
(di): Change SImode attribute to "nF".
(general_operand): Change SImode attribute to x86_64_general_operand.
(general_szext_operand): Change SImode attribute to
x86_64_szext_general_operand.
(immediate_operand): Change SImode attribute to
x86_64_immediate_operand.
(nonmemory_operand): Change SImode attribute to
x86_64_nonmemory_operand.
(*movdi_internal_rex64): Remove mode from pic_32bit_operand check.
(*movsi_internal): Ditto. Use "e" constraint in alternative 2.
(*lea_1): Use SWI48 mode iterator.
(*lea_1_zext): New insn pattern.
(testsi_ccno_1): Use x86_64_nonmemory_operand predicate for operand 2.
(*bt<mode>): Ditto.
(*add<mode>1): Use x86_64_general_operand predicate for operand 2.
Update operand constraints.
(addsi_1_zext): Ditto.
(*add<mode>2): Ditto.
(*addsi_3_zext): Ditto.
(*subsi_1_zext): Ditto.
(*subsi_2_zext): Ditto.
(*subsi_3_zext): Ditto.
(*addsi3_carry_zext): Ditto.
(*<plusminus_insn>si3_zext_cc_overflow): Ditto.
(*mulsi3_1_zext): Ditto.
(*andsi_1): Ditto.
(*andsi_1_zext): Ditto.
(*andsi_2_zext): Ditto.
(*<any_or:code>si_1_zext): Ditto.
(*<any_or:code>si_2_zext): Ditto.
(*test<mode>_1): Use <general_operand> predicate for operand 1.
(*and<mode>_2): Ditto.
(mov<mode>cc): Use <general_operand> predicate for operands 1 and 2.
(add->lea splitter): Check operand modes in insn constraint. Extend
operands less than SImode wide to SImode.
(add->lea zext splitter): Do not extend input operands to DImode.
(*lea_general_1): Handle only QImode and HImode operands.
(*lea_general_2): Ditto.
(*lea_general_3): Ditto.
(*lea_general_1_zext): Remove.
(*lea_general_2_zext): Ditto.
(*lea_general_3_zext): Ditto.
(*lea_general_4): Check operand modes in insn constraint. Extend
operands less than SImode wide to SImode.
(ashift->lea splitter): Ditto.
* config/i386/i386.c (ix86_print_operand_address): Print address
registers with 'q' modifier on 64bit targets.
* config/i386/predicates.md (pic_32bit_opreand): Define as special
predicate. Reject non-SI and non-DI modes.
Modified:
branches/x32/gcc/ChangeLog.x32
branches/x32/gcc/config/i386/i386.c
branches/x32/gcc/config/i386/i386.md
branches/x32/gcc/config/i386/predicates.md
^ permalink raw reply [flat|nested] 23+ messages in thread
end of thread, other threads:[~2011-07-29 16:01 UTC | newest]
Thread overview: 23+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-07-25 1:49 [Bug target/49833] New: PIC doesn't work hjl.tools at gmail dot com
2011-07-25 13:59 ` [Bug target/49833] [x32] " hjl.tools at gmail dot com
2011-07-25 14:37 ` hjl.tools at gmail dot com
2011-07-25 14:52 ` ubizjak at gmail dot com
2011-07-25 15:21 ` ubizjak at gmail dot com
2011-07-25 16:15 ` hjl.tools at gmail dot com
2011-07-25 16:15 ` hjl.tools at gmail dot com
2011-07-25 16:24 ` ubizjak at gmail dot com
2011-07-25 16:42 ` hjl.tools at gmail dot com
2011-07-25 16:59 ` ubizjak at gmail dot com
2011-07-25 18:04 ` hjl.tools at gmail dot com
2011-07-25 18:28 ` hjl.tools at gmail dot com
2011-07-25 18:29 ` hjl.tools at gmail dot com
2011-07-25 19:19 ` pluto at agmk dot net
2011-07-25 19:40 ` hjl.tools at gmail dot com
2011-07-25 19:52 ` ubizjak at gmail dot com
2011-07-25 19:59 ` hjl.tools at gmail dot com
2011-07-25 20:01 ` hjl.tools at gmail dot com
2011-07-25 20:11 ` hjl.tools at gmail dot com
2011-07-25 20:13 ` hjl.tools at gmail dot com
2011-07-26 12:01 ` uros at gcc dot gnu.org
2011-07-26 12:13 ` ubizjak at gmail dot com
2011-07-29 16:01 ` hjl at gcc dot gnu.org
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).