public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Rich Felker <dalias@libc.org>
To: Oleg Endo <oleg.endo@t-online.de>
Cc: gcc-patches@gcc.gnu.org
Subject: Re: [PATCH] SH FDPIC backend support
Date: Sat, 03 Oct 2015 19:12:00 -0000	[thread overview]
Message-ID: <20151003191216.GD8645@brightrain.aerifal.cx> (raw)
In-Reply-To: <20151002013017.GO8645@brightrain.aerifal.cx>

On Thu, Oct 01, 2015 at 09:30:17PM -0400, Rich Felker wrote:
> But trying the patch on vanilla GCC trunk without my usual J2 target
> setup revealed some additional issues I need to address. I'm getting
> ICE in the code that generates the libgcc bitshift calls, which
> weren't used on J2. This is my fault for failing to extend the changes
> made to other parts of sh.md to the patterns for the new shifts (the
> same ones that broke the kernel) and perhaps also some other things.
> I'm going to go back and review that code and get it done right before
> resubmitting the patch against trunk.

I found and fixed the problem, but I have a new concern: calls to the
new shift instructions are using the following address forms:

-mno-fdpic -fPIC:
	.long   __ashlsi3_r0@GOTOFF

-mfdpic:
	.long   __ashlsi3_r0-(.LPCS1+2)

Neither of these seems valid. Both assume __ashlsi3_r0 will be defined
in the same DSO, which is not true in general; shared libgcc_s.so
might be in use. In this case the call would need to go through the
PLT, which (for PIC or FDPIC) requires r12 to be loaded with the GOT
address. In the non-FDPIC case, r12 _happens_ to contain the GOT
address just because it was used as an addend to get the function
address from the @GOTOFF address, but this does not seem
safe/reliable. In the FDPIC case there's nothing to cause r12 to
contain the GOT address, and in fact if the function has already made
another function call (which uses and clobbers r12), no code is
generated to save and restore r12 for the libgcc call.

Calls to other functions lib libgcc (e.g. division) seem to work fine
and either go through the PLT or bypass it and load from the GOT
directly. It's only these new special-calling-convention ones that are
broken, and I can't figure out why...

Rich

  parent reply	other threads:[~2015-10-03 19:12 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-10-01 21:36 Rich Felker
2015-10-01 22:36 ` Oleg Endo
2015-10-01 23:39   ` Rich Felker
2015-10-02  1:30     ` Rich Felker
2015-10-02 13:51       ` Oleg Endo
2015-10-02 15:18         ` Rich Felker
2015-10-02 15:38           ` Oleg Endo
2015-10-04  1:12           ` Rich Felker
2015-10-02 21:58       ` Kaz Kojima
2015-10-03  4:50         ` Rich Felker
2015-10-03  8:18           ` Oleg Endo
2015-10-03 18:05             ` Rich Felker
2015-10-03 19:12       ` Rich Felker [this message]
2015-10-03 22:34         ` Rich Felker
2015-10-04  5:11           ` Oleg Endo
2015-10-05  2:16             ` Rich Felker
2015-10-05 11:53               ` Oleg Endo
2015-10-05  7:41             ` Kaz Kojima
2015-10-06  3:15   ` [PATCH v2] " Rich Felker
2015-10-06 12:39     ` Oleg Endo
2015-10-06 13:27       ` Kaz Kojima
2015-10-06 16:52       ` Rich Felker
2015-10-06 22:23         ` Oleg Endo
2015-10-06 23:37           ` Rich Felker
2015-10-07 13:57             ` Oleg Endo

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20151003191216.GD8645@brightrain.aerifal.cx \
    --to=dalias@libc.org \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=oleg.endo@t-online.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).