[2/3] glibcymbols.read_abilist: Add check for duplicate symbols

Message ID e27a86392f5056c1b37b3f6f6f5e5dd15804fec5.1615537262.git.fweimer@redhat.com
State Committed
Commit 3977477d48bc85a5719f3d54040b257cc7e85709
Headers
Series Merge helper for abilist files |

Commit Message

Florian Weimer March 12, 2021, 8:23 a.m. UTC
  This detects some bogus abilist files.
---
 scripts/glibcsymbols.py | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
  

Comments

Adhemerval Zanella March 15, 2021, 8:12 p.m. UTC | #1
LGTM, thanks.

Reviewed-by: Adhemerval Zanella  <adhemerval.zanella@linaro.org>

On 12/03/2021 05:23, Florian Weimer via Libc-alpha wrote:
> This detects some bogus abilist files.
> ---
>  scripts/glibcsymbols.py | 5 ++++-
>  1 file changed, 4 insertions(+), 1 deletion(-)
> 
> diff --git a/scripts/glibcsymbols.py b/scripts/glibcsymbols.py
> index e329ead7f2..1bdd19e51e 100644
> --- a/scripts/glibcsymbols.py
> +++ b/scripts/glibcsymbols.py
> @@ -63,7 +63,10 @@ def read_abilist(path):
>      with open(path) as inp:
>          for line in inp:
>              version, symbol, flags = line.strip().split(' ', 2)
> -            result[VersionedSymbol(symbol, version)] = flags
> +            versym = VersionedSymbol(symbol, version)
> +            if versym in result:
> +                raise IOError("{}: duplicate symbol {}".format(path, versym))
> +            result[versym] = flags
>      return result
>  
>  def abilist_lines(symbols):
>
  

Patch

diff --git a/scripts/glibcsymbols.py b/scripts/glibcsymbols.py
index e329ead7f2..1bdd19e51e 100644
--- a/scripts/glibcsymbols.py
+++ b/scripts/glibcsymbols.py
@@ -63,7 +63,10 @@  def read_abilist(path):
     with open(path) as inp:
         for line in inp:
             version, symbol, flags = line.strip().split(' ', 2)
-            result[VersionedSymbol(symbol, version)] = flags
+            versym = VersionedSymbol(symbol, version)
+            if versym in result:
+                raise IOError("{}: duplicate symbol {}".format(path, versym))
+            result[versym] = flags
     return result
 
 def abilist_lines(symbols):