Message ID | 20150327170813.GO1746@tucnak.redhat.com |
---|---|
State | New |
Headers | show |
On Fri, Mar 27, 2015 at 6:08 PM, Jakub Jelinek <jakub@redhat.com> wrote: > For %rip addressing, we only can use disp32 and thus can add > constants to the symbol/label, but not a register etc., as > there is no instruction supporting (plus (symbol_ref) (reg)) > for PIC. > > Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk? OK for trunk and release branches. Thanks, Uros.
--- gcc/config/i386/i386.c.jj 2015-03-23 16:31:27.000000000 +0100 +++ gcc/config/i386/i386.c 2015-03-27 14:19:54.646117550 +0100 @@ -13881,6 +13881,12 @@ legitimize_pic_address (rtx orig, rtx re } else { + /* For %rip addressing, we have to use just disp32, not + base nor index. */ + if (TARGET_64BIT + && (GET_CODE (base) == SYMBOL_REF + || GET_CODE (base) == LABEL_REF)) + base = force_reg (mode, base); if (GET_CODE (new_rtx) == PLUS && CONSTANT_P (XEXP (new_rtx, 1))) { --- gcc/testsuite/gcc.c-torture/compile/pr65593.c.jj 2015-03-27 14:40:55.973767411 +0100 +++ gcc/testsuite/gcc.c-torture/compile/pr65593.c 2015-03-27 14:42:19.697417036 +0100 @@ -0,0 +1,4 @@ +/* PR target/65593 */ +/* { dg-additional-options "-fpie" { target pie } } */ + +#include "pr20928.c"