linux-sh.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Nick Clifton <nickc@redhat.com>
To: linux-sh@vger.kernel.org
Subject: Re: SH FDPIC ABI spec/binutils and kernel conflict on flag definitions
Date: Thu, 10 Sep 2015 11:57:09 +0000	[thread overview]
Message-ID: <55F17015.8090207@redhat.com> (raw)
In-Reply-To: <20150910033400.GM17773@brightrain.aerifal.cx>

Hi Rich,

> In the ELF Header part of the SH FDPIC ABI document, it's stated that
> EF_SH_FDPIC|EF_SH_PIC means each LOAD segment can be independently
> positioned, while EF_SH_FDPIC by itself (without EF_SH_PIC) means the
> relative position of LOAD segments with respect to each other is fixed
> (like in normal ELF usage). This seems to match what binutils outputs.
>
> However the kernel contains the code (arch/sh/include/asm/elf.h):
>
> #define elf_check_const_displacement(x) ((x)->e_flags & EF_SH_PIC)
>
> and (fs/binfmt_elf_fdpic.c):
>
> 	if (elf_check_const_displacement(&exec_params.hdr))
> 		exec_params.flags |= ELF_FDPIC_FLAG_CONSTDISP;
>
> which does exactly the opposite: the presence of the EF_SH_PIC flag,
> rather than absence of it, causes the kernel to treat the binary as
> one requiring "constant displacement" between LOAD segments.
>
> If my analysis is correct, how should this be fixed? It seems to me
> the kernel is clearly wrong, but it might also be considered the de
> facto ABI.

I think that adopting the kernel's behaviour as correct would set a 
dangerous precedent.  A published ABI should be followed, and if the 
kernel does not implement it, then the kernel is wrong.

> Is there any way forward that allows fixing this bug (which
> defeats the whole purpose of FDPIC) without breaking existing usage?

Maybe a kernel tuning option ?  (I am not familiar with kernel 
development so maybe this idea is a non-starter).

> Or is there no existing usage to care about?

I could not say for sure, but I imagine that there must be at least some 
people who are using SH linux at the moment.

Cheers
   Nick


  reply	other threads:[~2015-09-10 11:57 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 [this message]
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

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=55F17015.8090207@redhat.com \
    --to=nickc@redhat.com \
    --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).