linux-sh.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Mike Frysinger <vapier@gentoo.org>
To: linux-sh@vger.kernel.org
Subject: Re: SH FDPIC ABI spec/binutils and kernel conflict on flag definitions
Date: Wed, 30 Dec 2015 03:55:54 +0000	[thread overview]
Message-ID: <20151230035554.GU25803@vapier.lan> (raw)
In-Reply-To: <20150910033400.GM17773@brightrain.aerifal.cx>

[-- Attachment #1: Type: text/plain, Size: 2475 bytes --]

On 14 Sep 2015 12:09, Rich Felker wrote:
> On Thu, Sep 10, 2015 at 04:53:35PM +0100, David Howells wrote:
> > Rich Felker <dalias@libc.org> wrote:
> > > On the other hand, the only existing way to produce a binary that both
> > > (1) needs constant displacement, and (2) actually gets constant
> > > displacement from the kernel at load time, is to manually edit the ELF
> > > headers to flip the bit. So I really doubt any such binaries exist. Do
> > > you have a reason to believe they do?
> > 
> > Well, Fujitsu asked for it for FRV - I've no idea whether they have such
> > binaries still.
> 
> OK, I've solved part of the mystery: on FRV and Blackfin, binutils
> matches the kernel behavior and conflicts with the (effectively wrong)
> ABI documents. As can be seen at the following locations in the
> source, EF_$ARCH_PIC is cleared by default and set when there is a
> cross-segment relocation that forces constant displacement:
> 
> Blackfin:
> https://sourceware.org/git/?p=binutils-gdb.git;a=blob;f=bfd/elf32-bfin.c;h=152134ee7b9b445d96818fcab2350ffd11795897;hb=HEAD#l3140
> https://sourceware.org/git/?p=binutils-gdb.git;a=blob;f=bfd/elf32-bfin.c;h=152134ee7b9b445d96818fcab2350ffd11795897;hb=HEAD#l4978

it's a bit more complicated than that.  only one place does Blackfin
permit setting of EF_BFIN_PIC:
https://sourceware.org/git/?p=binutils-gdb.git;a=blob;f=bfd/elf32-bfin.c;h=152134ee7b9b445d96818fcab2350ffd11795897;hb=HEAD#l3140

and if you look before that, it has:
  if (!silence_segment_error && bfd_link_pic (info))
    return FALSE;

and those are defined as:
  int silence_segment_error = !bfd_link_pic (info);
  #define bfd_link_pic(info)  (bfd_link_dll (info) || bfd_link_pie (info))
  #define bfd_link_pie(info)  ((info)->type == type_pie)

all FDPIC ELFs must be PIE which means it's not possible to create a
Blackfin FDPIC ELF with EF_BFIN_PIC set.

off the top of my head, i don't recall seeing EF_BFIN_PIC being set
in Blackfin FDPIC ELFs.  it would show up when generating some FLAT
code w/-fpic, but that doesn't matter here.

> FRV:
> https://sourceware.org/git/?p=binutils-gdb.git;a=blob;f=bfd/elf32-frv.c;h=fa12528b3d11ab9ed7a4d5d894f8b9c1a5e783a9;hb=HEAD#l3919
> https://sourceware.org/git/?p=binutils-gdb.git;a=blob;f=bfd/elf32-frv.c;h=fa12528b3d11ab9ed7a4d5d894f8b9c1a5e783a9;hb=HEAD#l6367

the Blackfin code was copied from FRV, and the codepath i noted above
is the same for FRV.
-mike

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

      parent reply	other threads:[~2015-12-30  3:55 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-09-10  3:34 SH FDPIC ABI spec/binutils and kernel conflict on flag definitions Rich Felker
2015-09-10 11:57 ` Nick Clifton
2015-09-10 14:58 ` Rich Felker
2015-09-10 15:45 ` David Howells
2015-09-10 15:50 ` Rich Felker
2015-09-10 15:53 ` David Howells
2015-09-10 16:01 ` Rich Felker
2015-09-10 21:09 ` Rich Felker
2015-09-14 16:09 ` Rich Felker
2015-12-30  3:55 ` Mike Frysinger [this message]

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=20151230035554.GU25803@vapier.lan \
    --to=vapier@gentoo.org \
    --cc=linux-sh@vger.kernel.org \
    /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 NNTP newsgroup(s).