]> git.droids-corp.org - dpdk.git/commitdiff
buildtools: allow string constant padding
authorDmitry Kozlyuk <dmitry.kozliuk@gmail.com>
Thu, 27 May 2021 21:24:21 +0000 (00:24 +0300)
committerThomas Monjalon <thomas@monjalon.net>
Thu, 17 Jun 2021 16:44:30 +0000 (18:44 +0200)
Size of string constant symbol may be larger than its length
measured up to NUL terminator. In this case pmdinfogen included padding
bytes after NUL terminator in generated source, yielding incorrect code.

Always trim string data to NUL terminator while reading ELF.
It was already done for COFF because there's no symbol size.

Bugzilla ID: 720
Fixes: f0f93a7adfee ("buildtools: use Python pmdinfogen")
Cc: stable@dpdk.org
Signed-off-by: Dmitry Kozlyuk <dmitry.kozliuk@gmail.com>
buildtools/pmdinfogen.py

index 7a739ec7d442889a2f8dc7763aea99344f68a1b5..2a44f17bdad6461efafd09bcee9be78c7b7f52f6 100755 (executable)
@@ -28,7 +28,7 @@ class ELFSymbol:
     def string_value(self):
         size = self._symbol["st_size"]
         value = self.get_value(0, size)
-        return value[:-1].decode() if value else ""
+        return coff.decode_asciiz(value)  # not COFF-specific
 
     def get_value(self, offset, size):
         section = self._symbol["st_shndx"]