From: Fangrui Song <maskray@google.com>
To: Florian Weimer <fweimer@redhat.com>
Cc: libc-alpha@sourceware.org
Subject: Re: [PATCH v3 2/2] Default to --with-default-link=no (bug 25812)
Date: Fri, 29 Apr 2022 00:43:49 -0700 [thread overview]
Message-ID: <20220429074349.gna53j7ujgqql4ux@google.com> (raw)
In-Reply-To: <87h76c74cb.fsf@oldenburg.str.redhat.com>
On 2022-04-29, Florian Weimer wrote:
>* Fangrui Song:
>
>>>How does lld place sections without a linker script? Purely based on
>>>names?
>>
>> It entirely uses code to describe the built-in rules like gold, while
>> GNU ld uses an internal linker script plus built-in code.
>> (some rules cannot be described by the linker script language and needs
>> code anyway).
>
>How can we make sure that certain sections are covered by RELRO, and
>still get start/stop symbols for them?
About __start_/__stop_:
__start_/__stop_ symbols are special. They don't need to be mentioned in a
linker script to take effects for lld and modern GNU ld. I haven't checked
whether there is an ancient GNU ld which requires symbol assignments when the
output section description is specified.
About RELRO:
It seems that there is no section name convention to make a section
RELRO. Having a SECTIONS command with DATA_SEGMENT_ALIGN /
DATA_SEGMENT_RELRO_END can specify all RELRO sections. I do not know a
simpler approach than postprocessing ld.bfd --verbose output.
To make GNU ld work, the following linker script is sufficient:
SECTIONS {
__libc_subfreeres : { *(__libc_subfreeres) }
__libc_atexit : { *(__libc_atexit) }
__libc_IO_vtables : { *(__libc_IO_vtables) }
} INSERT BEFORE .data.rel.ro;
This script does not work with ld.lld right now because there is an
`error: section ... is not contiguous with other relro sections` from
https://reviews.llvm.org/D40359 . I need to think whether the diagnostic
can be suppressed in some cases.
>>>> Besides, the position of .hash in --with-default-link=no seems weird.
>>>> 71213dc2589554dc8f8061e9b04e80c55d098b6a (2006-09) moved it to the end
>>>> of the RO segment.
>>>
>>>I think it's odd that we have an old-style hash table at all. Do we
>>>really need it? All tools should have migrated by now.
>>
>> We can remove .hash for non-mips architectures.
>
>We need the support in glibc for most architectures in the dynamic
>linker, but we don't have to build glibc with the legacy hash tables.
Agree
>> (I am a bit sad .MIPS.xhash support went in, but thankfully it doesn't take
>> too much code. The translation table could be solved in a better way. I
>> suspect the whole thing is unnecessary with RELR.)
>
>Huh? Aren't they unrelated?
>
`DT_MIPS_LOCAL_GOTNO` and `DT_MIPS_SYMTABNO-DT_MIPS_GOTSYM` can be
defined in a way that there is no special handling. Then there will be no
requirement on the .dynsym ordering. Then the regular DT_GNU_HASH can be
used, and DT_MIPS_XHASH will be unneeded.
`DT_MIPS_LOCAL_GOTNO` optimizes on top of relative relocations but with RELR
the additional benefit is very low.
>Thanks,
>Florian
>
next prev parent reply other threads:[~2022-04-29 7:43 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-04-11 15:32 [PATCH v3 1/2] scripts: Add glibcelf.py module Florian Weimer
2022-04-11 15:32 ` [PATCH v3 2/2] Default to --with-default-link=no (bug 25812) Florian Weimer
2022-04-22 6:12 ` Siddhesh Poyarekar
2022-04-22 6:35 ` Florian Weimer
2022-04-22 8:12 ` Siddhesh Poyarekar
2022-04-22 8:24 ` Florian Weimer
2022-04-22 8:32 ` Siddhesh Poyarekar
2022-04-22 8:34 ` Florian Weimer
2022-04-22 8:36 ` Siddhesh Poyarekar
2022-04-22 8:56 ` Andreas Schwab
2022-04-29 16:02 ` Dmitry V. Levin
2022-04-29 16:14 ` Florian Weimer
2022-04-29 20:48 ` Dmitry V. Levin
2022-04-28 7:25 ` Fangrui Song
2022-04-28 8:40 ` Florian Weimer
2022-04-29 6:00 ` Fangrui Song
2022-04-29 7:09 ` Florian Weimer
2022-04-29 7:43 ` Fangrui Song [this message]
2022-04-29 14:55 ` Florian Weimer
2022-04-29 19:26 ` Fangrui Song
2022-04-29 12:59 ` Adhemerval Zanella
2022-04-29 13:17 ` Florian Weimer
2022-04-29 13:55 ` Adhemerval Zanella
2022-04-29 14:03 ` Florian Weimer
2022-04-21 15:54 ` [PATCH v3 1/2] scripts: Add glibcelf.py module Siddhesh Poyarekar
2022-04-21 20:23 ` Florian Weimer
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=20220429074349.gna53j7ujgqql4ux@google.com \
--to=maskray@google.com \
--cc=fweimer@redhat.com \
--cc=libc-alpha@sourceware.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).