2000-03-20 18:33:28 +00:00
|
|
|
# Combine version map fragments into version scripts for our shared objects.
|
2022-01-01 18:54:23 +00:00
|
|
|
# Copyright (C) 1998-2022 Free Software Foundation, Inc.
|
1998-07-02 22:51:40 +00:00
|
|
|
|
1998-07-08 22:53:56 +00:00
|
|
|
# This script expects the following variables to be defined:
|
|
|
|
# defsfile name of Versions.def file
|
|
|
|
# buildroot name of build directory with trailing slash
|
|
|
|
# move_if_change move-if-change command
|
|
|
|
|
1998-07-02 22:51:40 +00:00
|
|
|
# Read definitions for the versions.
|
|
|
|
BEGIN {
|
2005-03-22 23:52:59 +00:00
|
|
|
lossage = 0;
|
|
|
|
|
1998-07-02 22:51:40 +00:00
|
|
|
nlibs=0;
|
1998-07-06 17:09:00 +00:00
|
|
|
while (getline < defsfile) {
|
1999-02-07 00:06:12 +00:00
|
|
|
if (/^[a-zA-Z0-9_.]+ \{/) {
|
1998-07-02 22:51:40 +00:00
|
|
|
libs[$1] = 1;
|
|
|
|
curlib = $1;
|
1998-07-06 17:09:00 +00:00
|
|
|
while (getline < defsfile && ! /^}/) {
|
2005-03-22 23:52:59 +00:00
|
|
|
if ($2 == "=") {
|
2000-03-20 18:33:28 +00:00
|
|
|
renamed[curlib "::" $1] = $3;
|
2005-03-22 23:52:59 +00:00
|
|
|
}
|
2000-03-19 20:36:44 +00:00
|
|
|
else
|
2005-03-22 23:52:59 +00:00
|
|
|
versions[curlib "::" $1] = 1;
|
1998-07-02 22:51:40 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
1998-07-06 17:09:00 +00:00
|
|
|
close(defsfile);
|
1998-07-02 22:51:40 +00:00
|
|
|
|
1998-07-08 22:53:56 +00:00
|
|
|
tmpfile = buildroot "Versions.tmp";
|
2008-12-06 02:13:20 +00:00
|
|
|
# POSIX sort needed.
|
|
|
|
sort = "sort -t. -k 1,1 -k 2n,2n -k 3 > " tmpfile;
|
1998-07-02 22:51:40 +00:00
|
|
|
}
|
|
|
|
|
2021-05-10 08:31:41 +00:00
|
|
|
# GNU awk does not implement the ord and chr functions.
|
|
|
|
# <https://www.gnu.org/software/gawk/manual/html_node/Ordinal-Functions.html>
|
|
|
|
# says that they are "written very nicely", using code similar to what
|
|
|
|
# is included here.
|
|
|
|
function chr(c) {
|
|
|
|
return sprintf("%c", c)
|
|
|
|
}
|
|
|
|
|
|
|
|
BEGIN {
|
|
|
|
for (c = 1; c < 127; c++) {
|
|
|
|
ord_table[chr(c)] = c;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function ord(c) {
|
|
|
|
if (ord_table[c]) {
|
|
|
|
return ord_table[c];
|
|
|
|
} else {
|
|
|
|
printf("Invalid character reference: '%c'\n", c) > "/dev/stderr";
|
|
|
|
++lossage;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1998-07-02 22:51:40 +00:00
|
|
|
# Remove comment lines.
|
|
|
|
/^ *#/ {
|
|
|
|
next;
|
|
|
|
}
|
|
|
|
|
|
|
|
# This matches the beginning of the version information for a new library.
|
1999-02-07 00:06:12 +00:00
|
|
|
/^[a-zA-Z0-9_.]+/ {
|
1998-07-02 22:51:40 +00:00
|
|
|
actlib = $1;
|
1998-07-06 17:09:00 +00:00
|
|
|
if (!libs[$1]) {
|
|
|
|
printf("no versions defined for %s\n", $1) > "/dev/stderr";
|
2005-03-22 23:52:59 +00:00
|
|
|
++lossage;
|
1998-07-02 22:51:40 +00:00
|
|
|
}
|
|
|
|
next;
|
|
|
|
}
|
|
|
|
|
|
|
|
# This matches the beginning of a new version for the current library.
|
|
|
|
/^ [A-Za-z_]/ {
|
2000-03-20 18:33:28 +00:00
|
|
|
if (renamed[actlib "::" $1])
|
|
|
|
actver = renamed[actlib "::" $1];
|
2005-03-23 01:46:42 +00:00
|
|
|
else if (!versions[actlib "::" $1] && $1 != "GLIBC_PRIVATE") {
|
2002-02-07 05:25:11 +00:00
|
|
|
printf("version %s not defined for %s\n", $1, actlib) > "/dev/stderr";
|
2005-03-22 23:52:59 +00:00
|
|
|
++lossage;
|
1998-07-02 22:51:40 +00:00
|
|
|
}
|
2000-03-19 20:36:44 +00:00
|
|
|
else
|
|
|
|
actver = $1;
|
1998-07-02 22:51:40 +00:00
|
|
|
next;
|
|
|
|
}
|
|
|
|
|
|
|
|
# This matches lines with names to be added to the current version in the
|
|
|
|
# current library. This is the only place where we print something to
|
|
|
|
# the intermediate file.
|
|
|
|
/^ / {
|
2001-12-06 07:59:42 +00:00
|
|
|
sortver=actver
|
|
|
|
# Ensure GLIBC_ versions come always first
|
|
|
|
sub(/^GLIBC_/," GLIBC_",sortver)
|
|
|
|
printf("%s %s %s\n", actlib, sortver, $0) | sort;
|
1998-07-02 22:51:40 +00:00
|
|
|
}
|
|
|
|
|
2021-06-02 05:32:19 +00:00
|
|
|
# Some targets do not set the ABI baseline for libdl. As a result,
|
|
|
|
# symbols originally in libdl need to be moved under historic symbol
|
|
|
|
# versions, without altering the baseline version for libc itself.
|
|
|
|
/^ *!libc_pre_versions/ {
|
|
|
|
libc_pre_versions_active = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
function libc_pre_versions() {
|
|
|
|
# No local: * here, so that we do not have to update this script
|
|
|
|
# if symbols are moved into libc. The abilist files and the other
|
|
|
|
# targets (with a real GLIBC_2.0 baseline) provide testing
|
|
|
|
# coverage.
|
|
|
|
printf("\
|
|
|
|
GLIBC_2.0 {\n\
|
|
|
|
};\n\
|
|
|
|
GLIBC_2.1 {\n\
|
|
|
|
} GLIBC_2.0;\n\
|
|
|
|
") > outfile;
|
|
|
|
return "GLIBC_2.1";
|
|
|
|
}
|
1998-07-02 22:51:40 +00:00
|
|
|
|
1999-11-15 07:01:16 +00:00
|
|
|
function closeversion(name, oldname) {
|
2021-06-02 05:32:19 +00:00
|
|
|
printf(" local:\n *;\n") > outfile;
|
2002-02-07 05:25:11 +00:00
|
|
|
# This version inherits from the last one only if they
|
|
|
|
# have the same nonnumeric prefix, i.e. GLIBC_x.y and GLIBC_x.z
|
|
|
|
# or FOO_x and FOO_y but not GLIBC_x and FOO_y.
|
|
|
|
pfx = oldname;
|
|
|
|
sub(/[0-9.]+/,".+",pfx);
|
|
|
|
if (oldname == "" || name !~ pfx) print "};" > outfile;
|
|
|
|
else printf("} %s;\n", oldname) > outfile;
|
1998-07-02 22:51:40 +00:00
|
|
|
}
|
|
|
|
|
1998-07-08 22:53:56 +00:00
|
|
|
function close_and_move(name, real_name) {
|
|
|
|
close(name);
|
|
|
|
system(move_if_change " " name " " real_name " >&2");
|
|
|
|
}
|
|
|
|
|
2021-05-10 08:31:41 +00:00
|
|
|
# ELF hash, for use with symbol versions.
|
|
|
|
function elf_hash(s, i, acc) {
|
|
|
|
acc = 0;
|
|
|
|
for (i = 1; i <= length(s); ++i) {
|
|
|
|
acc = and(lshift(acc, 4) + ord(substr(s, i, 1)), 0xffffffff);
|
|
|
|
top = and(acc, 0xf0000000);
|
|
|
|
acc = and(xor(acc, rshift(top, 24)), compl(top));
|
|
|
|
}
|
|
|
|
return acc;
|
|
|
|
}
|
|
|
|
|
1998-07-02 22:51:40 +00:00
|
|
|
# Now print the accumulated information.
|
|
|
|
END {
|
|
|
|
close(sort);
|
2005-03-22 23:52:59 +00:00
|
|
|
|
|
|
|
if (lossage) {
|
|
|
|
system("rm -f " tmpfile);
|
|
|
|
exit 1;
|
|
|
|
}
|
|
|
|
|
1998-07-08 22:53:56 +00:00
|
|
|
oldlib = "";
|
|
|
|
oldver = "";
|
2017-05-19 11:26:00 +00:00
|
|
|
real_first_ver_header = buildroot "first-versions.h"
|
|
|
|
first_ver_header = real_first_ver_header "T"
|
|
|
|
printf("#ifndef _FIRST_VERSIONS_H\n") > first_ver_header;
|
|
|
|
printf("#define _FIRST_VERSIONS_H\n") > first_ver_header;
|
2017-05-19 11:30:26 +00:00
|
|
|
real_ldbl_compat_header = buildroot "ldbl-compat-choose.h"
|
|
|
|
ldbl_compat_header = real_ldbl_compat_header "T"
|
|
|
|
printf("#ifndef _LDBL_COMPAT_CHOOSE_H\n") > ldbl_compat_header;
|
|
|
|
printf("#define _LDBL_COMPAT_CHOOSE_H\n") > ldbl_compat_header;
|
|
|
|
printf("#ifndef LONG_DOUBLE_COMPAT\n") > ldbl_compat_header;
|
|
|
|
printf("# error LONG_DOUBLE_COMPAT not defined\n") > ldbl_compat_header;
|
|
|
|
printf("#endif\n") > ldbl_compat_header;
|
1998-07-08 22:53:56 +00:00
|
|
|
printf("version-maps =");
|
2002-02-07 05:25:11 +00:00
|
|
|
while (getline < tmpfile) {
|
1998-07-02 22:51:40 +00:00
|
|
|
if ($1 != oldlib) {
|
|
|
|
if (oldlib != "") {
|
1999-11-15 07:01:16 +00:00
|
|
|
closeversion(oldver, veryoldver);
|
1998-07-02 22:51:40 +00:00
|
|
|
oldver = "";
|
1998-07-08 22:53:56 +00:00
|
|
|
close_and_move(outfile, real_outfile);
|
1998-07-02 22:51:40 +00:00
|
|
|
}
|
|
|
|
oldlib = $1;
|
1998-07-08 22:53:56 +00:00
|
|
|
real_outfile = buildroot oldlib ".map";
|
|
|
|
outfile = real_outfile "T";
|
2021-06-02 05:32:19 +00:00
|
|
|
if ($1 == "libc" && libc_pre_versions_active) {
|
|
|
|
veryoldver = libc_pre_versions();
|
|
|
|
} else {
|
|
|
|
veryoldver = "";
|
|
|
|
}
|
1998-07-08 22:53:56 +00:00
|
|
|
printf(" %s.map", oldlib);
|
1998-07-02 22:51:40 +00:00
|
|
|
}
|
|
|
|
if ($2 != oldver) {
|
|
|
|
if (oldver != "") {
|
1999-11-15 07:01:16 +00:00
|
|
|
closeversion(oldver, veryoldver);
|
|
|
|
veryoldver = oldver;
|
1998-07-02 22:51:40 +00:00
|
|
|
}
|
|
|
|
printf("%s {\n global:\n", $2) > outfile;
|
|
|
|
oldver = $2;
|
|
|
|
}
|
|
|
|
printf(" ") > outfile;
|
|
|
|
for (n = 3; n <= NF; ++n) {
|
|
|
|
printf(" %s", $n) > outfile;
|
2017-05-19 11:26:00 +00:00
|
|
|
sym = $n;
|
|
|
|
sub(";", "", sym);
|
|
|
|
first_ver_macro = "FIRST_VERSION_" oldlib "_" sym;
|
|
|
|
if (!(first_ver_macro in first_ver_seen) \
|
|
|
|
&& oldver ~ "^GLIBC_[0-9]" \
|
|
|
|
&& sym ~ "^[A-Za-z0-9_]*$") {
|
|
|
|
ver_val = oldver;
|
2021-05-10 08:31:41 +00:00
|
|
|
printf("#define %s_STRING \"%s\"\n", first_ver_macro, ver_val) > first_ver_header;
|
|
|
|
printf("#define %s_HASH 0x%x\n", first_ver_macro, elf_hash(ver_val)) > first_ver_header;
|
2017-05-19 11:26:00 +00:00
|
|
|
gsub("\\.", "_", ver_val);
|
|
|
|
printf("#define %s %s\n", first_ver_macro, ver_val) > first_ver_header;
|
|
|
|
first_ver_seen[first_ver_macro] = 1;
|
2017-05-19 11:30:26 +00:00
|
|
|
if (oldlib == "libc" || oldlib == "libm") {
|
|
|
|
printf("#if LONG_DOUBLE_COMPAT (%s, %s)\n",
|
|
|
|
oldlib, ver_val) > ldbl_compat_header;
|
|
|
|
printf("# define LONG_DOUBLE_COMPAT_CHOOSE_%s_%s(a, b) a\n",
|
|
|
|
oldlib, sym) > ldbl_compat_header;
|
|
|
|
printf("#else\n") > ldbl_compat_header;
|
|
|
|
printf("# define LONG_DOUBLE_COMPAT_CHOOSE_%s_%s(a, b) b\n",
|
|
|
|
oldlib, sym) > ldbl_compat_header;
|
|
|
|
printf("#endif\n") > ldbl_compat_header;
|
|
|
|
}
|
2017-05-19 11:26:00 +00:00
|
|
|
}
|
1998-07-02 22:51:40 +00:00
|
|
|
}
|
|
|
|
printf("\n") > outfile;
|
|
|
|
}
|
1998-07-06 17:09:00 +00:00
|
|
|
printf("\n");
|
2017-05-19 11:26:00 +00:00
|
|
|
printf("#endif /* first-versions.h */\n") > first_ver_header;
|
2017-05-19 11:30:26 +00:00
|
|
|
printf("#endif /* ldbl-compat-choose.h */\n") > ldbl_compat_header;
|
1999-11-15 07:01:16 +00:00
|
|
|
closeversion(oldver, veryoldver);
|
1998-07-08 22:53:56 +00:00
|
|
|
close_and_move(outfile, real_outfile);
|
2017-05-19 11:26:00 +00:00
|
|
|
close_and_move(first_ver_header, real_first_ver_header);
|
2017-05-19 11:30:26 +00:00
|
|
|
close_and_move(ldbl_compat_header, real_ldbl_compat_header);
|
2008-12-06 02:13:20 +00:00
|
|
|
#system("rm -f " tmpfile);
|
1998-07-02 22:51:40 +00:00
|
|
|
}
|