Skip to content

Commit

Permalink
Makefile: use -z pack-relative-relocs
Browse files Browse the repository at this point in the history
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, replace --pack-dyn-relocs=relr with -z pack-relative-relocs,
which is supported since LLD 15.

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.

Link: ClangBuiltLinux#1057
Link: https://sourceware.org/git/?p=binutils-gdb.git;a=commit;h=a619b58721f0a03fd91c27670d3e4c2fb0d88f1e
Signed-off-by: Fangrui Song <maskray@google.com>
  • Loading branch information
MaskRay authored and intel-lab-lkp committed Mar 23, 2023
1 parent b26e7a4 commit 8f47a36
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 3 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -1113,7 +1113,7 @@ LDFLAGS_vmlinux += -X
endif

ifeq ($(CONFIG_RELR),y)
LDFLAGS_vmlinux += --pack-dyn-relocs=relr --use-android-relr-tags
LDFLAGS_vmlinux += -z pack-relative-relocs
endif

# We never want expected sections to be placed heuristically by the
Expand Down
3 changes: 1 addition & 2 deletions scripts/tools-support-relr.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@ trap "rm -f $tmp_file.o $tmp_file $tmp_file.bin" EXIT
cat << "END" | $CC -c -x c - -o $tmp_file.o >/dev/null 2>&1
void *p = &p;
END
$LD $tmp_file.o -shared -Bsymbolic --pack-dyn-relocs=relr \
--use-android-relr-tags -o $tmp_file
$LD $tmp_file.o -shared -Bsymbolic -z pack-relative-relocs -o $tmp_file

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

0 comments on commit 8f47a36

Please sign in to comment.