buildtools: fix invalid symbols
PATCH 1/1 buildtools: fix invalid symbols
ELF files generated by higher version compilers wrap multiple symbols prefixed with "this_pmd_name".
This patch fixes the issue by filtering invalid symbols.
Bugzilla ID: 1466
--- buildtools/pmdinfogen.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
buildtools/pmdinfogen.py +2 -1
@@ -200,7 +200,8 @@ def dump(self, file): def load_drivers(image): drivers = [] for symbol in image.find_by_prefix("this_pmd_name"): - drivers.append(Driver.load(image, symbol)) + if len(symbol.string_value) != 0: + drivers.append(Driver.load(image, symbol)) return drivers
Signature · 1 line
2.25.1
Quoted 19 lines · Mingjin Ye
ELF files generated by higher version compilers wrap multiple symbols prefixed with "
this_pmd_name".This patch fixes the issue by filtering invalid symbols.
Bugzilla ID: 1466
Fixes 6c4bf8f42432 ("buildtools: add Python pmdinfogen")Signed-off-by Mingjin Ye <[email protected]>--- buildtools/pmdinfogen.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)buildtools/pmdinfogen.py +0
-0
buildtools/pmdinfogen.py def dump(self, file): · line 204
Quoted 6 lines
buildtools/pmdinfogen.py +2
-1@@ -200,7 +200,8 @@ def dump(self, file): def load_drivers(image): drivers = [] for symbol in image.find_by_prefix("this_pmd_name"): - drivers.append(Driver.load(image, symbol)) + if len(symbol.string_value) != 0: + drivers.append(Driver.load(image, symbol))
One small suggestion. Empty strings evaluate to boolean false, so the condition can just be simplified to:
if symbol.string_value: drivers.append(....)
/Bruce
Quoted 31 lines · Bruce Richardson
Quoted 19 lines · Mingjin Ye
ELF files generated by higher version compilers wrap multiple symbols prefixed with "
this_pmd_name".This patch fixes the issue by filtering invalid symbols.
Bugzilla ID: 1466
Fixes 6c4bf8f42432 ("buildtools: add Python pmdinfogen")Signed-off-by Mingjin Ye <[email protected]>--- buildtools/pmdinfogen.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)buildtools/pmdinfogen.py +0
-0buildtools/pmdinfogen.py def dump(self, file): · line 204
Quoted 6 lines
buildtools/pmdinfogen.py +2
-1@@ -200,7 +200,8 @@ def dump(self, file): def load_drivers(image): drivers = [] for symbol in image.find_by_prefix("this_pmd_name"): - drivers.append(Driver.load(image, symbol)) + if len(symbol.string_value) != 0: + drivers.append(Driver.load(image, symbol))One small suggestion. Empty strings evaluate to boolean false, so the condition can just be simplified to:
Quoted 2 lines
if symbol.string_value:
drivers.append(....)I have the same comment than what Ali tried with:
https://patchwork.dpdk.org/project/dpdk/patch/[email protected]/
I would prefer we don't rely on the content of symbols (that we don't know anything about) when we can filter on the symbol names exactly which is something DPDK controls.
My suggestion is to filter symbol *names* with regex ^this_pmd_name[0-9]+$.
Signature · 1 line
David Marchand
Quoted 11 lines · Mingjin Ye
ELF files generated by higher version compilers wrap multiple symbols prefixed with "
this_pmd_name".This patch fixes the issue by filtering invalid symbols.
Bugzilla ID: 1466
Fixes 6c4bf8f42432 ("buildtools: add Python pmdinfogen")Signed-off-by Mingjin Ye <[email protected]>
Is it the same issue as:
https://patchwork.dpdk.org/project/dpdk/patch/[email protected]/
?
Signature · 1 line
David Marchand
PATCH v2 1/1 buildtools: fix invalid symbols
In reply to Mingjin YeElf files generated by higher version compilers wrap multiple symbols prefixed with "this_pmd_name".
The patch uses the regex "^this_pmd_name[0-9]+$" to match the symbol name.
Bugzilla ID: 1466
---
v2: Use regex ^this_pmd_name[0-9]+$ to filter symbols *names*
--- buildtools/pmdinfogen.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
buildtools/pmdinfogen.py +3 -2
@@ -6,6 +6,7 @@ import argparse import ctypes import json +import re import sys import tempfile
@@ -70,7 +71,7 @@ def find_by_prefix(self, prefix): prefix = prefix.encode("utf-8") if self._legacy_elftools else prefix for i in range(self._symtab.num_symbols()): symbol = self._symtab.get_symbol(i) - if symbol.name.startswith(prefix): + if re.match(prefix, symbol.name): yield ELFSymbol(self._image, symbol)
@@ -199,7 +200,7 @@ def dump(self, file): def load_drivers(image): drivers = [] - for symbol in image.find_by_prefix("this_pmd_name"): + for symbol in image.find_by_prefix("^this_pmd_name[0-9]+$"): drivers.append(Driver.load(image, symbol)) return drivers
Signature · 1 line
2.25.1
Quoted 14 lines
-----Original Message-----
From: Mingjin Ye <[email protected]>
Sent: Monday, July 1, 2024 6:33 PM
To: [email protected]
Cc: Ye, MingjinX <[email protected]>; [email protected]; Dmitry Kozlyuk <[email protected]>
Subject: [PATCH v2] buildtools: fix invalid symbolsElf files generated by higher version compilers wrap multiple symbols prefixed with "
this_pmd_name".The patch uses the regex "^this_pmd_name[0-9]+$" to match the symbol name.
Quoted 8 lines
Bugzilla ID: 1466
Fixes 6c4bf8f42432 ("buildtools: add Python pmdinfogen")Signed-off-by Mingjin Ye <[email protected]>---
v2: Use regex ^this_pmd_name[0-9]+$ to filter symbols *names*
---
Adding Ali in the loop, as he was working on a similar patch.
buildtools/pmdinfogen.py def find_by_prefix(self, prefix):
Quoted 31 lines · Mingjin Ye
Elf files generated by higher version compilers wrap multiple symbols prefixed with "
this_pmd_name".The patch uses the regex "^this_pmd_name[0-9]+$" to match the symbol name.
Bugzilla ID: 1466
Fixes 6c4bf8f42432 ("buildtools: add Python pmdinfogen")Signed-off-by Mingjin Ye <[email protected]>---
v2: Use regex ^this_pmd_name[0-9]+$ to filter symbols *names*--- buildtools/pmdinfogen.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)buildtools/pmdinfogen.py +1
-0@@ -6,6 +6,7 @@ import argparse import ctypes import json +import re import sys import tempfile@@ -70,7 +71,7 @@ def find_by_prefix(self, prefix):
This function does not find symbols with a prefix anymore... Please rename.
Quoted 9 lines
buildtools/pmdinfogen.py +1
-1prefix = prefix.encode("utf-8") if self._legacy_elftools else prefix for i in range(self._symtab.num_symbols()): symbol = self._symtab.get_symbol(i) - if symbol.name.startswith(prefix): + if re.match(prefix, symbol.name): yield ELFSymbol(self._image, symbol)
buildtools/pmdinfogen.py def dump(self, file): · line 205
Quoted 7 lines
buildtools/pmdinfogen.py +1
-1@@ -199,7 +200,7 @@ def dump(self, file): def load_drivers(image): drivers = [] - for symbol in image.find_by_prefix("this_pmd_name"): + for symbol in image.find_by_prefix("^this_pmd_name[0-9]+$"): drivers.append(Driver.load(image, symbol)) return drivers
The COFF implementation is probably broken by this change as it is still filtering symbols with a prefix.
Please update.
Signature · 1 line
David Marchand
PATCH v3 1/1 buildtools: fix invalid symbols
In reply to Mingjin YeIn scenarios where a higher clang compiler is used and ASAN is enabled, the generated ELF file will additionally insert undefined debug symbols with the same prefix. This causes duplicate C code to be generated.
This patch fixes this issue by skipping the unspecified symbol type.
--- buildtools/pmdinfogen.py | 3 +++ 1 file changed, 3 insertions(+)
buildtools/pmdinfogen.py +3 -0
@@ -70,6 +70,9 @@ def find_by_prefix(self, prefix): prefix = prefix.encode("utf-8") if self._legacy_elftools else prefix for i in range(self._symtab.num_symbols()): symbol = self._symtab.get_symbol(i) + # Skip unspecified symbol type + if symbol.entry.st_info['type'] == "STT_NOTYPE": + continue if symbol.name.startswith(prefix): yield ELFSymbol(self._image, symbol)
Signature · 1 line
2.25.1
Quoted 13 lines
-----Original Message-----
From: Mingjin Ye <[email protected]>
Sent: Friday, July 5, 2024 11:26 AM
To: [email protected]
Cc: [email protected]; Ali Alnubani <[email protected]>; Mingjin Ye <[email protected]>; [email protected]; Dmitry Kozlyuk <[email protected]>
Subject: [PATCH v3] buildtools: fix invalid symbolsIn scenarios where a higher clang compiler is used and ASAN is enabled, the generated ELF file will additionally insert undefined debug symbols with the same prefix. This causes duplicate C code to be generated.
Quoted 7 lines
This patch fixes this issue by skipping the unspecified symbol type.
Fixes 6c4bf8f42432 ("buildtools: add Python pmdinfogen")Signed-off-by Mingjin Ye <[email protected]>---
Can confirm it fixes the build failure in my environment, thanks Mingjin.
Regards,
Ali
Quoted 13 lines
-----Original Message-----
From: Mingjin Ye <[email protected]>
Sent: Friday, July 5, 2024 4:26 PM
To: [email protected]
Cc: Marchand, David <[email protected]>; [email protected]; Ye, MingjinX <[email protected]>; [email protected]; Dmitry Kozlyuk <[email protected]>
Subject: [PATCH v3] buildtools: fix invalid symbolsIn scenarios where a higher clang compiler is used and ASAN is enabled, the generated ELF file will additionally insert undefined debug symbols with the same prefix. This causes duplicate C code to be generated.
Quoted 7 lines
This patch fixes this issue by skipping the unspecified symbol type.
Fixes 6c4bf8f42432 ("buildtools: add Python pmdinfogen")Signed-off-by Mingjin Ye <[email protected]>---
Quoted 6 lines · Mingjin Ye
In scenarios where a higher clang compiler is used and ASAN is enabled, the generated ELF file will additionally insert undefined debug symbols with the same prefix. This causes duplicate C code to be generated.
This patch fixes this issue by skipping the unspecified symbol type.
You did not reply to my comments on v3 and here we have a new hack. This hack is ugly and not future proof (I can imagine some other symbols may appear in the future. If those symbols are not of type "STT_NOTYPE" we will have to find another filter at this point...).
Please have a try with:
https://patchwork.dpdk.org/project/dpdk/patch/[email protected]/
Thanks.
Signature · 1 line
David Marchand