On Wed, Jan 31, 2018 at 07:58:31AM -0800, H.J. Lu wrote:
> On Wed, Jan 31, 2018 at 7:56 AM, H.J. Lu <hjl.to...@gmail.com> wrote:
> > On Wed, Jan 31, 2018 at 7:44 AM, Cory Fields <li...@coryfields.com> wrote:
> >> After looking at this for quite a while, I'm afraid I'm unsure how to 
> >> proceed.
> >>
> >> As of now, static and static-pie are mutually exclusive. So given the
> >> GNU_USER_TARGET_STARTFILE_SPEC you pasted
> >> earlier, "static" matches before "static-pie", causing the wrong start 
> >> files.
> >>
> >> It seems to me that the static-pie target complicates things more than
> >> matching against static+pie individually.
> >>
> >> If I convert -static + -pie to -static-pie, then "static" won't be
> >> matched in specs, where maybe it otherwise should. Same for -pie.
> >>
> >> Would you prefer to swallow -static and -pie and pass along only
> >> -static-pie? Or forward them all along, and fix the specs which look
> >
> > Yes.  When you see both -static and -pie. regardless of their relative
> > order on command-line, you
> >
> > 1. Remove -static and -pie.
> > 2. Add -static-pie.
> 
> This assumes that -static -pie and -pie -static do not produce the working
> executable.  If they do, you can't change them.

That assumption is correct. Historically, GCC's specs have suppressed
--dynamic-linker when -static is present. This means when ld sees
-pie, it picks a builtin, wrong default dynamic linker name like
"/lib64/ld.so.1" and stores it in the output PT_INTERP. Perhaps there
were/are some obscure platforms on which the default worked, but in
general it doesn't.

Presumably on glibc-based systems you could have made it work as
"dynamic linked pie but with no .so's" by adding your own
-Wl,-dynamic-linker option, but I don't think that was supported
usage.

Rich

Reply via email to