From: Simon Glass Date: Tue, 17 Jul 2018 13:25:24 -0600 Subject: [U-Boot] [PATCH 01/29] binman: Don't depend on dict order in ELF testOutsideFile() In-Reply-To: <20180717192552.198496-1-sjg@chromium.org> References: <20180717192552.198496-1-sjg@chromium.org> Message-ID: <20180717192552.198496-2-sjg@chromium.org> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de At present this test assumes that the symbols are returned in address order. However, objdump can list symbols in any order and dictionaries do not guarantee any particular order when iterating through item. Update elf.GetSymbols() to return an OrderedDict, sorted by address, to avoid any problems. Signed-off-by: Simon Glass --- tools/binman/elf.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tools/binman/elf.py b/tools/binman/elf.py index 0ae3b611ba..8c23040d8c 100644 --- a/tools/binman/elf.py +++ b/tools/binman/elf.py @@ -57,7 +57,9 @@ def GetSymbols(fname, patterns): name = parts[2] syms[name] = Symbol(section, int(value, 16), int(size,16), flags[1] == 'w') - return syms + + # Sort dict by address + return OrderedDict(sorted(syms.iteritems(), key=lambda x: x[1].address)) def GetSymbolAddress(fname, sym_name): """Get a value of a symbol from an ELF file -- 2.18.0.203.gfac676dfb9-goog