This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: openbsd gotoff workaround
- To: Marc dot Espie at liafa dot jussieu dot fr
- Subject: Re: openbsd gotoff workaround
- From: Richard Henderson <rth at redhat dot com>
- Date: Tue, 11 Sep 2001 13:12:42 -0700
- Cc: gcc-patches at gcc dot gnu dot org
- References: <877kv7dp67.fsf@kaka.blahonga.org> <Pine.LNX.4.33.0109101655330.16107-100000@host140.cambridge.redhat.com> <20010910184528.A10185@schutzenberger.liafa.jussieu.fr> <20010910181833.A11350@redhat.com> <20010911160931.A10748@schutzenberger.liafa.jussieu.fr>
On Tue, Sep 11, 2001 at 04:09:31PM +0200, Marc Espie wrote:
> (insn 17 14 18 (set (reg/v/f:SI 44)
> (plus:SI (reg:SI 3 ebx)
> (const:SI (unspec:SI[
> (const:SI (plus:SI (symbol_ref/v:SI ("primes.0"))
> (const_int 124 [0x7c])))
> ] 7)))) -1 (nil)
> (nil))
Fixed. I've built x86 linux with BOOT_CFLAGS='-O2 -fpic';
I'd expect it to work for you.
r~
Index: i386.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/i386/i386.c,v
retrieving revision 1.211.2.14
diff -c -p -d -r1.211.2.14 i386.c
*** i386.c 2001/08/06 21:26:24 1.211.2.14
--- i386.c 2001/09/11 20:09:43
*************** int ix86_align_loops;
*** 417,423 ****
--- 417,428 ----
/* Power of two alignment for non-loop jumps. */
int ix86_align_jumps;
+
+ /* Prefix built by ASM_GENERATE_INTERNAL_LABEL. */
+ static char internal_label_prefix[16];
+ static int internal_label_prefix_len;
+ static int local_symbolic_operand PARAMS ((rtx, enum machine_mode));
static void output_pic_addr_const PARAMS ((FILE *, rtx, int));
static void put_condition_code PARAMS ((enum rtx_code, enum machine_mode,
int, int, FILE *));
*************** override_options ()
*** 693,698 ****
--- 698,712 ----
on by -msse. */
if (TARGET_SSE)
target_flags |= MASK_MMX;
+
+ /* Figure out what ASM_GENERATE_INTERNAL_LABEL builds as a prefix. */
+ {
+ char *p;
+ ASM_GENERATE_INTERNAL_LABEL (internal_label_prefix, "LX", 0);
+ p = strchr (internal_label_prefix, 'X');
+ internal_label_prefix_len = p - internal_label_prefix;
+ *p = '\0';
+ }
}
/* A C statement (sans semicolon) to choose the order in which to
*************** pic_symbolic_operand (op, mode)
*** 1128,1133 ****
--- 1142,1181 ----
return 0;
}
+ /* Return true if OP is a symbolic operand that resolves locally. */
+
+ static int
+ local_symbolic_operand (op, mode)
+ rtx op;
+ enum machine_mode mode ATTRIBUTE_UNUSED;
+ {
+ if (GET_CODE (op) == LABEL_REF)
+ return 1;
+
+ if (GET_CODE (op) == CONST
+ && GET_CODE (XEXP (op, 0)) == PLUS
+ && GET_CODE (XEXP (XEXP (op, 0), 1)) == CONST_INT)
+ op = XEXP (XEXP (op, 0), 0);
+
+ if (GET_CODE (op) != SYMBOL_REF)
+ return 0;
+
+ /* These we've been told are local by varasm and encode_section_info
+ respectively. */
+ if (CONSTANT_POOL_ADDRESS_P (op) || SYMBOL_REF_FLAG (op))
+ return 1;
+
+ /* There is, however, a not insubstantial body of code in the rest of
+ the compiler that assumes it can just stick the results of
+ ASM_GENERATE_INTERNAL_LABEL in a symbol_ref and have done. */
+
+ if (strncmp (XSTR (op, 0), internal_label_prefix,
+ internal_label_prefix_len) == 0)
+ return 1;
+
+ return 0;
+ }
+
/* Test for a valid operand for a call instruction. Don't allow the
arg pointer register or virtual regs since they may decay into
reg + const, which the patterns can't handle. */
*************** legitimate_pic_address_disp_p (disp)
*** 2530,2544 ****
return 0;
/* Must be @GOT or @GOTOFF. */
! if (XINT (disp, 1) != 6
! && XINT (disp, 1) != 7)
! return 0;
!
! if (GET_CODE (XVECEXP (disp, 0, 0)) != SYMBOL_REF
! && GET_CODE (XVECEXP (disp, 0, 0)) != LABEL_REF)
! return 0;
! return 1;
}
/* GO_IF_LEGITIMATE_ADDRESS recognizes an RTL expression that is a valid
--- 2578,2593 ----
return 0;
/* Must be @GOT or @GOTOFF. */
! switch (XINT (disp, 1))
! {
! case 6: /* @GOT */
! return GET_CODE (XVECEXP (disp, 0, 0)) == SYMBOL_REF;
! case 7: /* @GOTOFF */
! return local_symbolic_operand (XVECEXP (disp, 0, 0), Pmode);
! }
!
! return 0;
}
/* GO_IF_LEGITIMATE_ADDRESS recognizes an RTL expression that is a valid
*************** legitimize_pic_address (orig, reg)
*** 2767,2776 ****
rtx new = orig;
rtx base;
! if (GET_CODE (addr) == LABEL_REF
! || (GET_CODE (addr) == SYMBOL_REF
! && (CONSTANT_POOL_ADDRESS_P (addr)
! || SYMBOL_REF_FLAG (addr))))
{
/* This symbol may be referenced via a displacement from the PIC
base address (@GOTOFF). */
--- 2816,2822 ----
rtx new = orig;
rtx base;
! if (local_symbolic_operand (addr, Pmode))
{
/* This symbol may be referenced via a displacement from the PIC
base address (@GOTOFF). */
*************** legitimize_pic_address (orig, reg)
*** 2822,2831 ****
/* Check first to see if this is a constant offset from a @GOTOFF
symbol reference. */
! if ((GET_CODE (op0) == LABEL_REF
! || (GET_CODE (op0) == SYMBOL_REF
! && (CONSTANT_POOL_ADDRESS_P (op0)
! || SYMBOL_REF_FLAG (op0))))
&& GET_CODE (op1) == CONST_INT)
{
current_function_uses_pic_offset_table = 1;
--- 2868,2874 ----
/* Check first to see if this is a constant offset from a @GOTOFF
symbol reference. */
! if (local_symbolic_operand (op0, Pmode)
&& GET_CODE (op1) == CONST_INT)
{
current_function_uses_pic_offset_table = 1;