diff options
author | Roland McGrath <roland@gnu.org> | 2000-03-19 20:36:44 +0000 |
---|---|---|
committer | Roland McGrath <roland@gnu.org> | 2000-03-19 20:36:44 +0000 |
commit | 361742eda986901daf75169faaf648d4d132ccfb (patch) | |
tree | a5d99df3b839ac0fd99cf17886ea35b900d16039 | |
parent | 882688521994c2329242212a61dd2a7c44eadbc6 (diff) | |
download | glibc-361742eda986901daf75169faaf648d4d132ccfb.tar.gz glibc-361742eda986901daf75169faaf648d4d132ccfb.tar.xz glibc-361742eda986901daf75169faaf648d4d132ccfb.zip |
* shlib-versions [USE_IN_LIBIO] (.*-.*-gnu-gnu*): Set earliest
supported version for libc 0.2.90.libio to GLIBC_2.2. * Makeconfig (soversions.mk): Grok new third column in shlib-versions, and use it to emit new variable `map-firstversions'. * scripts/firstversions.awk: New file. * Makerules (Versions.all): Use scripts/firstversions.awk and the $(map-firstversions) value to generate a modified versions list that includes renames in "A = B" syntax for each version set earlier than the "earliest symbol version" named in shlib-versions. * scripts/versions.awk: Recognize "A = B" lines in the input to mean rename version set A to B in the output to the intermediate file. * scripts/abi-versions.awk: New file. * Makerules (abi-versions.h): New target, generated by that script. [$(versioning) = yes] (before-compile): Prepend abi-versions.h. * include/shlib-compat.h: New file, uses that generated header.
-rw-r--r-- | ChangeLog | 19 | ||||
-rw-r--r-- | Makeconfig | 30 | ||||
-rw-r--r-- | Makerules | 28 | ||||
-rw-r--r-- | include/shlib-compat.h | 61 | ||||
-rw-r--r-- | scripts/abi-versions.awk | 39 | ||||
-rw-r--r-- | scripts/firstversions.awk | 27 | ||||
-rw-r--r-- | scripts/versions.awk | 13 | ||||
-rw-r--r-- | shlib-versions | 6 |
8 files changed, 198 insertions, 25 deletions
diff --git a/ChangeLog b/ChangeLog index d8efcb08e9..9c84cb239f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,22 @@ +2000-03-19 Roland McGrath <roland@baalperazim.frob.com> + + * shlib-versions [USE_IN_LIBIO] (.*-.*-gnu-gnu*): Set earliest + supported version for libc 0.2.90.libio to GLIBC_2.2. + + * Makeconfig (soversions.mk): Grok new third column in shlib-versions, + and use it to emit new variable `map-firstversions'. + * scripts/firstversions.awk: New file. + * Makerules (Versions.all): Use scripts/firstversions.awk and + the $(map-firstversions) value to generate a modified versions list + that includes renames in "A = B" syntax for each version set earlier + than the "earliest symbol version" named in shlib-versions. + * scripts/versions.awk: Recognize "A = B" lines in the input to mean + rename version set A to B in the output to the intermediate file. + * scripts/abi-versions.awk: New file. + * Makerules (abi-versions.h): New target, generated by that script. + [$(versioning) = yes] (before-compile): Prepend abi-versions.h. + * include/shlib-compat.h: New file, uses that generated header. + 2000-03-18 Roland McGrath <roland@baalperazim.frob.com> * Makeconfig (soversions.mk): Convert % -> # in shlib-versions diff --git a/Makeconfig b/Makeconfig index de1b1b186a..14a690d213 100644 --- a/Makeconfig +++ b/Makeconfig @@ -687,23 +687,23 @@ $(common-objpfx)soversions.mk: $(..)shlib-versions $(..)Makeconfig \ for f in $$file; do \ sed 's/#.*$$//;s/^[ ]*%/#/' $$f \ | $(CC) -include $(common-objpfx)config.h -E -x c - \ - | while read conf versions; do \ - test -n "$$versions" && \ + | while read conf version setname; do \ + test -n "$$version" && \ test `expr '$(config-machine)-$(config-vendor)-$(config-os)' \ : "$$conf"` != 0 || continue; \ - for v in $$versions; do \ - lib=`echo $$v | sed 's/=.*$$//'`; \ - if eval "test -z \"\$$vers_lib$$lib\""; then \ - eval vers_lib$${lib}=yes; \ - number=`echo $$v | sed "s/^.*=//"`; \ - case $$number in \ - [0-9]*) echo "$$lib.so-version=.$$number"; \ - echo "all-sonames+=$$lib.so\$$($$lib.so-version)";;\ - *) echo "$$lib.so-version=$$number"; \ - echo "all-sonames+=\$$($$lib.so-version)";; \ - esac; \ - fi; \ - done; \ + lib=`echo $$version | sed 's/=.*$$//'`; \ + if eval "test -z \"\$$versioners_lib$$lib\""; then \ + eval vers_lib$${lib}=yes; \ + number=`echo $$version | sed "s/^.*=//"`; \ + case $$number in \ + [0-9]*) echo "$$lib.so-version=.$$number"; \ + echo "all-sonames+=$$lib.so\$$($$lib.so-version)";;\ + *) echo "$$lib.so-version=$$number"; \ + echo "all-sonames+=\$$($$lib.so-version)";; \ + esac; \ + test -z "$$setname" || \ + echo "map-firstversions+=$${lib}:$${setname}"; \ + fi; \ done; \ done;) > $@T; exit 0 mv -f $@T $@ diff --git a/Makerules b/Makerules index 4d6a48742c..fefbea0342 100644 --- a/Makerules +++ b/Makerules @@ -1,4 +1,5 @@ -# Copyright (C) 1991,92,93,94,95,96,97,98,99 Free Software Foundation, Inc. +# Copyright (C) 1991,92,93,94,95,96,97,98,99,2000 +# Free Software Foundation, Inc. # This file is part of the GNU C Library. # The GNU C Library is free software; you can redistribute it and/or @@ -128,6 +129,18 @@ before-compile := $(filter $(common-objpfx)mach% $(common-objpfx)hurd%,\ $(filter-out $(common-objpfx)mach% $(common-objpfx)hurd%,\ $(before-compile)) +# Even before that, we need abi-versions.h which is generated right here. +ifeq ($(versioning),yes) +ifndef avoid-generated +before-compile := $(common-objpfx)abi-versions.h $(before-compile) +$(common-objpfx)abi-versions.h: $(..)scripts/abi-versions.awk \ + $(common-objpfx)Versions.all + LC_ALL=C $(AWK) -f $^ > $@T + mv -f $@T $@ +endif # avoid-generated +endif # $(versioning) = yes + + # Remove existing files from `before-compile'. Things are added there when # they must exist for dependency generation to work right, but once they # exist there is no further need for every single file to depend on them, @@ -277,9 +290,15 @@ ifneq ($(sysd-versions-subdirs),$(all-subdirs) $(config-sysdirs)) sysd-versions-force = FORCE FORCE: endif -$(common-objpfx)Versions.all: $(..)Versions.def \ - $(wildcard $(add-ons:%=$(..)%/Versions.def)) - cat $^ > $@T +$(common-objpfx)Versions.all: $(..)scripts/firstversions.awk \ + $(..)Versions.def \ + $(wildcard $(add-ons:%=$(..)%/Versions.def)) \ + $(common-objpfx)soversions.mk + { for map in $(map-firstversions); do \ + echo $$map; \ + done | sed 's/:/ : /'; \ + cat $(filter-out $< $(common-objpfx)soversions.mk,$^); \ + } | LC_ALL=C $(AWK) -f $< > $@T mv -f $@T $@ $(common-objpfx)sysd-versions: $(common-objpfx)Versions.all \ $(..)scripts/versions.awk \ @@ -296,6 +315,7 @@ endif # avoid-generated endif # $(versioning) = yes endif # sysd-dirs-done + ifndef compile-command.S compile-command.S = $(compile.S) $(OUTPUT_OPTION) endif diff --git a/include/shlib-compat.h b/include/shlib-compat.h new file mode 100644 index 0000000000..50fba1b957 --- /dev/null +++ b/include/shlib-compat.h @@ -0,0 +1,61 @@ +/* Macros for managing ABI-compatibility definitions using ELF symbol versions. + Copyright (C) 2000 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public License as + published by the Free Software Foundation; either version 2 of the + License, or (at your option) any later version. + + The GNU C Library 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 + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with the GNU C Library; see the file COPYING.LIB. If not, + write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ + +#ifndef _SHLIB_COMPAT_H +#define _SHLIB_COMPAT_H 1 + +#if defined HAVE_ELF && defined PIC && defined DO_VERSIONING + +#include <abi-versions.h> /* header generated by abi-versions.awk */ + +/* The file abi-versions.h (generated by scripts/abi-versions.awk) defines + symbols like `ABI_libm_GLIBC_2_0' to either 1 or 0 indicating whether or + not we want to build binary compatibility for e.g. the GLIBC_2.0 version + set into the libm shared object. If this evaluates to zero, then there + is no need to compile in extra code to support this version set where it + has been superseded by a newer version. The compatibility code should + be conditionalized with `#if SHLIB_COMPAT (libm, GLIBC_2_0)'. */ + +#define SHLIB_COMPAT(lib, version) ABI_##lib##_##version + +/* That header also defines symbols like `VERSION_libm_GLIBC_2_1' to + the version set name to use for e.g. symbols first introduced into + libm in the GLIBC_2.1 version. Definitions of symbols with explicit + versions should look like: + versioned_symbol (libm, new_foo, foo, GLIBC_2_1); + This will define the symbol `foo' with the appropriate default version, + i.e. either GLIBC_2.1 or the "earliest version" specified in + shlib-versions if that is newer. */ + +#define versioned_symbol(lib, local, symbol, version) \ + default_symbol_version (local, symbol, VERSION_##lib##_##version) + +#else + +/* Not compiling ELF shared libraries at all, so never any old versions. */ +#define SHLIB_COMPAT(lib, version) 0 + +/* No versions to worry about, just make this the global definition. */ +#define versioned_symbol(lib, local, symbol, version) \ + weak_alias (local, symbol) + +#endif + + +#endif /* shlib-compat.h */ diff --git a/scripts/abi-versions.awk b/scripts/abi-versions.awk new file mode 100644 index 0000000000..0cceaad66a --- /dev/null +++ b/scripts/abi-versions.awk @@ -0,0 +1,39 @@ +# Script to generate <abi-versions.h> header file from Versions.all list. +# See include/shlib-compat.h comments for explanation. + +BEGIN { + print "/* This file is automatically generated by abi-versions.awk."; + print " It defines symbols used by shlib-compat.h, which see. */"; + print "\n#ifndef _ABI_VERSIONS_H\n#define _ABI_VERSIONS_H"; +} + +NF == 2 && $2 == "{" { + thislib = $1; + gsub(/[^A-Za-z0-9_ ]/, "_"); libid = $1; + printf "\n/* start %s */\n", thislib; + next; +} +$1 == "}" { + printf "/* end %s */\n", thislib; + next; +} + +$2 == "=" { + new = $3; + gsub(/[^A-Za-z0-9_ ]/, "_"); id = $1; + printf "#define ABI_%s_%s\t0\t/* earliest supported %s */\n", libid, id, new; + printf "#define VERSION_%s_%s\t%s\n", libid, id, new; + next; +} + +{ + vers = $1; + gsub(/[^A-Za-z0-9_ ]/, "_"); id = $1; + printf "#define ABI_%s_%s\t1\t/* support %s */\n", libid, id, vers; + printf "#define VERSION_%s_%s\t%s\n", libid, id, vers; + next; +} + +END { + print "\n#endif /* abi-versions.h */"; +} diff --git a/scripts/firstversions.awk b/scripts/firstversions.awk new file mode 100644 index 0000000000..236d90ec97 --- /dev/null +++ b/scripts/firstversions.awk @@ -0,0 +1,27 @@ +# Script to preprocess Versions.all lists based on "earliest version" +# specifications in the shlib-versions file. + +NF == 3 && $2 == ":" { firstversion[$1] = $3; next } + +NF == 2 && $2 == "{" { thislib = $1; print; next } + +$1 == "}" { + if (firstversion[thislib]) { + # We haven't seen the stated version, but have produced + # others pointing to it, so we synthesize it now. + printf " %s\n", firstversion[thislib]; + } + print; + next; +} + +{ + if (! firstversion[thislib]) + print; + else if ($1 == firstversion[thislib]) { + print; + firstversion[thislib] = 0; + } + else + print $1, "=", firstversion[thislib]; +} diff --git a/scripts/versions.awk b/scripts/versions.awk index 78ed73914b..086a963b25 100644 --- a/scripts/versions.awk +++ b/scripts/versions.awk @@ -16,7 +16,10 @@ BEGIN { libs[$1] = 1; curlib = $1; while (getline < defsfile && ! /^}/) { - versions[$1] = 1; + if ($2 == "=") + renamed[$1] = $3; + else + versions[$1] = 1; } } } @@ -33,6 +36,7 @@ BEGIN { # This matches the beginning of the version information for a new library. /^[a-zA-Z0-9_.]+/ { + delete renamed; actlib = $1; if (!libs[$1]) { printf("no versions defined for %s\n", $1) > "/dev/stderr"; @@ -43,11 +47,14 @@ BEGIN { # This matches the beginning of a new version for the current library. /^ [A-Za-z_]/ { - actver = $1; - if (!versions[$1]) { + if (renamed[$1]) + actver = renamed[$1]; + else if (!versions[$1]) { printf("version %s not defined\n", $1) > "/dev/stderr"; exit 1; } + else + actver = $1; next; } diff --git a/shlib-versions b/shlib-versions index abf2fd49de..f907bc7eee 100644 --- a/shlib-versions +++ b/shlib-versions @@ -8,8 +8,8 @@ # This file can use cpp-style conditionals starting with % instead of # # to test the symbols defined in config.h by configure. -# Configuration Library versions -# ------------- ------- -------- +# Configuration Library=version Earliest symbol set (optional) +# ------------- --------------- ------------------------------ # The interface to -lm depends mostly only on cpu, not on operating system. i.86-.*-.* libm=6 @@ -33,7 +33,7 @@ alpha.*-.*-linux.* libc=6.1 # libc.so.0.2 is for the Hurd alpha release 0.2. %ifdef USE_IN_LIBIO /* experimental only! */ -.*-.*-gnu-gnu* libc=0.2.90.libio +.*-.*-gnu-gnu* libc=0.2.90.libio GLIBC_2.2 %else .*-.*-gnu-gnu* libc=0.2 %endif |