Pārlūkot izejas kodu

binman: Don't depend on dict order in ELF testOutsideFile()

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>
Simon Glass 6 gadi atpakaļ
vecāks
revīzija
46d61a2f2a
1 mainītis faili ar 3 papildinājumiem un 1 dzēšanām
  1. 3 1
      tools/binman/elf.py

+ 3 - 1
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