public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
* Initial DT_RELR support in bfd linker
@ 2022-01-03  5:26 H.J. Lu
  2022-01-05  4:44 ` Fangrui Song
  0 siblings, 1 reply; 2+ messages in thread
From: H.J. Lu @ 2022-01-03  5:26 UTC (permalink / raw)
  To: GNU C Library, Fangrui Song

Hi,

I created users/hjl/DT_RELR/master branch:

https://gitlab.com/x86-binutils/binutils-gdb/-/commits/users/hjl/DT_RELR/master

for initial DT_RELR support in bfd linker.   I added
a -z pack-relative-dyn-relocs option which also adds
GLIBC_ABI_VERSION_GEN2 dependency when
 -z pack-relative-dyn-relocs option is used to link
against glibc.

-- 
H.J.

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: Initial DT_RELR support in bfd linker
  2022-01-03  5:26 Initial DT_RELR support in bfd linker H.J. Lu
@ 2022-01-05  4:44 ` Fangrui Song
  0 siblings, 0 replies; 2+ messages in thread
From: Fangrui Song @ 2022-01-05  4:44 UTC (permalink / raw)
  To: H.J. Lu; +Cc: GNU C Library

On 2022-01-02, H.J. Lu wrote:
>Hi,
>
>I created users/hjl/DT_RELR/master branch:
>
>https://gitlab.com/x86-binutils/binutils-gdb/-/commits/users/hjl/DT_RELR/master
>
>for initial DT_RELR support in bfd linker.   I added
>a -z pack-relative-dyn-relocs option which also adds
>GLIBC_ABI_VERSION_GEN2 dependency when
> -z pack-relative-dyn-relocs option is used to link
>against glibc.

Thanks for working on this!

Non-glibc systems (musl, FreeBSD, NetBSD, etc) will definitely want a
version of -z pack-relative-dyn-relocs which does not require GLIBC_ABI_VERSION_GEN2 in .gnu.version_r.

I managed to test this with
https://sourceware.org/git/?p=glibc.git;a=shortlog;h=refs/heads/maskray/relr
by commenting out elf_link_add_packed_relative_dyn_reloc_dependency:

--- i/bfd/elflink.c
+++ w/bfd/elflink.c
@@ -2219,2 +2219,3 @@ _bfd_elf_export_symbol (struct elf_link_hash_entry *h, void *data)
  
+__attribute__((unused))
  static bool
@@ -7045,3 +7046,3 @@ bfd_elf_size_dynamic_sections (bfd *output_bfd,
         {
-         elf_link_add_packed_relative_dyn_reloc_dependency (&sinfo);
+         //elf_link_add_packed_relative_dyn_reloc_dependency (&sinfo);
           if (sinfo.failed)


A -DCMAKE_BUILD_TYPE=Release -DCMAKE_CXX_FLAGS=-fpie -DCMAKE_EXE_LINKER_FLAGS=-pie -DLLVM_ENABLE_PROJECTS=clang
Clang build crashes with -z pack-relative-dyn-relocs.
In llvm-readelf -r output, .rela.dyn has 277 R_X86_64_RELATIVE
relocations while .relr.dyn has 535577. This may be suspicious.
ld.lld --pack-dyn-relocs=relr places all relative relocations in .relr.dyn.

I am sure you know how to reproduce by yourself:)

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2022-01-05  4:44 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-01-03  5:26 Initial DT_RELR support in bfd linker H.J. Lu
2022-01-05  4:44 ` Fangrui Song

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).