Skip to content

Commit

Permalink
binman: Don't depend on dict order in ELF testOutsideFile()
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
sjg20 committed Aug 1, 2018
1 parent 61523dd commit 46d61a2
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion tools/binman/elf.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 46d61a2

Please sign in to comment.