blob: 13f670ae0ef047febafe0194debcfcb65b7594d5 [file] [log] [blame]
Marek Behúnd72a3b72021-05-20 13:24:03 +02001#!/bin/bash
2# SPDX-License-Identifier: GPL-2.0+
Marek Behúnd63726e2022-06-01 17:17:06 +02003# Copyright (C) 2020 Marek Behún <kabel@kernel.org>
Marek Behúnd72a3b72021-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 Delaunay8210d0c2021-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únd72a3b72021-05-20 13:24:03 +020011set -e
12
Tom Rinidec7ea02024-05-20 13:35:03 -060013echo '#include <linux/compiler.h>'
Patrick Delaunay8210d0c2021-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únd72a3b72021-05-20 13:24:03 +020015 sort -u | sed -e 's/^\(.*\)/extern char \1[];\n__ADDRESSABLE(\1);/'