binman: Provide a way to set the symbol base address

The base address of the ELF containing symbols is normally added to
any symbols written, so that the value points to the correct address in
memory when everything is loaded. When the binary resides on disk, a
different offset may be needed, typically 0. Provide a way to specify
this.

Signed-off-by: Simon Glass <sjg@chromium.org>
This commit is contained in:
Simon Glass
2024-08-26 13:11:40 -06:00
parent 01a609930b
commit bce055338e
7 changed files with 110 additions and 7 deletions

View File

@@ -234,7 +234,7 @@ def GetSymbolOffset(elf_fname, sym_name, base_sym=None):
return val - base
def LookupAndWriteSymbols(elf_fname, entry, section, is_elf=False,
base_sym=None):
base_sym=None, base_addr=None):
"""Replace all symbols in an entry with their correct values
The entry contents is updated so that values for referenced symbols will be
@@ -249,6 +249,8 @@ def LookupAndWriteSymbols(elf_fname, entry, section, is_elf=False,
section: Section which can be used to lookup symbol values
base_sym: Base symbol marking the start of the image (__image_copy_start
by default)
base_addr (int): Base address to use for the entry being written. If
None then the value of base_sym is used
Returns:
int: Number of symbols written
@@ -278,7 +280,8 @@ def LookupAndWriteSymbols(elf_fname, entry, section, is_elf=False,
if not base and not is_elf:
tout.debug(f'LookupAndWriteSymbols: no base: elf_fname={elf_fname}, base_sym={base_sym}, is_elf={is_elf}')
return 0
base_addr = 0 if is_elf else base.address
if base_addr is None:
base_addr = 0 if is_elf else base.address
count = 0
for name, sym in syms.items():
if name.startswith('_binman'):