[PATCH 10/15] binman: Adjust naming for reading symbols
Simon Glass
sjg at chromium.org
Mon Aug 26 21:11:38 CEST 2024
These functions get the value of a symbol. The reference to ELF files
is confusing since they are reading the position/size of entries, not
ELF symbols. Rename the functions and adjust the comments also.
Signed-off-by: Simon Glass <sjg at chromium.org>
---
tools/binman/elf.py | 4 ++--
tools/binman/elf_test.py | 4 ++--
tools/binman/etype/section.py | 13 ++++++-------
tools/binman/image.py | 11 +++++------
tools/binman/image_test.py | 8 ++++----
5 files changed, 19 insertions(+), 21 deletions(-)
diff --git a/tools/binman/elf.py b/tools/binman/elf.py
index a4694056391..1c3b1e225f4 100644
--- a/tools/binman/elf.py
+++ b/tools/binman/elf.py
@@ -301,8 +301,8 @@ def LookupAndWriteSymbols(elf_fname, entry, section, is_elf=False,
value = BINMAN_SYM_MAGIC_VALUE
else:
# Look up the symbol in our entry tables.
- value = section.GetImage().LookupImageSymbol(name, sym.weak,
- msg, base_addr)
+ value = section.GetImage().GetImageSymbolValue(name, sym.weak,
+ msg, base_addr)
if value is None:
value = -1
pack_string = pack_string.lower()
diff --git a/tools/binman/elf_test.py b/tools/binman/elf_test.py
index b64134123c1..2f22639dffc 100644
--- a/tools/binman/elf_test.py
+++ b/tools/binman/elf_test.py
@@ -37,7 +37,7 @@ class FakeSection:
"""A fake Section object, used for testing
This has the minimum feature set needed to support testing elf functions.
- A LookupSymbol() function is provided which returns a fake value for amu
+ A GetSymbolValue() function is provided which returns a fake value for any
symbol requested.
"""
def __init__(self, sym_value=1):
@@ -46,7 +46,7 @@ class FakeSection:
def GetPath(self):
return 'section_path'
- def LookupImageSymbol(self, name, weak, msg, base_addr):
+ def GetImageSymbolValue(self, name, weak, msg, base_addr):
"""Fake implementation which returns the same value for all symbols"""
return self.sym_value
diff --git a/tools/binman/etype/section.py b/tools/binman/etype/section.py
index 30c1041c7e8..6c181531b8b 100644
--- a/tools/binman/etype/section.py
+++ b/tools/binman/etype/section.py
@@ -563,13 +563,13 @@ class Entry_section(Entry):
return entry.GetData(required)
def LookupEntry(self, entries, sym_name, msg):
- """Look up the entry for an ENF symbol
+ """Look up the entry for a binman symbol
Args:
entries (dict): entries to search:
key: entry name
value: Entry object
- sym_name: Symbol name in the ELF file to look up in the format
+ sym_name: Symbol name to look up in the format
_binman_<entry>_prop_<property> where <entry> is the name of
the entry and <property> is the property to find (e.g.
_binman_u_boot_prop_offset). As a special case, you can append
@@ -606,11 +606,10 @@ class Entry_section(Entry):
entry = entries[name]
return entry, entry_name, prop_name
- def LookupSymbol(self, sym_name, optional, msg, base_addr, entries=None):
- """Look up a symbol in an ELF file
+ def GetSymbolValue(self, sym_name, optional, msg, base_addr, entries=None):
+ """Get the value of a Binman symbol
- Looks up a symbol in an ELF file. Only entry types which come from an
- ELF image can be used by this function.
+ Look up a Binman symbol and obtain its value.
At present the only entry properties supported are:
offset
@@ -618,7 +617,7 @@ class Entry_section(Entry):
size
Args:
- sym_name: Symbol name in the ELF file to look up in the format
+ sym_name: Symbol name to look up in the format
_binman_<entry>_prop_<property> where <entry> is the name of
the entry and <property> is the property to find (e.g.
_binman_u_boot_prop_offset). As a special case, you can append
diff --git a/tools/binman/image.py b/tools/binman/image.py
index 702c9055585..c667f583db6 100644
--- a/tools/binman/image.py
+++ b/tools/binman/image.py
@@ -381,11 +381,10 @@ class Image(section.Entry_section):
selected_entries.append(entry)
return selected_entries, lines, widths
- def LookupImageSymbol(self, sym_name, optional, msg, base_addr):
- """Look up a symbol in an ELF file
+ def GetImageSymbolValue(self, sym_name, optional, msg, base_addr):
+ """Get the value of a Binman symbol
- Looks up a symbol in an ELF file. Only entry types which come from an
- ELF image can be used by this function.
+ Look up a Binman symbol and obtain its value.
This searches through this image including all of its subsections.
@@ -423,8 +422,8 @@ class Image(section.Entry_section):
entries = OrderedDict()
entries_by_name = {}
self._CollectEntries(entries, entries_by_name, self)
- return self.LookupSymbol(sym_name, optional, msg, base_addr,
- entries_by_name)
+ return self.GetSymbolValue(sym_name, optional, msg, base_addr,
+ entries_by_name)
def CollectBintools(self):
"""Collect all the bintools used by this image
diff --git a/tools/binman/image_test.py b/tools/binman/image_test.py
index bd51c1e55d1..7d65e2d589a 100644
--- a/tools/binman/image_test.py
+++ b/tools/binman/image_test.py
@@ -13,7 +13,7 @@ class TestImage(unittest.TestCase):
def testInvalidFormat(self):
image = Image('name', 'node', test=True)
with self.assertRaises(ValueError) as e:
- image.LookupSymbol('_binman_something_prop_', False, 'msg', 0)
+ image.GetSymbolValue('_binman_something_prop_', False, 'msg', 0)
self.assertIn(
"msg: Symbol '_binman_something_prop_' has invalid format",
str(e.exception))
@@ -22,7 +22,7 @@ class TestImage(unittest.TestCase):
image = Image('name', 'node', test=True)
image._entries = {}
with self.assertRaises(ValueError) as e:
- image.LookupSymbol('_binman_type_prop_pname', False, 'msg', 0)
+ image.GetSymbolValue('_binman_type_prop_pname', False, 'msg', 0)
self.assertIn("msg: Entry 'type' not found in list ()",
str(e.exception))
@@ -30,7 +30,7 @@ class TestImage(unittest.TestCase):
image = Image('name', 'node', test=True)
image._entries = {}
with capture_sys_output() as (stdout, stderr):
- val = image.LookupSymbol('_binman_type_prop_pname', True, 'msg', 0)
+ val = image.GetSymbolValue('_binman_type_prop_pname', True, 'msg', 0)
self.assertEqual(val, None)
self.assertEqual("Warning: msg: Entry 'type' not found in list ()\n",
stderr.getvalue())
@@ -40,5 +40,5 @@ class TestImage(unittest.TestCase):
image = Image('name', 'node', test=True)
image._entries = {'u-boot': 1}
with self.assertRaises(ValueError) as e:
- image.LookupSymbol('_binman_u_boot_prop_bad', False, 'msg', 0)
+ image.GetSymbolValue('_binman_u_boot_prop_bad', False, 'msg', 0)
self.assertIn("msg: No such property 'bad", str(e.exception))
--
2.34.1
More information about the U-Boot
mailing list