On Sat, 2 Jan 2016 00:30:58 -0700 Jeff Law <l...@redhat.com> wrote: > > That way gcc will be able to compile glibc's ld: PR/60465 > Egad. PIC on ia64 is a mess. I can kind of see what Richard was trying > to do, but ewww. I don't think it's worth the effort to deep dive into > the PIC support and make ia64 handle things like most other ports -- > it's a dead architecture so ISTM the easiest fix is the right fix. > > A few, relatively minor things.
> > diff --git a/gcc/config/ia64/ia64.c b/gcc/config/ia64/ia64.c > > index f48cebc..6ea5072 100644 > > --- a/gcc/config/ia64/ia64.c > > +++ b/gcc/config/ia64/ia64.c > > @@ -1105,6 +1105,8 @@ ia64_expand_load_address (rtx dest, rtx src) > > emit_insn (gen_load_fptr (dest, src)); > > else if (sdata_symbolic_operand (src, VOIDmode)) > > emit_insn (gen_load_gprel (dest, src)); > > + else if (local_symbolic_operand64 (src, VOIDmode)) > > + emit_insn (gen_load_gprel64 (dest, src)); > Comment here. Something like > > /* We want to use gprel rather than ltoff relocations for > local symbolic operands. */ Done. Hope not too wordy :) > > > > > +;; True if OP refers to a local symbol +any large offset). > ;; True if OP refers to a local symbol [+ any offset ] > > I haven't dug into the ia64 port (and I'm not planning to) to see if/how > it MINUS in symbolic expressions. It's been the source of problems in > various ports trough the years. > > Can you take the testcase from your post as well as the one from BZ60465 > comment #37 (from you) and add them to the testsuite? Added both tests. > Note you're not running the full testsuite, just a few dozen ia64 > specific tests, which will include your new tests. ANd you're not > rebuilding the whole compiler between those steps, just ia64.o and > relinking the compiler. So it ought to be reasonably fast. > > So to summarize, I think your patch needs the two trivial comment fixes > noted above, 2 testcases and the before/after results of running just > the ia64.exp tests. Repost with that and I'll get it into the tree. --- ia64-before.log 2016-01-02 11:20:21.000000000 +0000 +++ ia64-after.log 2016-01-02 11:22:37.000000000 +0000 @@ -1 +1 @@ -Test Run By slyfox on Sat Jan 2 11:19:38 2016 +Test Run By slyfox on Sat Jan 2 11:22:16 2016 @@ -26,2 +25,0 @@ -FAIL: gcc.target/ia64/pr60465-gprel64-c37.c scan-assembler-not @ltoffx -FAIL: gcc.target/ia64/pr60465-gprel64.c scan-assembler-not @ltoffx @@ -31,2 +29,2 @@ -# of expected passes 147 -# of unexpected failures 11 +# of expected passes 149 +# of unexpected failures 9 I did ran tests only on amd64 host thus the execution failure tests. Attached updated patch and test runs on a crosscompiler before and after the change. Now I'm building on real ia64 hardware as make bootstrap make -k check for both clean and patched trees. -- Sergei
From 04a34fd97cffae4f40e1c226489129f42f3ceb2a Mon Sep 17 00:00:00 2001 From: Sergei Trofimovich <siarh...@google.com> Date: Mon, 28 Dec 2015 17:33:43 +0000 Subject: [PATCH] ia64: don't use dynamic relocations for local symbols Tested on the following example: void * a[77] __attribute((visibility("hidden"))); void f(long o, void * v) { a[0x6ffffeff - o + 66] = v; } Before the patch generated code uses .GOT entry: addl r14 = @ltoffx(a#), r1 ld8.mov r14 = [r14], a# After the patch generated code uses static gprel relocation: movl r14 = @gprel(a#) add r14 = r1, r14 That way gcc will be able to compile glibc's ld: PR/60465 Bug: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=60465 Signed-off-by: Sergei Trofimovich <siarh...@google.com> --- gcc/config/ia64/ia64.c | 9 ++++++++ gcc/config/ia64/predicates.md | 26 +++++++++++++++++++++ .../gcc.target/ia64/pr60465-gprel64-c37.c | 10 ++++++++ gcc/testsuite/gcc.target/ia64/pr60465-gprel64.c | 27 ++++++++++++++++++++++ 4 files changed, 72 insertions(+) create mode 100644 gcc/testsuite/gcc.target/ia64/pr60465-gprel64-c37.c create mode 100644 gcc/testsuite/gcc.target/ia64/pr60465-gprel64.c diff --git a/gcc/config/ia64/ia64.c b/gcc/config/ia64/ia64.c index f48cebc..ccf2bec 100644 --- a/gcc/config/ia64/ia64.c +++ b/gcc/config/ia64/ia64.c @@ -1105,6 +1105,15 @@ ia64_expand_load_address (rtx dest, rtx src) emit_insn (gen_load_fptr (dest, src)); else if (sdata_symbolic_operand (src, VOIDmode)) emit_insn (gen_load_gprel (dest, src)); + else if (local_symbolic_operand64 (src, VOIDmode)) + { + /* We want to use @gprel rather than @ltoff relocations for local + symbols: + - @gprel does not require dynamic linker + - and does not use .sdata section + https://gcc.gnu.org/bugzilla/60465 */ + emit_insn (gen_load_gprel64 (dest, src)); + } else { HOST_WIDE_INT addend = 0; diff --git a/gcc/config/ia64/predicates.md b/gcc/config/ia64/predicates.md index 2aa7a78..1a461ed 100644 --- a/gcc/config/ia64/predicates.md +++ b/gcc/config/ia64/predicates.md @@ -97,6 +97,32 @@ } }) +;; True if OP refers to a local symbol [+any offset]. +;; To be encoded as: +;; movl % = @gprel(symbol+offset) +;; add % = %, gp +(define_predicate "local_symbolic_operand64" + (match_code "symbol_ref,const") +{ + switch (GET_CODE (op)) + { + case CONST: + op = XEXP (op, 0); + if (GET_CODE (op) != PLUS + || GET_CODE (XEXP (op, 0)) != SYMBOL_REF + || GET_CODE (XEXP (op, 1)) != CONST_INT) + return false; + op = XEXP (op, 0); + /* FALLTHRU */ + + case SYMBOL_REF: + return SYMBOL_REF_LOCAL_P (op); + + default: + gcc_unreachable (); + } +}) + ;; True if OP refers to a symbol in the small address area. (define_predicate "small_addr_symbolic_operand" (match_code "symbol_ref,const") diff --git a/gcc/testsuite/gcc.target/ia64/pr60465-gprel64-c37.c b/gcc/testsuite/gcc.target/ia64/pr60465-gprel64-c37.c new file mode 100644 index 0000000..a7e6809 --- /dev/null +++ b/gcc/testsuite/gcc.target/ia64/pr60465-gprel64-c37.c @@ -0,0 +1,10 @@ +/* { dg-do compile { target ia64-*-* } } */ +/* { dg-options "-O2 -fpic" } */ +/* { dg-final { scan-assembler-not "@ltoffx" } } */ + +/* A bit of https://bugzilla.redhat.com/show_bug.cgi?id=33354 + where many stores to static variables overflow .sdata */ + +static const char *s90; +void f() { s90 = "string 90"; } +const char * g() { return s90; } diff --git a/gcc/testsuite/gcc.target/ia64/pr60465-gprel64.c b/gcc/testsuite/gcc.target/ia64/pr60465-gprel64.c new file mode 100644 index 0000000..c00ecc9 --- /dev/null +++ b/gcc/testsuite/gcc.target/ia64/pr60465-gprel64.c @@ -0,0 +1,27 @@ +/* { dg-do compile { target ia64-*-* } } */ +/* { dg-options "-O2 -fpic" } */ +/* { dg-final { scan-assembler-not "@ltoffx" } } */ + +/* Test imitates early ld.so setup in glibc + where no dynamic relocations must be present. */ + +struct rtld_global +{ + long *p[77]; +}; + +struct rtld_global _rtld_local __attribute__ ((visibility ("hidden"), section (".sdata"))); + +static void __attribute__ ((unused, noinline)) +elf_get_dynamic_info (struct rtld_global * g, long * dyn) +{ + long **info = g->p; + + info[(0x6ffffeff - *dyn) + 66] = dyn; +} + +void __attribute__ ((unused, noinline)) +_dl_start (long * dyn) +{ + elf_get_dynamic_info(&_rtld_local, dyn); +} -- 2.6.4
Test Run By slyfox on Sat Jan 2 11:22:16 2016 Target is ia64-unknown-linux-gnu Host is x86_64-pc-linux-gnu === gcc tests === Schedule of variations: unix Running target unix Using /usr/share/dejagnu/baseboards/unix.exp as board description file for target. Using /usr/share/dejagnu/config/unix.exp as generic interface file for target. Using /home/slyfox/dev/git/gcc/gcc/testsuite/config/default.exp as tool-and-target-specific interface file. WARNING: Assuming target board is the local machine (which is probably wrong). You may need to set your DEJAGNU environment variable. Running /home/slyfox/dev/git/gcc/gcc/testsuite/gcc.target/ia64/ia64.exp ... FAIL: gcc.target/ia64/20030225-2.c execution test FAIL: gcc.target/ia64/20040303-1.c execution test FAIL: gcc.target/ia64/asm-1.c execution test FAIL: gcc.target/ia64/float80-1.c execution test FAIL: gcc.target/ia64/float80-2.c execution test FAIL: gcc.target/ia64/float80-varargs-1.c execution test FAIL: gcc.target/ia64/pr42542-1.c execution test FAIL: gcc.target/ia64/pr42542-2.c execution test FAIL: gcc.target/ia64/pr42542-3.c execution test === gcc Summary === # of expected passes 149 # of unexpected failures 9 # of unsupported tests 4 /home/slyfox/dev/git/gcc-ia64/gcc/xgcc version 6.0.0 20151228 (experimental) (GCC)
Test Run By slyfox on Sat Jan 2 11:19:38 2016 Target is ia64-unknown-linux-gnu Host is x86_64-pc-linux-gnu === gcc tests === Schedule of variations: unix Running target unix Using /usr/share/dejagnu/baseboards/unix.exp as board description file for target. Using /usr/share/dejagnu/config/unix.exp as generic interface file for target. Using /home/slyfox/dev/git/gcc/gcc/testsuite/config/default.exp as tool-and-target-specific interface file. WARNING: Assuming target board is the local machine (which is probably wrong). You may need to set your DEJAGNU environment variable. Running /home/slyfox/dev/git/gcc/gcc/testsuite/gcc.target/ia64/ia64.exp ... FAIL: gcc.target/ia64/20030225-2.c execution test FAIL: gcc.target/ia64/20040303-1.c execution test FAIL: gcc.target/ia64/asm-1.c execution test FAIL: gcc.target/ia64/float80-1.c execution test FAIL: gcc.target/ia64/float80-2.c execution test FAIL: gcc.target/ia64/float80-varargs-1.c execution test FAIL: gcc.target/ia64/pr42542-1.c execution test FAIL: gcc.target/ia64/pr42542-2.c execution test FAIL: gcc.target/ia64/pr42542-3.c execution test FAIL: gcc.target/ia64/pr60465-gprel64-c37.c scan-assembler-not @ltoffx FAIL: gcc.target/ia64/pr60465-gprel64.c scan-assembler-not @ltoffx === gcc Summary === # of expected passes 147 # of unexpected failures 11 # of unsupported tests 4 /home/slyfox/dev/git/gcc-ia64/gcc/xgcc version 6.0.0 20151228 (experimental) (GCC)
signature.asc
Description: PGP signature