linux-raid.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Mariusz Tkaczyk <mariusz.tkaczyk@linux.intel.com>
To: Fabrice Fontaine <fontaine.fabrice@gmail.com>
Cc: linux-raid@vger.kernel.org, Jes Sorensen <jes@trained-monkey.org>
Subject: Re: [PATCH] Makefile: add USE_PIE
Date: Mon, 6 May 2024 16:56:44 +0200	[thread overview]
Message-ID: <20240506165644.000066aa@linux.intel.com> (raw)
In-Reply-To: <20240505133923.267977-1-fontaine.fabrice@gmail.com>

On Sun,  5 May 2024 15:39:23 +0200
Fabrice Fontaine <fontaine.fabrice@gmail.com> 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?

> 
> Signed-off-by: Fabrice Fontaine <fontaine.fabrice@gmail.com>
> ---
>  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?

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

  parent reply	other threads:[~2024-05-06 14:56 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-05-05 13:39 [PATCH] Makefile: add USE_PIE Fabrice Fontaine
2024-05-05 17:22 ` Paul Menzel
2024-05-05 17:38   ` Fabrice Fontaine
2024-05-05 17:51     ` Paul Menzel
2024-05-06 14:56 ` Mariusz Tkaczyk [this message]
2024-05-06 15:54   ` Fabrice Fontaine
2024-05-07  6:46     ` Mariusz Tkaczyk

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=20240506165644.000066aa@linux.intel.com \
    --to=mariusz.tkaczyk@linux.intel.com \
    --cc=fontaine.fabrice@gmail.com \
    --cc=jes@trained-monkey.org \
    --cc=linux-raid@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).