This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
[PATCH] Add new script add-abilist.py
- From: Florian Weimer <fweimer at redhat dot com>
- To: libc-alpha at sourceware dot org
- Date: Mon, 2 Mar 2015 09:01:37 +0100
- Subject: [PATCH] Add new script add-abilist.py
- Authentication-results: sourceware.org; auth=none
This script adds new entries to the abilist files, in the right place
according to the sorting produced by scripts/abilist.awk.
---
scripts/add-abilist.py | 93 ++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 93 insertions(+)
create mode 100644 scripts/add-abilist.py
diff --git a/scripts/add-abilist.py b/scripts/add-abilist.py
new file mode 100644
index 0000000..3d6b6b8
--- /dev/null
+++ b/scripts/add-abilist.py
@@ -0,0 +1,93 @@
+#!/usr/bin/python
+# Copyright (C) 2015 Free Software Foundation, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, see <http://www.gnu.org/licenses/>.
+
+# usage:
+#
+# python scripts/add-abilist.py GLIBC_X.Y function1 function2 \
+# -- $(find sysdeps/unix -name libc.abilist)
+#
+# By default, function symbols are added. You can also add arguments
+# of the form "variable 0x4" to add symbols for variables. (Note that
+# the size may be architecture-specific.)
+
+import sys
+
+def parse_arguments(argv):
+ if len(argv) < 5 or "--" not in argv[3:]:
+ sys.stderr.write(
+ "usage: {} VERSION SYMBOL... -- FILES...\n".format(argv[0]))
+ sys.exit(1)
+ version = argv[1]
+ for dashdash in range(2, len(argv)):
+ if argv[dashdash] == "--":
+ break
+ symbols = argv[2:dashdash]
+ files = argv[dashdash + 1:]
+ return version, symbols, files
+version, symbols, files = parse_arguments(sys.argv)
+
+def read_file(path):
+ result = {}
+ with file(path) as f:
+ version = None
+ for line in f:
+ if line[0] == ' ':
+ line = line.strip()
+ assert version is not None
+ try:
+ result[version].add(line)
+ except KeyError:
+ result[version] = set((line,))
+ else:
+ version = line.strip()
+ return result
+
+def write_file(path, versions):
+ with file(path, "w") as f:
+ for (version, symbols) in sorted(versions.items()):
+ f.write("{}\n".format(version))
+ for symbol in sorted(symbols):
+ f.write(" {}\n".format(symbol))
+
+def patch_file(path, version, symbols):
+ file_versions = read_file(path)
+ changed = []
+ try:
+ version_symbols = file_versions[version]
+ except KeyError:
+ version_symbols = set((version + " A",))
+ changed.append(version)
+ file_versions[version] = version_symbols
+ for symbol in symbols:
+ if symbol not in version_symbols:
+ changed.append(symbol)
+ if " " not in symbols:
+ symbol += " F" # Mark as function by default
+ version_symbols.add(symbol)
+ write_file(path, file_versions)
+ return tuple(changed)
+
+previous = ()
+for path in sorted(files):
+ if path[:2] == "./":
+ path = path[2:]
+ changed = patch_file(path, version, symbols)
+ if changed == previous:
+ changed = "Likewise."
+ else:
+ previous = changed
+ changed = "Add {}.".format(", ".join(changed))
+ sys.stdout.write("\t* {}: {}\n".format(path, changed))
--
2.1.0