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()
"""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):
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
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
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
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
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.
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
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))
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))
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())
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))