Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

elf_parser.py: make dependency graph output deterministic #66014

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions scripts/build/elf_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ def __init__(self, elf, sym):
self.sym = sym
self.data = self.elf.symbol_data(sym)

def __lt__(self, other):
return self.sym.entry.st_value < other.sym.entry.st_value

def _data_native_read(self, offset):
(format, size) = self.elf.native_struct_format
return struct.unpack(format, self.data[offset:offset + size])[0]
Expand Down Expand Up @@ -238,8 +241,8 @@ def _on_device(sym):
self.devices.append(Device(self, sym))
self._object_find_named('__device_', _on_device)

# Sort the device array by address for handle calculation
self.devices = sorted(self.devices, key = lambda k: k.sym.entry.st_value)
# Sort the device array by address (st_value) for handle calculation
self.devices = sorted(self.devices)

# Assign handles to the devices
for idx, dev in enumerate(self.devices):
Expand Down Expand Up @@ -280,6 +283,6 @@ def device_dependency_graph(self, title, comment):
)
dot.node(str(dev.ordinal), text)
for dev in self.devices:
for sup in dev.devs_supports:
for sup in sorted(dev.devs_supports):
dot.edge(str(dev.ordinal), str(sup.ordinal))
return dot
Loading