From: Simon Glass Date: Mon, 21 Oct 2019 03:31:34 +0000 (-0600) Subject: binman: Correct symbol calculation with non-zero image base X-Git-Tag: v2020.01-rc2~21^2~15 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=15c981cc;p=oweals%2Fu-boot.git binman: Correct symbol calculation with non-zero image base At present binman adds the image base address to the symbol value before it writes it to the binary. This is not correct since the symbol value itself (e.g. image position) has no relationship to the image base. Fix this and update the tests to cover this case. Signed-off-by: Simon Glass Reviewed-by: Bin Meng --- diff --git a/tools/binman/elf.py b/tools/binman/elf.py index 7bc7cf61b5..0c1a5b44b6 100644 --- a/tools/binman/elf.py +++ b/tools/binman/elf.py @@ -135,9 +135,7 @@ def LookupAndWriteSymbols(elf_fname, entry, section): # Look up the symbol in our entry tables. value = section.LookupSymbol(name, sym.weak, msg) - if value is not None: - value += base.address - else: + if value is None: value = -1 pack_string = pack_string.lower() value_bytes = struct.pack(pack_string, value) diff --git a/tools/binman/test/u_boot_binman_syms.lds b/tools/binman/test/u_boot_binman_syms.lds index 926df873cb..825fc3f649 100644 --- a/tools/binman/test/u_boot_binman_syms.lds +++ b/tools/binman/test/u_boot_binman_syms.lds @@ -9,7 +9,7 @@ ENTRY(_start) SECTIONS { - . = 0x00000000; + . = 0x00000010; _start = .; . = ALIGN(4);