[ELF] Add -z pack-relative-relocs
authorFangrui Song <i@maskray.me>
Fri, 11 Mar 2022 03:54:20 +0000 (19:54 -0800)
committerFangrui Song <i@maskray.me>
Fri, 11 Mar 2022 03:54:21 +0000 (19:54 -0800)
commit4a8de2832a2a730f63b71bdf1c1b446285ec5b6f
tree7f9fbf7e7a8ddb1027fc14a6f624a84673549c56
parente970d2823cf2a666cb597bf06ff8e0d0b880d361
[ELF] Add -z pack-relative-relocs

GNU ld 2.38 added -z pack-relative-relocs which is similar to
--pack-dyn-relocs=relr but synthesizes the `GLIBC_ABI_DT_RELR` version
dependency if a shared object named `libc.so.*` has a `GLIBC_2.*` version
dependency.

This is used to implement the (as some glibc folks call) version lockout
mechanism. Add this option, because glibc does not want to support
--pack-dyn-relocs=relr which does not add `GLIBC_ABI_DT_RELR`.
See https://maskray.me/blog/2021-10-31-relative-relocations-and-relr for
detail.

Close https://github.com/llvm/llvm-project/issues/53775

Reviewed By: peter.smith

Differential Revision: https://reviews.llvm.org/D120701
lld/ELF/Config.h
lld/ELF/Driver.cpp
lld/ELF/SyntheticSections.cpp
lld/docs/ReleaseNotes.rst
lld/docs/ld.lld.1
lld/test/ELF/pack-dyn-relocs-glibc.s [new file with mode: 0644]