]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
binman: Don't depend on dict order in ELF testOutsideFile()
authorSimon Glass <sjg@chromium.org>
Tue, 17 Jul 2018 19:25:24 +0000 (13:25 -0600)
committerSimon Glass <sjg@chromium.org>
Wed, 1 Aug 2018 22:27:28 +0000 (16:27 -0600)
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 <sjg@chromium.org>
tools/binman/elf.py

index 0ae3b611bae6bee6fa5bf160ddbf16335d5cbdb3..8c23040d8c5b5a4bead928f50fb6f6ce7b00db85 100644 (file)
@@ -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