Skip to content

Commit ccb2d17

Browse files
MaskRaymasahir0y
authored andcommitted
Makefile: use -z pack-relative-relocs
Commit 27f2a4d ("Makefile: fix GDB warning with CONFIG_RELR") added --use-android-relr-tags to fix a GDB warning BFD: /android0/linux-next/vmlinux: unknown type [0x13] section `.relr.dyn' The GDB warning has been fixed in version 11.2. The DT_ANDROID_RELR tag was deprecated since DT_RELR was standardized. Thus, --use-android-relr-tags should be removed. While making the change, try -z pack-relative-relocs, which is supported since LLD 15. Keep supporting --pack-dyn-relocs=relr as well for older LLD versions. There is no indication of obsolescence for --pack-dyn-relocs=relr. As of today, GNU ld supports the latter option for x86 and powerpc64 ports and has no intention to support --pack-dyn-relocs=relr. In the absence of the glibc symbol version GLIBC_ABI_DT_RELR, --pack-dyn-relocs=relr and -z pack-relative-relocs are identical in ld.lld. GNU ld and newer versions of LLD report warnings (instead of errors) for unknown -z options. Only errors lead to non-zero exit codes. Therefore, we should test --pack-dyn-relocs=relr before testing -z pack-relative-relocs. Link: ClangBuiltLinux/linux#1057 Link: https://sourceware.org/git/?p=binutils-gdb.git;a=commit;h=a619b58721f0a03fd91c27670d3e4c2fb0d88f1e Signed-off-by: Fangrui Song <[email protected]> Reviewed-by: Nick Desaulniers <[email protected]> Acked-by: Will Deacon <[email protected]> Signed-off-by: Masahiro Yamada <[email protected]>
1 parent ddc72c9 commit ccb2d17

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

Makefile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1113,7 +1113,8 @@ LDFLAGS_vmlinux += -X
11131113
endif
11141114

11151115
ifeq ($(CONFIG_RELR),y)
1116-
LDFLAGS_vmlinux += --pack-dyn-relocs=relr --use-android-relr-tags
1116+
# ld.lld before 15 did not support -z pack-relative-relocs.
1117+
LDFLAGS_vmlinux += $(call ld-option,--pack-dyn-relocs=relr,-z pack-relative-relocs)
11171118
endif
11181119

11191120
# We never want expected sections to be placed heuristically by the

scripts/tools-support-relr.sh

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,12 @@ trap "rm -f $tmp_file.o $tmp_file $tmp_file.bin" EXIT
77
cat << "END" | $CC -c -x c - -o $tmp_file.o >/dev/null 2>&1
88
void *p = &p;
99
END
10-
$LD $tmp_file.o -shared -Bsymbolic --pack-dyn-relocs=relr \
11-
--use-android-relr-tags -o $tmp_file
10+
11+
# ld.lld before 15 did not support -z pack-relative-relocs.
12+
if ! $LD $tmp_file.o -shared -Bsymbolic --pack-dyn-relocs=relr -o $tmp_file 2>/dev/null; then
13+
$LD $tmp_file.o -shared -Bsymbolic -z pack-relative-relocs -o $tmp_file 2>&1 |
14+
grep -q pack-relative-relocs && exit 1
15+
fi
1216

1317
# Despite printing an error message, GNU nm still exits with exit code 0 if it
1418
# sees a relr section. So we need to check that nothing is printed to stderr.

0 commit comments

Comments
 (0)