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 <equinox@diac24.net>
This commit is contained in:
David Lamparter 2021-04-08 00:00:27 +02:00
parent 81693617a2
commit b17f302b20

View file

@ -162,7 +162,10 @@ class ELFDissectData(object):
for field in parent._efields[self.elfclass]: for field in parent._efields[self.elfclass]:
if field[0] == fieldname: if field[0] == fieldname:
break 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: else:
raise AttributeError('%r not found in %r.fields' % (fieldname, parent)) raise AttributeError('%r not found in %r.fields' % (fieldname, parent))