This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[PATCH] Fix i386 PIC breakage
- To: rth at cygnus dot com, jh at suse dot cz
- Subject: [PATCH] Fix i386 PIC breakage
- From: Jakub Jelinek <jakub at redhat dot com>
- Date: Thu, 13 Jul 2000 11:48:19 +0200
- Cc: gcc-patches at gcc dot gnu dot org
- Reply-To: Jakub Jelinek <jakub at redhat dot com>
Hi!
Sat Jul 8 01:38:25 MET DST 2000 Jan Hubicka <jh@suse.cz>
* i386.md (call_pop, call, call_value_pop): Do not set
current_function_uses_pic_offset_table for calls to static
functions or indirect calls.
broke PIC support on i386.
E.g.
extern void bar(void);
extern void baz(void);
void foo(void)
{
bar();
baz();
}
gets miscompiled with -fpic - it does not compute %ebx prior to calling
functions @PLT.
Here is a fix.
I also changed the code so that it only checks for SYMBOL_REF_FLAG for
SYMBOL_REF, I don't know if other rtxs can make it into these expanders
(like LABEL_REF or CONST (PLUS (SYMBOL_REF CONST_INT)) and it is IMHO good
to play safe.
Ok to commit (provided bootstrap succeeds, will start it really soon)?
2000-07-13 Jakub Jelinek <jakub@redhat.com>
* config/i386/i386.md (call_pop): Check operands[0],
not operands[1]. Only check SYMBOL_REF_FLAG for a SYMBOL_REF.
(call): Likewise.
(call_value_pop): Only check SYMBOL_REF_FLAG for a SYMBOL_REF.
(call_value): Likewise.
--- gcc/config/i386/i386.md.jj Mon Jul 10 02:08:37 2000
+++ gcc/config/i386/i386.md Thu Jul 13 11:22:13 2000
@@ -8203,8 +8203,9 @@
/* Static functions and indirect calls don't need
current_function_uses_pic_offset_table. */
if (flag_pic
- && constant_call_address_operand (operands[1], SImode)
- && !SYMBOL_REF_FLAG (XEXP (operands[1], 0)))
+ && constant_call_address_operand (operands[0], SImode)
+ && (GET_CODE (XEXP (operands[0], 0)) != SYMBOL_REF
+ || !SYMBOL_REF_FLAG (XEXP (operands[0], 0))))
current_function_uses_pic_offset_table = 1;
if (! call_insn_operand (operands[0], QImode))
XEXP (operands[0], 0) = copy_to_mode_reg (Pmode, XEXP (operands[0], 0));
@@ -8258,8 +8259,9 @@
/* Static functions and indirect calls don't need
current_function_uses_pic_offset_table. */
if (flag_pic
- && constant_call_address_operand (operands[1], SImode)
- && !SYMBOL_REF_FLAG (XEXP (operands[1], 0)))
+ && constant_call_address_operand (operands[0], SImode)
+ && (GET_CODE (XEXP (operands[0], 0)) != SYMBOL_REF
+ || !SYMBOL_REF_FLAG (XEXP (operands[0], 0))))
current_function_uses_pic_offset_table = 1;
if (! call_insn_operand (operands[0], QImode))
XEXP (operands[0], 0) = copy_to_mode_reg (Pmode, XEXP (operands[0], 0));
@@ -8321,7 +8323,8 @@
current_function_uses_pic_offset_table. */
if (flag_pic
&& constant_call_address_operand (operands[1], SImode)
- && !SYMBOL_REF_FLAG (XEXP (operands[1], 0)))
+ && (GET_CODE (XEXP (operands[1], 0)) != SYMBOL_REF
+ || !SYMBOL_REF_FLAG (XEXP (operands[1], 0))))
current_function_uses_pic_offset_table = 1;
if (! call_insn_operand (operands[1], QImode))
XEXP (operands[1], 0) = copy_to_mode_reg (Pmode, XEXP (operands[1], 0));
@@ -8339,7 +8342,8 @@
current_function_uses_pic_offset_table. */
if (flag_pic
&& constant_call_address_operand (operands[1], SImode)
- && !SYMBOL_REF_FLAG (XEXP (operands[1], 0)))
+ && (GET_CODE (XEXP (operands[1], 0)) != SYMBOL_REF
+ || !SYMBOL_REF_FLAG (XEXP (operands[1], 0))))
current_function_uses_pic_offset_table = 1;
if (! call_insn_operand (operands[1], QImode))
XEXP (operands[1], 0) = copy_to_mode_reg (Pmode, XEXP (operands[1], 0));
Jakub