From: Rich Felker <dalias@libc.org>
To: Szabolcs Nagy <Szabolcs.Nagy@arm.com>
Cc: Stafford Horne <shorne@gmail.com>, nd <nd@arm.com>,
GCC patches <gcc-patches@gcc.gnu.org>,
Openrisc <openrisc@lists.librecores.org>,
Richard Henderson <rth@twiddle.net>, Jeff Law <law@redhat.com>,
Joseph Myers <joseph@codesourcery.com>,
Joel Sherrill <joel@rtems.org>,
Sebastian Huber <sebastian.huber@embedded-brains.de>
Subject: Re: [PATCH v3 3/3] or1k: gcc: initial support for openrisc
Date: Mon, 05 Nov 2018 15:10:00 -0000 [thread overview]
Message-ID: <20181105151022.GO5150@brightrain.aerifal.cx> (raw)
In-Reply-To: <74dd7edd-ea59-9fd6-6c9b-82ac34574897@arm.com>
On Mon, Nov 05, 2018 at 11:13:53AM +0000, Szabolcs Nagy wrote:
> On 04/11/18 09:05, Stafford Horne wrote:
> > On Mon, Oct 29, 2018 at 02:28:11PM +0000, Szabolcs Nagy wrote:
> >> On 27/10/18 05:37, Stafford Horne wrote:
> ...
> >>> +#undef LINK_SPEC
> >>> +#define LINK_SPEC "%{h*} \
> >>> + %{static:-Bstatic} \
> >>> + %{shared:-shared} \
> >>> + %{symbolic:-Bsymbolic} \
> >>> + %{!static: \
> >>> + %{rdynamic:-export-dynamic} \
> >>> + %{!shared:-dynamic-linker " GNU_USER_DYNAMIC_LINKER "}}"
> >>> +
> >>> +#endif /* GCC_OR1K_LINUX_H */
> >>
> >> note that because of the -static-pie mess each
> >> target needs a more complicated LINK_SPEC now.
> >
> > Hello,
> >
> > Does something like this look better?
> >
> > --- a/gcc/config/or1k/linux.h
> > +++ b/gcc/config/or1k/linux.h
> > @@ -37,8 +37,9 @@
> > %{static:-Bstatic} \
> > %{shared:-shared} \
> > %{symbolic:-Bsymbolic} \
> > - %{!static: \
> > + %{!static:%{!static-pie: \
> > %{rdynamic:-export-dynamic} \
> > - %{!shared:-dynamic-linker " GNU_USER_DYNAMIC_LINKER "}}"
> > + %{!shared:-dynamic-linker " GNU_USER_DYNAMIC_LINKER "}}} \
> > + %{static-pie:-Bstatic -pie --no-dynamic-linker -z text}"
> >
> > #endif /* GCC_OR1K_LINUX_H */
>
> looks ok.
>
> > I have tested this out with or1k-linux-musl, but I get some LD complaints i.e.
> >
> > .../or1k-linux-musl/bin/ld: .../or1k-linux-musl/lib/libc.a(exit.o): non-pic relocation against symbol __fini_array_end
> > .../or1k-linux-musl/bin/ld: .../or1k-linux-musl/lib/libc.a(exit.o): non-pic relocation against symbol __fini_array_start
> >
> > Those are some warnings we recently added to LD, perhaps I need to rebuild the
> > libc.a with PIE as well. I will try it out, but if anyone has some suggestions
> > that would be helpful.
>
> yes, musl does not build libc.a with pic by default,
> either use a gcc configured with --enable-default-pie
> or CC='gcc -fPIC' when building musl.
>
> after that -static-pie linking should work.
>
> (maybe musl should have an --enable-static-pie config
> option to make this simpler)
For practical purposes, if you want to use static pie, you need a
default-pie toolchain. This is because _every_ static lib you might
link needs to be built with -fPIE (or -fPIC), and ensuring that
happens on a package-by-package basis is largely impractical; at least
it's on the same order of magnitude of difficulty as other systems
integration/packaging tasks.
However from the musl side it might make sense to produce a libc_pic.a
as part of the build process. This would make it easy to replace
libc.a with libc_pic.a if desired, and could also be used as the basis
for linking libc.so and to allow production of a stripped-down libc.so
that only includes symbols a fixed set of binaries depend on. We could
discuss something like this on the musl list.
Rich
next prev parent reply other threads:[~2018-11-05 15:10 UTC|newest]
Thread overview: 35+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-10-27 6:03 [PATCH v3 0/3] OpenRISC port Stafford Horne
2018-10-27 9:34 ` [PATCH v3 1/3] or1k: libgcc: initial support for openrisc Stafford Horne
2018-10-28 3:19 ` Segher Boessenkool
2018-10-28 8:30 ` Stafford Horne
2018-10-28 9:16 ` Richard Henderson
2018-10-29 14:22 ` Stafford Horne
2018-10-27 10:31 ` [PATCH v3 3/3] or1k: gcc: " Stafford Horne
2018-10-28 12:38 ` Richard Henderson
2018-10-30 14:07 ` Stafford Horne
2018-10-30 17:06 ` Richard Henderson
2018-10-31 4:38 ` Stafford Horne
2018-10-28 14:13 ` Segher Boessenkool
2018-10-29 7:32 ` Stafford Horne
2018-10-29 8:16 ` Segher Boessenkool
2018-10-30 14:44 ` Stafford Horne
2018-10-30 17:21 ` Segher Boessenkool
2018-10-31 3:26 ` Stafford Horne
2018-10-31 15:04 ` Jeff Law
2018-10-29 7:49 ` Richard Henderson
2018-10-29 13:58 ` Stafford Horne
2018-10-29 18:07 ` Segher Boessenkool
2018-10-29 18:44 ` Richard Henderson
2018-10-30 12:49 ` Stafford Horne
2018-10-30 16:12 ` Segher Boessenkool
2018-10-29 15:02 ` Szabolcs Nagy
2018-11-04 9:05 ` Stafford Horne
2018-11-05 11:13 ` Szabolcs Nagy
2018-11-05 15:10 ` Rich Felker [this message]
2018-11-05 20:59 ` Stafford Horne
2018-11-05 20:52 ` Stafford Horne
2018-11-05 19:46 ` Richard Henderson
2018-11-05 20:16 ` Christophe Lyon
2018-10-27 11:00 ` [PATCH v3 2/3] or1k: testsuite: " Stafford Horne
2018-10-28 11:31 ` Richard Henderson
2018-10-28 12:21 ` [PATCH v3 0/3] OpenRISC port Richard Henderson
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=20181105151022.GO5150@brightrain.aerifal.cx \
--to=dalias@libc.org \
--cc=Szabolcs.Nagy@arm.com \
--cc=gcc-patches@gcc.gnu.org \
--cc=joel@rtems.org \
--cc=joseph@codesourcery.com \
--cc=law@redhat.com \
--cc=nd@arm.com \
--cc=openrisc@lists.librecores.org \
--cc=rth@twiddle.net \
--cc=sebastian.huber@embedded-brains.de \
--cc=shorne@gmail.com \
/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).