From patchwork Mon Mar 2 08:01:37 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Florian Weimer X-Patchwork-Id: 5386 Received: (qmail 38604 invoked by alias); 2 Mar 2015 08:03:12 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 38592 invoked by uid 89); 2 Mar 2015 08:03:12 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-3.0 required=5.0 tests=AWL, BAYES_00, SPF_HELO_PASS, SPF_PASS, T_RP_MATCHES_RCVD autolearn=ham version=3.3.2 X-HELO: mx1.redhat.com From: Florian Weimer Date: Mon, 2 Mar 2015 09:01:37 +0100 Subject: [PATCH] Add new script add-abilist.py To: libc-alpha@sourceware.org Message-Id: <20150302080300.B464D4242A0BE@oldenburg.str.redhat.com> 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 . + +# 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))