scripts: build: elf_parser: _DEVICE_STRUCT_HANDLES_OFFSET is optional

It is only available if CONFIG_DEVICE_DEPS=y, so the ZephyrElf class
would fail to load if it does not treat _DEVICE_STRUCT_HANDLES_OFFSET as
optional.

Signed-off-by: Gerard Marull-Paretas <gerard@teslabs.com>
This commit is contained in:
Gerard Marull-Paretas 2023-08-31 13:25:50 +02:00 committed by Carles Cufí
parent 78d9ebb51d
commit a4858c40ec

View file

@ -100,8 +100,11 @@ class Device(_Symbol):
# Point to the handles instance associated with the device; # Point to the handles instance associated with the device;
# assigned by correlating the device struct handles pointer # assigned by correlating the device struct handles pointer
# value with the addr of a Handles instance. # value with the addr of a Handles instance.
ordinal_offset = self.elf.ld_consts['_DEVICE_STRUCT_HANDLES_OFFSET'] self.obj_ordinals = None
self.obj_ordinals = self._data_native_read(ordinal_offset) if '_DEVICE_STRUCT_HANDLES_OFFSET' in self.elf.ld_consts:
ordinal_offset = self.elf.ld_consts['_DEVICE_STRUCT_HANDLES_OFFSET']
self.obj_ordinals = self._data_native_read(ordinal_offset)
self.obj_pm = None self.obj_pm = None
if '_DEVICE_STRUCT_PM_OFFSET' in self.elf.ld_consts: if '_DEVICE_STRUCT_PM_OFFSET' in self.elf.ld_consts:
pm_offset = self.elf.ld_consts['_DEVICE_STRUCT_PM_OFFSET'] pm_offset = self.elf.ld_consts['_DEVICE_STRUCT_PM_OFFSET']