From b17f302b2015c0e8d97a0ff3f023b83830a6ec6f Mon Sep 17 00:00:00 2001 From: David Lamparter Date: Thu, 8 Apr 2021 00:00:27 +0200 Subject: [PATCH] python: fix 32-bit pointers in xrelfo container_of This was mistakenly using the host platform's pointer size rather than the ELF file's. Only noticeable when cross compiling... Signed-off-by: David Lamparter --- python/clippy/elf.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/python/clippy/elf.py b/python/clippy/elf.py index 4ed334f0c4..02cb2e38b3 100644 --- a/python/clippy/elf.py +++ b/python/clippy/elf.py @@ -162,7 +162,10 @@ class ELFDissectData(object): for field in parent._efields[self.elfclass]: if field[0] == fieldname: break - offset += struct.calcsize(field[1]) + spec = field[1] + if spec == 'P': + spec = 'I' if self.elfclass == 32 else 'Q' + offset += struct.calcsize(spec) else: raise AttributeError('%r not found in %r.fields' % (fieldname, parent))