[ipxe-devel] [PATCH 1/1] [build] Fix no-PIE workaround for i386 builds
Christian Hesse
list at eworm.de
Fri Apr 24 17:23:18 UTC 2015
Michael Brown <mcb30 at ipxe.org> on Fri, 2015/04/24 17:41:
> On 08/04/15 09:13, Christian Hesse wrote:
> > diff --git a/src/arch/i386/Makefile b/src/arch/i386/Makefile
> > index 99f8753..897081b 100644
> > --- a/src/arch/i386/Makefile
> > +++ b/src/arch/i386/Makefile
> > @@ -75,8 +75,8 @@ CFLAGS += -Ui386
> > # output on stderr instead of checking the exit status.
> > #
> > ifeq ($(CCTYPE),gcc)
> > -PIE_TEST = [ -z "`$(CC) -fno-PIE -nopie -x c -c /dev/null -o /dev/null
> > 2>&1`" ] -PIE_FLAGS := $(shell $(PIE_TEST) && $(ECHO) '-fno-PIE -nopie')
> > +PIE_TEST = $(CC) -dM -E - < /dev/null | grep -q '__PIE__'
> > +PIE_FLAGS := $(shell $(PIE_TEST) && $(ECHO) '-fno-PIE')
> > WORKAROUND_CFLAGS += $(PIE_FLAGS)
> > endif
>
> The original fix (in http://git.ipxe.org/ipxe.git/commitdiff/fe61f6d)
> added both -fno-PIE and -nopie if it detected that the workaround was
> necessary: the -fno-PIE is for compilation and the -nopie is to instruct
> gcc to not pass "-pie" to the linker (i.e. not to default to -Wl,-pie).
>
> Since we (I think) always invoke the linker directly via $(LD), it's
> plausible that the -nopie was never needed. Is this the case? (I don't
> have any systems on which the workaround is necessary, so can't test
> this for myself.)
The problem is that gcc does not know the command option -nopie here:
% gcc -fno-PIE -nopie -x c -c /dev/null -o /dev/null
gcc: error: unrecognized command line option ‘-nopie’
% echo $?
1
So the check always fails and the workaround is never applied.
(I missed to update the comment, though...)
--
main(a){char*c=/* Schoene Gruesse */"B?IJj;MEH"
"CX:;",b;for(a/* Chris get my mail address: */=0;b=c[a++];)
putchar(b-1/(/* gcc -o sig sig.c && ./sig */b/42*2-3)*42);}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 473 bytes
Desc: OpenPGP digital signature
URL: <http://lists.ipxe.org/pipermail/ipxe-devel/attachments/20150424/9c05f133/attachment.sig>
More information about the ipxe-devel
mailing list