xref: /kernel/linux/linux-6.6/scripts/tools-support-relr.sh
  • Home
  • History
  • Annotate Annotate
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
  • only in /kernel/linux/linux-6.6/scripts/
162306a36Sopenharmony_ci#!/bin/sh -eu
262306a36Sopenharmony_ci# SPDX-License-Identifier: GPL-2.0
362306a36Sopenharmony_ci
462306a36Sopenharmony_citmp_file=$(mktemp)
562306a36Sopenharmony_citrap "rm -f $tmp_file.o $tmp_file $tmp_file.bin" EXIT
662306a36Sopenharmony_ci
762306a36Sopenharmony_cicat << "END" | $CC -c -x c - -o $tmp_file.o >/dev/null 2>&1
862306a36Sopenharmony_civoid *p = &p;
962306a36Sopenharmony_ciEND
1062306a36Sopenharmony_ci
1162306a36Sopenharmony_ci# ld.lld before 15 did not support -z pack-relative-relocs.
1262306a36Sopenharmony_ciif ! $LD $tmp_file.o -shared -Bsymbolic --pack-dyn-relocs=relr -o $tmp_file 2>/dev/null; then
1362306a36Sopenharmony_ci	$LD $tmp_file.o -shared -Bsymbolic -z pack-relative-relocs -o $tmp_file 2>&1 |
1462306a36Sopenharmony_ci		grep -q pack-relative-relocs && exit 1
1562306a36Sopenharmony_cifi
1662306a36Sopenharmony_ci
1762306a36Sopenharmony_ci# Despite printing an error message, GNU nm still exits with exit code 0 if it
1862306a36Sopenharmony_ci# sees a relr section. So we need to check that nothing is printed to stderr.
1962306a36Sopenharmony_citest -z "$($NM $tmp_file 2>&1 >/dev/null)"
2062306a36Sopenharmony_ci
2162306a36Sopenharmony_ci$OBJCOPY -O binary $tmp_file $tmp_file.bin
22

Indexes created Thu Nov 07 10:32:03 CST 2024