3978a39d9709d1d00416b74d734398302400e1ee
[platform/kernel/u-boot.git] / scripts / gen_ll_addressable_symbols.sh
1 #!/bin/bash
2 # SPDX-License-Identifier: GPL-2.0+
3 # Copyright (C) 2020 Marek BehĂșn <marek.behun@nic.cz>
4
5 # Generate __ADDRESSABLE(symbol) for every linker list entry symbol, so that LTO
6 # does not optimize these symbols away
7
8 set -e
9
10 echo '#include <common.h>'
11 $NM "$@" 2>/dev/null | grep -oe '_u_boot_list_2_[a-zA-Z0-9_]*_2_[a-zA-Z0-9_]*' | \
12         sort -u | sed -e 's/^\(.*\)/extern char \1[];\n__ADDRESSABLE(\1);/'