mirror of
https://xff.cz/git/u-boot/
synced 2025-09-03 17:52:07 +02:00
binman: Add a function to read ELF symbols
In some cases we need to read symbols from U-Boot. At present we have a a few cases which does this via 'nm' and 'grep'. It is better to use objdump since that tells us the size of the symbols and also whether it is weak or not. Add a new module which reads ELF information from files. Update existing uses of 'nm' to use this module. Signed-off-by: Simon Glass <sjg@chromium.org>
This commit is contained in:
32
tools/binman/elf_test.py
Normal file
32
tools/binman/elf_test.py
Normal file
@@ -0,0 +1,32 @@
|
||||
#
|
||||
# Copyright (c) 2017 Google, Inc
|
||||
# Written by Simon Glass <sjg@chromium.org>
|
||||
#
|
||||
# SPDX-License-Identifier: GPL-2.0+
|
||||
#
|
||||
# Test for the elf module
|
||||
|
||||
import os
|
||||
import sys
|
||||
import unittest
|
||||
|
||||
import elf
|
||||
|
||||
binman_dir = os.path.dirname(os.path.realpath(sys.argv[0]))
|
||||
fname = os.path.join(binman_dir, 'test', 'u_boot_ucode_ptr')
|
||||
|
||||
class TestElf(unittest.TestCase):
|
||||
def testAllSymbols(self):
|
||||
syms = elf.GetSymbols(fname, [])
|
||||
self.assertIn('.ucode', syms)
|
||||
|
||||
def testRegexSymbols(self):
|
||||
syms = elf.GetSymbols(fname, ['ucode'])
|
||||
self.assertIn('.ucode', syms)
|
||||
syms = elf.GetSymbols(fname, ['missing'])
|
||||
self.assertNotIn('.ucode', syms)
|
||||
syms = elf.GetSymbols(fname, ['missing', 'ucode'])
|
||||
self.assertIn('.ucode', syms)
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
Reference in New Issue
Block a user