* [PATCH] Use $(DEFAULT-LDFLAGS-$(@F)) in +link-static-before-libc
@ 2017-10-03 22:48 H.J. Lu
2017-10-04 1:13 ` H.J. Lu
0 siblings, 1 reply; 5+ messages in thread
From: H.J. Lu @ 2017-10-03 22:48 UTC (permalink / raw)
To: GNU C Library
Use $(LDFLAGS-$(@F)) with tst-tls1-static-non-pie may not be sufficient
when static PIE is built by default. Use $(DEFAULT-LDFLAGS-$(@F)) in
+link-static-before-libc to make sure that tst-tls1-static-non-pie is
always built as non-PIE static executable.
Any comments?
H.J.
---
* Makeconfig (+link-static-before-libc): Use
$(DEFAULT-LDFLAGS-$(@F)).
* elf/Makefile (LDFLAGS-tst-tls1-static-non-pie): Renamed to ...
(DEFAULT-LDFLAGS-tst-tls1-static-non-pie): This.
---
Makeconfig | 1 +
elf/Makefile | 2 +-
2 files changed, 2 insertions(+), 1 deletion(-)
diff --git a/Makeconfig b/Makeconfig
index b51904b797..0ceff92a3d 100644
--- a/Makeconfig
+++ b/Makeconfig
@@ -435,6 +435,7 @@ endif
# Command for statically linking programs with the C library.
ifndef +link-static
+link-static-before-libc = $(CC) -nostdlib -nostartfiles -static -o $@ \
+ $(DEFAULT-LDFLAGS-$(@F)) \
$(sysdep-LDFLAGS) $(LDFLAGS) $(LDFLAGS-$(@F)) \
$(addprefix $(csu-objpfx),$(static-start-installed-name)) \
$(+preinit) $(+prectorT) \
diff --git a/elf/Makefile b/elf/Makefile
index c6edebd4ee..06e2e4cd08 100644
--- a/elf/Makefile
+++ b/elf/Makefile
@@ -152,7 +152,7 @@ tests-static-internal := tst-tls1-static tst-tls2-static \
tst-ptrguard1-static tst-stackguard1-static \
tst-tls1-static-non-pie
-LDFLAGS-tst-tls1-static-non-pie = $(no-pie-ldflag)
+DEFAULT-LDFLAGS-tst-tls1-static-non-pie = $(no-pie-ldflag)
tests := tst-tls9 tst-leaks1 \
tst-array1 tst-array2 tst-array3 tst-array4 tst-array5 \
--
2.13.6
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] Use $(DEFAULT-LDFLAGS-$(@F)) in +link-static-before-libc
2017-10-03 22:48 [PATCH] Use $(DEFAULT-LDFLAGS-$(@F)) in +link-static-before-libc H.J. Lu
@ 2017-10-04 1:13 ` H.J. Lu
2017-10-04 8:31 ` Andreas Schwab
0 siblings, 1 reply; 5+ messages in thread
From: H.J. Lu @ 2017-10-04 1:13 UTC (permalink / raw)
To: GNU C Library
[-- Attachment #1: Type: text/plain, Size: 1799 bytes --]
On 10/3/17, H.J. Lu <hjl.tools@gmail.com> wrote:
> Use $(LDFLAGS-$(@F)) with tst-tls1-static-non-pie may not be sufficient
> when static PIE is built by default. Use $(DEFAULT-LDFLAGS-$(@F)) in
> +link-static-before-libc to make sure that tst-tls1-static-non-pie is
> always built as non-PIE static executable.
>
> Any comments?
>
> H.J.
> ---
> * Makeconfig (+link-static-before-libc): Use
> $(DEFAULT-LDFLAGS-$(@F)).
> * elf/Makefile (LDFLAGS-tst-tls1-static-non-pie): Renamed to ...
> (DEFAULT-LDFLAGS-tst-tls1-static-non-pie): This.
> ---
> Makeconfig | 1 +
> elf/Makefile | 2 +-
> 2 files changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/Makeconfig b/Makeconfig
> index b51904b797..0ceff92a3d 100644
> --- a/Makeconfig
> +++ b/Makeconfig
> @@ -435,6 +435,7 @@ endif
> # Command for statically linking programs with the C library.
> ifndef +link-static
> +link-static-before-libc = $(CC) -nostdlib -nostartfiles -static -o $@ \
> + $(DEFAULT-LDFLAGS-$(@F)) \
> $(sysdep-LDFLAGS) $(LDFLAGS) $(LDFLAGS-$(@F)) \
> $(addprefix $(csu-objpfx),$(static-start-installed-name)) \
> $(+preinit) $(+prectorT) \
> diff --git a/elf/Makefile b/elf/Makefile
> index c6edebd4ee..06e2e4cd08 100644
> --- a/elf/Makefile
> +++ b/elf/Makefile
> @@ -152,7 +152,7 @@ tests-static-internal := tst-tls1-static tst-tls2-static
> \
> tst-ptrguard1-static tst-stackguard1-static \
> tst-tls1-static-non-pie
>
> -LDFLAGS-tst-tls1-static-non-pie = $(no-pie-ldflag)
> +DEFAULT-LDFLAGS-tst-tls1-static-non-pie = $(no-pie-ldflag)
>
> tests := tst-tls9 tst-leaks1 \
> tst-array1 tst-array2 tst-array3 tst-array4 tst-array5 \
Here is the updated patch to add
+CRT-tst-tls1-static-non-pie := $(csu-objpfx)crt1.o
so that crt1.o is always used.
--
H.J.
[-- Attachment #2: 0001-Use-DEFAULT-LDFLAGS-F-in-link-static-before-libc.patch --]
[-- Type: text/x-patch, Size: 1908 bytes --]
From a0b9dd6c93d349722f7266aac8e5f27686b8cbbe Mon Sep 17 00:00:00 2001
From: "H.J. Lu" <hjl.tools@gmail.com>
Date: Tue, 3 Oct 2017 15:02:19 -0700
Subject: [PATCH 01/14] Use $(DEFAULT-LDFLAGS-$(@F)) in
+link-static-before-libc
Use $(LDFLAGS-$(@F)) with tst-tls1-static-non-pie may not be sufficient
when static PIE is built by default. Use $(DEFAULT-LDFLAGS-$(@F)) in
+link-static-before-libc to make sure that tst-tls1-static-non-pie is
always built as non-PIE static executable and make sure that crt1.o is
used with tst-tls1-static-non-pie.
* Makeconfig (+link-static-before-libc): Use
$(DEFAULT-LDFLAGS-$(@F)).
* elf/Makefile (CRT-tst-tls1-static-non-pie): New.
(LDFLAGS-tst-tls1-static-non-pie): Renamed to ...
(DEFAULT-LDFLAGS-tst-tls1-static-non-pie): This.
---
Makeconfig | 1 +
elf/Makefile | 3 ++-
2 files changed, 3 insertions(+), 1 deletion(-)
diff --git a/Makeconfig b/Makeconfig
index b51904b797..0ceff92a3d 100644
--- a/Makeconfig
+++ b/Makeconfig
@@ -435,6 +435,7 @@ endif
# Command for statically linking programs with the C library.
ifndef +link-static
+link-static-before-libc = $(CC) -nostdlib -nostartfiles -static -o $@ \
+ $(DEFAULT-LDFLAGS-$(@F)) \
$(sysdep-LDFLAGS) $(LDFLAGS) $(LDFLAGS-$(@F)) \
$(addprefix $(csu-objpfx),$(static-start-installed-name)) \
$(+preinit) $(+prectorT) \
diff --git a/elf/Makefile b/elf/Makefile
index c6edebd4ee..d1c61a12ca 100644
--- a/elf/Makefile
+++ b/elf/Makefile
@@ -152,7 +152,8 @@ tests-static-internal := tst-tls1-static tst-tls2-static \
tst-ptrguard1-static tst-stackguard1-static \
tst-tls1-static-non-pie
-LDFLAGS-tst-tls1-static-non-pie = $(no-pie-ldflag)
+CRT-tst-tls1-static-non-pie := $(csu-objpfx)crt1.o
+DEFAULT-LDFLAGS-tst-tls1-static-non-pie = $(no-pie-ldflag)
tests := tst-tls9 tst-leaks1 \
tst-array1 tst-array2 tst-array3 tst-array4 tst-array5 \
--
2.13.6
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] Use $(DEFAULT-LDFLAGS-$(@F)) in +link-static-before-libc
2017-10-04 1:13 ` H.J. Lu
@ 2017-10-04 8:31 ` Andreas Schwab
2017-10-04 9:01 ` H.J. Lu
0 siblings, 1 reply; 5+ messages in thread
From: Andreas Schwab @ 2017-10-04 8:31 UTC (permalink / raw)
To: H.J. Lu; +Cc: GNU C Library
On Okt 03 2017, "H.J. Lu" <hjl.tools@gmail.com> wrote:
> Use $(LDFLAGS-$(@F)) with tst-tls1-static-non-pie may not be sufficient
> when static PIE is built by default.
Why is that not sufficient?
Andreas.
--
Andreas Schwab, SUSE Labs, schwab@suse.de
GPG Key fingerprint = 0196 BAD8 1CE9 1970 F4BE 1748 E4D4 88E3 0EEA B9D7
"And now for something completely different."
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] Use $(DEFAULT-LDFLAGS-$(@F)) in +link-static-before-libc
2017-10-04 8:31 ` Andreas Schwab
@ 2017-10-04 9:01 ` H.J. Lu
2017-10-05 0:13 ` H.J. Lu
0 siblings, 1 reply; 5+ messages in thread
From: H.J. Lu @ 2017-10-04 9:01 UTC (permalink / raw)
To: Andreas Schwab; +Cc: GNU C Library
On 10/4/17, Andreas Schwab <schwab@suse.de> wrote:
> On Okt 03 2017, "H.J. Lu" <hjl.tools@gmail.com> wrote:
>
>> Use $(LDFLAGS-$(@F)) with tst-tls1-static-non-pie may not be sufficient
>> when static PIE is built by default.
>
> Why is that not sufficient?
>
If GCC doesn't support -static-pie, -Wl,-pie -static is used to build static
executables by default. We need to override it by
$(firstword $(DEFAULT-LDFLAGS-$(@F)) $(default-pie-ldflag))
to avoid passing -Wl,-pie -static to GCC.
--
H.J.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] Use $(DEFAULT-LDFLAGS-$(@F)) in +link-static-before-libc
2017-10-04 9:01 ` H.J. Lu
@ 2017-10-05 0:13 ` H.J. Lu
0 siblings, 0 replies; 5+ messages in thread
From: H.J. Lu @ 2017-10-05 0:13 UTC (permalink / raw)
To: Andreas Schwab; +Cc: GNU C Library
On 10/4/17, H.J. Lu <hjl.tools@gmail.com> wrote:
> On 10/4/17, Andreas Schwab <schwab@suse.de> wrote:
>> On Okt 03 2017, "H.J. Lu" <hjl.tools@gmail.com> wrote:
>>
>>> Use $(LDFLAGS-$(@F)) with tst-tls1-static-non-pie may not be sufficient
>>> when static PIE is built by default.
>>
>> Why is that not sufficient?
>>
>
> If GCC doesn't support -static-pie, -Wl,-pie -static is used to build
> static
> executables by default. We need to override it by
>
> $(firstword $(DEFAULT-LDFLAGS-$(@F)) $(default-pie-ldflag))
>
> to avoid passing -Wl,-pie -static to GCC.
>
I will check it in shortly.
--
H.J.
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2017-10-05 0:13 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-10-03 22:48 [PATCH] Use $(DEFAULT-LDFLAGS-$(@F)) in +link-static-before-libc H.J. Lu
2017-10-04 1:13 ` H.J. Lu
2017-10-04 8:31 ` Andreas Schwab
2017-10-04 9:01 ` H.J. Lu
2017-10-05 0:13 ` H.J. Lu
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).