xref: /openbmc/linux/scripts/tools-support-relr.sh (revision 65e1f38d9a2f07d4b81f369864c105880e47bd5a)
15cf896fbSPeter Collingbourne#!/bin/sh -eu
25cf896fbSPeter Collingbourne# SPDX-License-Identifier: GPL-2.0
35cf896fbSPeter Collingbourne
45cf896fbSPeter Collingbournetmp_file=$(mktemp)
55cf896fbSPeter Collingbournetrap "rm -f $tmp_file.o $tmp_file $tmp_file.bin" EXIT
65cf896fbSPeter Collingbourne
7*65e1f38dSIlie Halipcat << "END" | $CC -c -x c - -o $tmp_file.o >/dev/null 2>&1
85cf896fbSPeter Collingbournevoid *p = &p;
95cf896fbSPeter CollingbourneEND
10*65e1f38dSIlie Halip$LD $tmp_file.o -shared -Bsymbolic --pack-dyn-relocs=relr -o $tmp_file
115cf896fbSPeter Collingbourne
125cf896fbSPeter Collingbourne# Despite printing an error message, GNU nm still exits with exit code 0 if it
135cf896fbSPeter Collingbourne# sees a relr section. So we need to check that nothing is printed to stderr.
14*65e1f38dSIlie Haliptest -z "$($NM $tmp_file 2>&1 >/dev/null)"
155cf896fbSPeter Collingbourne
16*65e1f38dSIlie Halip$OBJCOPY -O binary $tmp_file $tmp_file.bin
17