1*5cf896fbSPeter Collingbourne#!/bin/sh -eu 2*5cf896fbSPeter Collingbourne# SPDX-License-Identifier: GPL-2.0 3*5cf896fbSPeter Collingbourne 4*5cf896fbSPeter Collingbournetmp_file=$(mktemp) 5*5cf896fbSPeter Collingbournetrap "rm -f $tmp_file.o $tmp_file $tmp_file.bin" EXIT 6*5cf896fbSPeter Collingbourne 7*5cf896fbSPeter Collingbournecat << "END" | "$CC" -c -x c - -o $tmp_file.o >/dev/null 2>&1 8*5cf896fbSPeter Collingbournevoid *p = &p; 9*5cf896fbSPeter CollingbourneEND 10*5cf896fbSPeter Collingbourne"$LD" $tmp_file.o -shared -Bsymbolic --pack-dyn-relocs=relr -o $tmp_file 11*5cf896fbSPeter Collingbourne 12*5cf896fbSPeter Collingbourne# Despite printing an error message, GNU nm still exits with exit code 0 if it 13*5cf896fbSPeter Collingbourne# sees a relr section. So we need to check that nothing is printed to stderr. 14*5cf896fbSPeter Collingbournetest -z "$("$NM" $tmp_file 2>&1 >/dev/null)" 15*5cf896fbSPeter Collingbourne 16*5cf896fbSPeter Collingbourne"$OBJCOPY" -O binary $tmp_file $tmp_file.bin 17