From: Fangrui Song <maskray@google.com>
To: Sam James <sam@gentoo.org>, Florian Weimer <fweimer@redhat.com>
Cc: libc-alpha@sourceware.org
Subject: Re: [PATCH] Makerules: Generate shlib.lds with -fuse-ld=bfd
Date: Mon, 7 Nov 2022 16:22:35 -0800 [thread overview]
Message-ID: <20221108002235.6hdp4uvm2twy76ei@google.com> (raw)
In-Reply-To: <96E39C71-C947-400A-B4BC-A07404C8BDDD@gentoo.org>
On 2022-11-08, Sam James wrote:
>
>
>> On 7 Nov 2022, at 08:31, Florian Weimer via Libc-alpha <libc-alpha@sourceware.org> wrote:
>>
>> * Fangrui Song:
>>
>>> lld does not dump a linker script with --verbose (it does not use a
>>> linker script driven design and lots of linker processing is not
>>> serializable as a linker script anyway). With the default
>>> --with-default-link=no build, $@T is empty and makes `test -s $@T` fail.
>>>
>>> Just dump the linker script with -fuse-ld=bfd. lld since 15
>>> (https://reviews.llvm.org/D124656) supports custom RELRO sections in the
>>> GNU ld dumped linker script.
>>> ---
>>> Makerules | 2 +-
>>> 1 file changed, 1 insertion(+), 1 deletion(-)
>>>
>>> diff --git a/Makerules b/Makerules
>>> index 09c0cf8357..2edc6ee4e1 100644
>>> --- a/Makerules
>>> +++ b/Makerules
>>> @@ -553,7 +553,7 @@ else
>>> # not for shared objects
>>> $(common-objpfx)shlib.lds: $(common-objpfx)config.make $(..)Makerules
>>> $(LINK.o) -shared -Wl,-O1 \
>>> - -nostdlib -nostartfiles \
>>> + -nostdlib -nostartfiles -fuse-ld=bfd \
>>> $(sysdep-LDFLAGS) $(rtld-LDFLAGS) $(LDFLAGS.so) \
>>> -Wl,--verbose 2>/dev/null | \
>>> sed > $@T \
>>
>> Would you please add the comment?
>>
>> I'm not sure if a configure check is required. We have a path towards
>> removal of the custom linker script; the vfprintf refactor I posted is a
>> first step.
>>
>
>That works for me.
>
>
Added comments...
From 00ee52ee0753a8d849c23d4e051f10aa8a4e2074 Mon Sep 17 00:00:00 2001
From: Fangrui Song <maskray@google.com>
Date: Mon, 7 Nov 2022 16:21:13 -0800
Subject: [PATCH] Makerules: Generate shlib.lds with -fuse-ld=bfd
lld does not dump a linker script with --verbose (it does not use a
linker script driven design and lots of linker processing is not
serializable as a linker script anyway). With the default
--with-default-link=no build, $@T is empty and makes `test -s $@T` fail.
Just dump the linker script with -fuse-ld=bfd. lld since 15
(https://reviews.llvm.org/D124656) supports custom RELRO sections in the
GNU ld dumped linker script.
---
Makerules | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/Makerules b/Makerules
index 09c0cf8357..ed6873a1a8 100644
--- a/Makerules
+++ b/Makerules
@@ -546,14 +546,16 @@ endef
ifeq (yes,$(use-default-link))
# If the linker is good enough, we can let it use its default linker script.
+# In the long term the custom linker script will be removed.
shlib-lds =
shlib-lds-flags =
else
# binutils only position loadable notes into the first page for binaries,
# not for shared objects
+# lld --verbose does not dump a linker script. Use -fuse-ld=bfd.
$(common-objpfx)shlib.lds: $(common-objpfx)config.make $(..)Makerules
$(LINK.o) -shared -Wl,-O1 \
- -nostdlib -nostartfiles \
+ -nostdlib -nostartfiles -fuse-ld=bfd \
$(sysdep-LDFLAGS) $(rtld-LDFLAGS) $(LDFLAGS.so) \
-Wl,--verbose 2>/dev/null | \
sed > $@T \
--
2.38.1.431.g37b22c650d-goog
next prev parent reply other threads:[~2022-11-08 0:22 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-11-06 18:17 Fangrui Song
2022-11-06 21:21 ` Sam James
2022-11-06 23:06 ` Fangrui Song
2022-11-06 23:12 ` Sam James
2022-11-06 23:15 ` Fangrui Song
2022-11-06 23:15 ` Sam James
2022-11-06 23:21 ` Fangrui Song
2022-11-07 8:31 ` Florian Weimer
2022-11-08 0:06 ` Sam James
2022-11-08 0:22 ` Fangrui Song [this message]
2022-11-08 0:29 ` Sam James
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=20221108002235.6hdp4uvm2twy76ei@google.com \
--to=maskray@google.com \
--cc=fweimer@redhat.com \
--cc=libc-alpha@sourceware.org \
--cc=sam@gentoo.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 read-only IMAP folder(s) and NNTP newsgroup(s).