]> git.puffer.fish Git - matthieu/frr.git/commitdiff
python: fix 32-bit pointers in xrelfo container_of
authorDavid Lamparter <equinox@diac24.net>
Wed, 7 Apr 2021 22:00:27 +0000 (00:00 +0200)
committerDavid Lamparter <equinox@diac24.net>
Wed, 7 Apr 2021 22:01:07 +0000 (00:01 +0200)
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>
python/clippy/elf.py

index 4ed334f0c4e2835d9792c599e3b02f7d37d149d6..02cb2e38b313baa806049aa500a5eeb1f9f21454 100644 (file)
@@ -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))