core: fix gen_tee_bin.py to handle STB_LOCAL symbols
Prior to this patch scripts/gen_tee_bin.py only looked for global
symbols (STB_GLOBAL). The linker in some older versions of the gcc
toolchain makes some of the symbols local (STB_LOCAL) instead. This
patch fixes that by falling back to a local symbol in case a global
cannot be found.
Reviewed-by: Jerome Forissier <jerome@forissier.org>
Reported-by: Victor Chong <victor.chong@linaro.org>
Fixes: 3c51966baa03 ("core: add scripts/gen_tee_bin.py for boot binaries")
Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org>
diff --git a/scripts/gen_tee_bin.py b/scripts/gen_tee_bin.py
index 504d6b3..e4b4663 100755
--- a/scripts/gen_tee_bin.py
+++ b/scripts/gen_tee_bin.py
@@ -64,21 +64,33 @@
def get_symbol(elffile, name):
global elffile_symbols
+ global lsyms_def
if elffile_symbols is None:
elffile_symbols = dict()
+ lsyms_def = dict()
symbol_tables = [s for s in elffile.iter_sections()
if isinstance(s, SymbolTableSection)]
for section in symbol_tables:
for symbol in section.iter_symbols():
if symbol['st_info']['bind'] == 'STB_GLOBAL':
elffile_symbols[symbol.name] = symbol
+ elif symbol['st_info']['bind'] == 'STB_LOCAL':
+ if symbol.name not in elffile_symbols.keys():
+ elffile_symbols[symbol.name] = symbol
+ if symbol.name not in lsyms_def.keys():
+ lsyms_def[symbol.name] = 1
+ else:
+ lsyms_def[symbol.name] += 1
- try:
- return elffile_symbols[name]
- except (KeyError):
+ if name in lsyms_def.keys() and lsyms_def[name] > 1:
+ eprint("Multiple definitions of local symbol %s" % name)
+ sys.exit(1)
+ if name not in elffile_symbols.keys():
eprint("Cannot find symbol %s" % name)
sys.exit(1)
+ return elffile_symbols[name]
+
def get_sections(elffile, pad_to, dump_names):
last_end = 0