From be45bb941abe18aea0ae03af3d4ce8797885916f Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Mon, 26 Aug 2024 13:11:31 -0600 Subject: binman: Tidy up comments for Entry.GetEntryArgsOrProps() Improve the comments for this function. Signed-off-by: Simon Glass --- tools/binman/entry.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'tools/binman/entry.py') diff --git a/tools/binman/entry.py b/tools/binman/entry.py index 6d2f3789940..7d4d4692776 100644 --- a/tools/binman/entry.py +++ b/tools/binman/entry.py @@ -576,8 +576,16 @@ class Entry(object): def GetEntryArgsOrProps(self, props, required=False): """Return the values of a set of properties + Looks up the named entryargs and returns the value for each. If any + required ones are missing, the error is reported to the user. + Args: - props: List of EntryArg objects + props (list of EntryArg): List of entry arguments to look up + required (bool): True if these entry arguments are required + + Returns: + list of values: one for each item in props, the type is determined + by the EntryArg's 'datatype' property (str or int) Raises: ValueError if a property is not found -- cgit v1.2.3 From bce055338eabdac46d34c781753e05486898325a Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Mon, 26 Aug 2024 13:11:40 -0600 Subject: 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 --- tools/binman/entry.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'tools/binman/entry.py') diff --git a/tools/binman/entry.py b/tools/binman/entry.py index 7d4d4692776..8ad9fe89e0c 100644 --- a/tools/binman/entry.py +++ b/tools/binman/entry.py @@ -108,6 +108,9 @@ class Entry(object): not need to be done again. This is only used with 'binman replace', to stop sections from being rebuilt if their entries have not been replaced + symbols_base (int): Use this value as the assumed load address of the + target entry, when calculating the symbol value. If None, this is + 0 for blobs and the image-start address for ELF files """ fake_dir = None @@ -159,6 +162,7 @@ class Entry(object): self.preserve = False self.build_done = False self.no_write_symbols = False + self.symbols_base = None @staticmethod def FindEntryClass(etype, expanded): @@ -324,6 +328,7 @@ class Entry(object): self.preserve = fdt_util.GetBool(self._node, 'preserve') self.no_write_symbols = fdt_util.GetBool(self._node, 'no-write-symbols') + self.symbols_base = fdt_util.GetInt(self._node, 'symbols-base') def GetDefaultFilename(self): return None @@ -713,7 +718,8 @@ class Entry(object): # Check if we are writing symbols into an ELF file is_elf = self.GetDefaultFilename() == self.elf_fname elf.LookupAndWriteSymbols(self.elf_fname, self, section.GetImage(), - is_elf, self.elf_base_sym) + is_elf, self.elf_base_sym, + self.symbols_base) def CheckEntries(self): """Check that the entry offsets are correct -- cgit v1.2.3 From b73d0bb584e5f89c8d80c7435f1a6c036be25dd9 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Mon, 26 Aug 2024 13:11:41 -0600 Subject: binman: Unwind the end-at-4gb special-case a little Move the check for this further out, so that base_addr is computed in Entry.WriteSymbols() rather than at lower levels. Signed-off-by: Simon Glass --- tools/binman/entry.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'tools/binman/entry.py') diff --git a/tools/binman/entry.py b/tools/binman/entry.py index 8ad9fe89e0c..68f8d62bba9 100644 --- a/tools/binman/entry.py +++ b/tools/binman/entry.py @@ -711,15 +711,22 @@ class Entry(object): def WriteSymbols(self, section): """Write symbol values into binary files for access at run time + As a special case, if symbols_base is not specified and this is an + end-at-4gb image, a symbols_base of 0 is used + Args: section: Section containing the entry """ if self.auto_write_symbols and not self.no_write_symbols: # Check if we are writing symbols into an ELF file is_elf = self.GetDefaultFilename() == self.elf_fname + + symbols_base = self.symbols_base + if symbols_base is None and self.GetImage()._end_4gb: + symbols_base = 0 + elf.LookupAndWriteSymbols(self.elf_fname, self, section.GetImage(), - is_elf, self.elf_base_sym, - self.symbols_base) + is_elf, self.elf_base_sym, symbols_base) def CheckEntries(self): """Check that the entry offsets are correct -- cgit v1.2.3