blob: b8840dd011351ca0ca6946f0426e495c8bd0c3a2 [file] [log] [blame]
Marek Behúnc1094982021-05-20 13:24:03 +02001#!/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
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);/'