binman: Adjust naming for reading symbols
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@chromium.org>
This commit is contained in:
@@ -301,7 +301,7 @@ 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,
|
||||
value = section.GetImage().GetImageSymbolValue(name, sym.weak,
|
||||
msg, base_addr)
|
||||
if value is None:
|
||||
value = -1
|
||||
|
@@ -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
|
||||
|
||||
|
@@ -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
|
||||
|
@@ -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,7 +422,7 @@ 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,
|
||||
return self.GetSymbolValue(sym_name, optional, msg, base_addr,
|
||||
entries_by_name)
|
||||
|
||||
def CollectBintools(self):
|
||||
|
@@ -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))
|
||||
|
Reference in New Issue
Block a user