blob: d0864804aafba12454bf1241d5cbcdb94d0b05a4 [file] [log] [blame]
Marek Behúnc1094982021-05-20 13:24:03 +02001#!/bin/bash
2# SPDX-License-Identifier: GPL-2.0+
Marek Behún61143f72022-06-01 17:17:06 +02003# Copyright (C) 2020 Marek Behún <kabel@kernel.org>
Marek Behúnc1094982021-05-20 13:24:03 +02004
5# Generate __ADDRESSABLE(symbol) for every linker list entry symbol, so that LTO
6# does not optimize these symbols away
7
Patrick Delaunayff7852d2021-07-21 09:56:07 +02008# The expected parameter of this script is the command requested to have
9# the U-Boot symbols to parse, for example: $(NM) $(u-boot-main)
10
Marek Behúnc1094982021-05-20 13:24:03 +020011set -e
12
13echo '#include <common.h>'
Patrick Delaunayff7852d2021-07-21 09:56:07 +020014$@ 2>/dev/null | grep -oe '_u_boot_list_2_[a-zA-Z0-9_]*_2_[a-zA-Z0-9_]*' | \
Marek Behúnc1094982021-05-20 13:24:03 +020015 sort -u | sed -e 's/^\(.*\)/extern char \1[];\n__ADDRESSABLE(\1);/'