Re: [PATCH] Makefile: add USE_PIE

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Le lun. 6 mai 2024 à 16:56, Mariusz Tkaczyk
<mariusz.tkaczyk@xxxxxxxxxxxxxxx> a écrit :
>
> On Sun,  5 May 2024 15:39:23 +0200
> Fabrice Fontaine <fontaine.fabrice@xxxxxxxxx> wrote:
>
> > Do not hardcode -pie and allow the user to drop it (e.g. PIE could be
> > enabled or disabled by the buildsystem such as buildroot)
>
> What about -fPIE? It is in CWFLAGS but it is configurable.
> Do you specify you own set of CWFLAGS?

Yes, CWFLAGS is set to an empty value.

>
> >
> > Signed-off-by: Fabrice Fontaine <fontaine.fabrice@xxxxxxxxx>
> > ---
> >  Makefile | 6 +++++-
> >  1 file changed, 5 insertions(+), 1 deletion(-)
> >
> > diff --git a/Makefile b/Makefile
> > index 7c221a89..a5269687 100644
> > --- a/Makefile
> > +++ b/Makefile
> > @@ -137,7 +137,11 @@ LDFLAGS = -Wl,-z,now,-z,noexecstack
> >  # If you want a static binary, you might uncomment these
> >  # LDFLAGS += -static
> >  # STRIP = -s
> > -LDLIBS = -ldl -pie
> > +LDLIBS = -ldl
> > +USE_PIE = 1
> > +ifdef USE_PIE
> > +LDLIBS += -pie
> > +endif
> >
> >  # To explicitly disable libudev, set -DNO_LIBUDEV in CXFLAGS
> >  ifeq (, $(findstring -DNO_LIBUDEV,  $(CXFLAGS)))
>
> AFAIK -pie is not library specifier, it is a a gcc linking setting so having it
> in LDLIBS seems weird to me. What about making LDFLAGS configurable?

Sure, moving -pie to LDFLAGS and allowing the user to override it will
also work.

>
> diff --git a/Makefile b/Makefile
> index 7c221a891181..adac7905ab57 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -132,12 +132,12 @@ CFLAGS += -DUSE_PTHREADS
>  MON_LDFLAGS += -pthread
>  endif
>
> -LDFLAGS = -Wl,-z,now,-z,noexecstack
> +LDFLAGS ?= -pie -Wl,-z,now,-z,noexecstack
>
>  # If you want a static binary, you might uncomment these
>  # LDFLAGS += -static
>  # STRIP = -s
> -LDLIBS = -ldl -pie
> +LDLIBS = -ldl
>
> It works on my setup however I'm not deeply sure if it is correct.
> Let me know if it resolves your issue. I would prefer to give possibility to
> customize LDFLAGS rather than add ifdef to Makefile.
>
> Thanks,
> Mariusz

Best Regards,

Fabrice





[Index of Archives]     [Linux RAID Wiki]     [ATA RAID]     [Linux SCSI Target Infrastructure]     [Linux Block]     [Linux IDE]     [Linux SCSI]     [Linux Hams]     [Device Mapper]     [Device Mapper Cryptographics]     [Kernel]     [Linux Admin]     [Linux Net]     [GFS]     [RPM]     [git]     [Yosemite Forum]


  Powered by Linux