Files
patches/glibc/glibc-2.43-accept-yacc-awk.patch

511 lines
14 KiB
Diff

--- a/configure.ac
+++ b/configure.ac
@@ -575,12 +575,14 @@
[GNU sed[^0-9]* \([0-9]*\.[0-9.]*\)],
[3.0[2-9]*|3.[1-9]*|[4-9]*],
SED=: aux_missing="$aux_missing sed")
-AC_CHECK_PROG_VER(AWK, gawk, --version,
- [GNU Awk[^0-9]*\([0-9][0-9.]*\)],
- [3.1.[2-9]*|3.[2-9]*|[4-9]*], critic_missing="$critic_missing gawk")
-AC_CHECK_PROG_VER(BISON, bison, --version,
- [bison (GNU Bison) \([0-9]*\.[0-9.]*\)],
- [2.7*|[3-9].*|[1-9][0-9]*], critic_missing="$critic_missing bison")
+AC_CHECK_PROGS(AWK, awk gawk)
+if test -z "$AWK"; then
+ critic_missing="$critic_missing awk"
+fi
+AC_CHECK_PROGS(BISON, bison yacc)
+if test -z "$BISON"; then
+ critic_missing="$critic_missing yacc"
+fi
# Require GCC 12.1 to build.
AC_CACHE_CHECK([if $CC is sufficient to build libc], libc_cv_compiler_ok, [
--- a/configure
+++ b/configure
@@ -5645,7 +5645,7 @@
SED=: aux_missing="$aux_missing sed"
fi
-for ac_prog in gawk
+for ac_prog in awk gawk
do
# Extract the first word of "$ac_prog", so it can be a program name with args.
set dummy $ac_prog; ac_word=$2
@@ -5694,27 +5694,10 @@
done
if test -z "$AWK"; then
- ac_verc_fail=yes
-else
- # Found it, now check the version.
- { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking version of $AWK" >&5
-printf %s "checking version of $AWK... " >&6; }
- ac_prog_version=`$AWK --version 2>&1 | sed -n 's/^.*GNU Awk[^0-9]*\([0-9][0-9.]*\).*$/\1/p'`
- case $ac_prog_version in
- '') ac_prog_version="v. ?.??, bad"; ac_verc_fail=yes;;
- 3.1.[2-9]*|3.[2-9]*|[4-9]*)
- ac_prog_version="$ac_prog_version, ok"; ac_verc_fail=no;;
- *) ac_prog_version="$ac_prog_version, bad"; ac_verc_fail=yes;;
-
- esac
- { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_prog_version" >&5
-printf "%s\n" "$ac_prog_version" >&6; }
-fi
-if test $ac_verc_fail = yes; then
- critic_missing="$critic_missing gawk"
+ critic_missing="$critic_missing awk"
fi
-for ac_prog in bison
+for ac_prog in bison yacc
do
# Extract the first word of "$ac_prog", so it can be a program name with args.
set dummy $ac_prog; ac_word=$2
@@ -5763,24 +5746,7 @@
done
if test -z "$BISON"; then
- ac_verc_fail=yes
-else
- # Found it, now check the version.
- { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking version of $BISON" >&5
-printf %s "checking version of $BISON... " >&6; }
- ac_prog_version=`$BISON --version 2>&1 | sed -n 's/^.*bison (GNU Bison) \([0-9]*\.[0-9.]*\).*$/\1/p'`
- case $ac_prog_version in
- '') ac_prog_version="v. ?.??, bad"; ac_verc_fail=yes;;
- 2.7*|[3-9].*|[1-9][0-9]*)
- ac_prog_version="$ac_prog_version, ok"; ac_verc_fail=no;;
- *) ac_prog_version="$ac_prog_version, bad"; ac_verc_fail=yes;;
-
- esac
- { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_prog_version" >&5
-printf "%s\n" "$ac_prog_version" >&6; }
-fi
-if test $ac_verc_fail = yes; then
- critic_missing="$critic_missing bison"
+ critic_missing="$critic_missing yacc"
fi
@@ -11003,4 +10969,3 @@
printf "%s\n" "$as_me: WARNING: unrecognized options: $ac_unrecognized_opts" >&2;}
fi
-
--- a/Makerules
+++ b/Makerules
@@ -1000,7 +1000,7 @@
$(common-objpfx)config.h $(..)Makerules
$(LINK.o) -shared -nostdlib -nostartfiles \
-x assembler /dev/null -o $@.so
- $(OBJDUMP) -f $@.so | sed -n 's/.*file format \(.*\)/OUTPUT_FORMAT(\1)/;T;p' > $@
+ $(OBJDUMP) -f $@.so | sed -n 's/.*file format \(.*\)/OUTPUT_FORMAT(\1)/p' > $@
rm -f $@.so
common-generated += format.lds
--- a/scripts/gen-sorted.awk
+++ b/scripts/gen-sorted.awk
@@ -15,7 +15,7 @@
{
subdir = type = FILENAME;
sub(/^.*\//, "", type);
- sub(/\/[^/]+$/, "", subdir);
+ sub("/[^/]+$", "", subdir);
sub(/^.*\//, "", subdir);
thisdir = "";
}
--- a/scripts/gen-tunables.awk
+++ b/scripts/gen-tunables.awk
@@ -16,6 +16,25 @@
max_alias_len=0
}
+function trim(s) {
+ sub(/^[ \t]+/, "", s)
+ sub(/[ \t]+$/, "", s)
+ return s
+}
+
+function sort_indices(src, dst, n, i, key) {
+ n = 0
+ for (key in src) {
+ i = ++n
+ while (i > 1 && dst[i - 1] > key) {
+ dst[i] = dst[i - 1]
+ --i
+ }
+ dst[i] = key
+ }
+ return n
+}
+
# Skip over blank lines and comments.
/^#/ {
next
@@ -97,8 +116,8 @@
# Otherwise, we have encountered a tunable attribute.
split($0, arr, ":")
- attr = gensub(/^[ \t]+|[ \t]+$/, "", "g", arr[1])
- val = gensub(/^[ \t]+|[ \t]+$/, "", "g", arr[2])
+ attr = trim(arr[1])
+ val = trim(arr[2])
if (attr == "type") {
types[top_ns,ns,tunable] = val
@@ -134,7 +153,7 @@
# TYPES is an associative array where the index is the data
# TYPESA is an indexed array where the value is the data
# We sort TYPESA
- typecount = asorti (types, typesa)
+ typecount = sort_indices(types, typesa)
print "/* AUTOGENERATED by gen-tunables.awk. */"
print "#ifndef _TUNABLES_H_"
--- a/scripts/sysd-rules.awk
+++ b/scripts/sysd-rules.awk
@@ -1,4 +1,4 @@
-# This is a GAWK script to generate the sysd-rules file.
+# This is an awk script to generate the sysd-rules file.
# It does not read any input, but it requires that several variables
# be set on its command line (using -v) to their makefile counterparts:
# all_object_suffixes $(all-object-suffixes)
@@ -28,8 +28,8 @@
dep_order = sprintf("%09d", npatterns - length(td[2]));
sort_patterns[target_order SUBSEP dep_order] = patterns[i];
}
- asorti(sort_patterns, map_patterns);
- for (i in map_patterns) {
+ nsorted_patterns = sort_indices(sort_patterns, map_patterns);
+ for (i = 1; i <= nsorted_patterns; ++i) {
patterns[i] = sort_patterns[map_patterns[i]];
}
@@ -57,7 +57,8 @@
if (target_pattern == "%") {
command_suffix = "";
} else {
- prefix = gensub(/%/, "", 1, target_pattern);
+ prefix = target_pattern;
+ sub(/%/, "", prefix);
command_suffix = " $(" prefix "CPPFLAGS)" " $(" prefix "CFLAGS)";
}
target = "$(objpfx)" target_pattern o ":";
@@ -78,3 +79,16 @@
print "sysd-rules-done := t";
exit 0;
}
+
+function sort_indices(src, dst, n, i, key) {
+ n = 0;
+ for (key in src) {
+ i = ++n;
+ while (i > 1 && dst[i - 1] > key) {
+ dst[i] = dst[i - 1];
+ --i;
+ }
+ dst[i] = key;
+ }
+ return n;
+}
--- a/scripts/versionlist.awk
+++ b/scripts/versionlist.awk
@@ -3,6 +3,19 @@
BEGIN { in_lib = ""; in_version = 0 }
+function sort_indices(src, dst, n, i, key) {
+ n = 0;
+ for (key in src) {
+ i = ++n;
+ while (i > 1 && dst[i - 1] > key) {
+ dst[i] = dst[i - 1];
+ --i;
+ }
+ dst[i] = key;
+ }
+ return n;
+}
+
!in_lib && NF == 2 && $2 == "{" {
in_lib = $1;
all_libs[in_lib] = 1;
@@ -31,7 +44,7 @@
$1 == "}" { in_lib = ""; next }
END {
- nlibs = asorti(all_libs, libs_order);
+ nlibs = sort_indices(all_libs, libs_order);
for (i = 1; i <= nlibs; ++i) {
lib = libs_order[i];
--- a/scripts/versions.awk
+++ b/scripts/versions.awk
@@ -104,12 +104,10 @@
# 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;
+ print "GLIBC_2.0 {" > outfile;
+ print "};" > outfile;
+ print "GLIBC_2.1 {" > outfile;
+ print "} GLIBC_2.0;" > outfile;
return "GLIBC_2.1";
}
@@ -130,12 +128,28 @@
}
# ELF hash, for use with symbol versions.
+function bit_xor(a, b, res, bit, abit, bbit) {
+ res = 0;
+ bit = 1;
+ while (a > 0 || b > 0) {
+ abit = a % 2;
+ bbit = b % 2;
+ if ((abit && !bbit) || (!abit && bbit))
+ res += bit;
+ a = int(a / 2);
+ b = int(b / 2);
+ bit *= 2;
+ }
+ return res;
+}
+
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));
+ acc = (acc * 16 + ord(substr(s, i, 1))) % 4294967296;
+ top = int(acc / 268435456) * 268435456;
+ acc = bit_xor(acc, int(top / 16777216));
+ acc -= top;
}
return acc;
}
--- a/scripts/localplt.awk
+++ b/scripts/localplt.awk
@@ -9,6 +9,42 @@
pltrelsize = -1;
}
+function hexval(c) {
+ if (c >= "0" && c <= "9")
+ return c + 0;
+ if (c >= "a" && c <= "f")
+ return 10 + index("abcdef", c) - 1;
+ if (c >= "A" && c <= "F")
+ return 10 + index("ABCDEF", c) - 1;
+ return 0;
+}
+
+function number(s, i, n) {
+ if (s ~ /^0[xX]/) {
+ n = 0;
+ for (i = 3; i <= length(s); ++i)
+ n = n * 16 + hexval(substr(s, i, 1));
+ return n;
+ }
+ return s + 0;
+}
+
+function unversioned(s) {
+ sub(/@.*/, "", s);
+ return s;
+}
+
+function jmprel_file_name(s) {
+ sub(/^.*\//, "", s);
+ sub(/\.jmprel$/, ":", s);
+ return s;
+}
+
+function clear_array(a, k) {
+ for (k in a)
+ delete a[k];
+}
+
FILENAME != lastfile {
if (lastfile && jmprel_offset == 0 && rela_offset == 0 && rel_offset == 0 \
&& relr_offset == 0) {
@@ -25,7 +61,7 @@
rel_offset = 0;
relr_offset = 0;
pltrelsz = -1;
- delete section_offset_by_address;
+ clear_array(section_offset_by_address);
}
/^Section Headers:/ { in_shdrs = 1; next }
@@ -33,8 +69,8 @@
in_shdrs && /^ +\[/ { sub(/\[ +/, "[") }
in_shdrs {
- address = strtonum("0x" $4);
- offset = strtonum("0x" $5);
+ address = number("0x" $4);
+ offset = number("0x" $5);
section_offset_by_address[address] = offset;
}
@@ -47,11 +83,11 @@
# Relocations against GNU_IFUNC symbols are not shown as an hexadecimal
# value, but rather as the resolver symbol followed by ().
if ($4 ~ /\(\)/) {
- print whatfile, gensub(/@.*/, "", "g", $5)
+ print whatfile, unversioned($5)
} else {
- symval = strtonum("0x" $4);
+ symval = number("0x" $4);
if (symval != 0)
- print whatfile, gensub(/@.*/, "", "g", $5)
+ print whatfile, unversioned($5)
}
}
@@ -59,11 +95,11 @@
# Relocations against GNU_IFUNC symbols are not shown as an hexadecimal
# value, but rather as the resolver symbol followed by ().
if ($4 ~ /\(\)/) {
- print whatfile, gensub(/@.*/, "", "g", $5), "RELA", $3
+ print whatfile, unversioned($5), "RELA", $3
} else {
- symval = strtonum("0x" $4);
+ symval = number("0x" $4);
if (symval != 0)
- print whatfile, gensub(/@.*/, "", "g", $5), "RELA", $3
+ print whatfile, unversioned($5), "RELA", $3
}
}
@@ -71,11 +107,11 @@
# Relocations against GNU_IFUNC symbols are not shown as an hexadecimal
# value, but rather as the resolver symbol followed by ().
if ($4 ~ /\(\)/) {
- print whatfile, gensub(/@.*/, "", "g", $5), "REL", $3
+ print whatfile, unversioned($5), "REL", $3
} else {
- symval = strtonum("0x" $4);
+ symval = number("0x" $4);
if (symval != 0)
- print whatfile, gensub(/@.*/, "", "g", $5), "REL", $3
+ print whatfile, unversioned($5), "REL", $3
}
}
@@ -84,13 +120,13 @@
in_relocs { next }
$1 == "Relocation" && $2 == "section" && $5 == "offset" {
- relocs_offset = strtonum($6);
- whatfile = gensub(/^.*\/([^/]+)\.jmprel$/, "\\1:", 1, FILENAME);
+ relocs_offset = number($6);
+ whatfile = jmprel_file_name(FILENAME);
next
}
$2 == "(JMPREL)" {
- jmprel_addr = strtonum($3);
+ jmprel_addr = number($3);
if (jmprel_addr in section_offset_by_address) {
jmprel_offset = section_offset_by_address[jmprel_addr];
} else {
@@ -100,12 +136,12 @@
}
$2 == "(PLTRELSZ)" {
- pltrelsz = strtonum($3);
+ pltrelsz = number($3);
next
}
$2 == "(RELA)" {
- rela_addr = strtonum($3);
+ rela_addr = number($3);
if (rela_addr in section_offset_by_address) {
rela_offset = section_offset_by_address[rela_addr];
} else {
@@ -116,7 +152,7 @@
}
$2 == "(REL)" {
- rel_addr = strtonum($3);
+ rel_addr = number($3);
if (rel_addr in section_offset_by_address) {
rel_offset = section_offset_by_address[rel_addr];
} else {
@@ -127,7 +163,7 @@
}
$2 == "(RELR)" {
- relr_addr = strtonum($3);
+ relr_addr = number($3);
if (relr_addr in section_offset_by_address) {
relr_offset = section_offset_by_address[relr_addr];
} else {
--- a/sysdeps/unix/sysv/linux/gen-syscall-h.awk
+++ b/sysdeps/unix/sysv/linux/gen-syscall-h.awk
@@ -36,7 +36,11 @@
}
# Skip empty lines and comments.
-/^\s*(|#.*)$/ {
+/^[[:space:]]*$/ {
+ next;
+}
+
+/^[[:space:]]*#/ {
next;
}
--- a/elf/Makefile
+++ b/elf/Makefile
@@ -1561,7 +1561,7 @@
-Wl,-soname=$(rtld-installed-name)
$(call after-link,$@.new)
$(READELF) -s $@.new \
- | $(AWK) '($$7 ~ /^UND(|EF)$$/ && $$1 != "0:" && $$4 != "REGISTER") { print; p=1 } END { exit p != 0 }'
+ | $(AWK) '(($$7 == "UND" || $$7 == "UNDEF") && $$1 != "0:" && $$4 != "REGISTER") { print; p=1 } END { exit p != 0 }'
mv -f $@.new $@
ifeq (yes,$(build-shared))
--- a/intl/Makefile
+++ b/intl/Makefile
@@ -161,7 +161,11 @@
-D'LOCALE_ALIAS_PATH="$(localedir)"' \
-Wno-unused-but-set-variable \
-Wno-implicit-fallthrough
+ifeq ($(notdir $(BISON)),yacc)
+BISONFLAGS = -l -p __gettext -o
+else
BISONFLAGS = --yacc --no-lines --name-prefix=__gettext --output
+endif
$(inst_localedir)/locale.alias: locale.alias $(+force)
$(do-install)
--- a/timezone/Makefile
+++ b/timezone/Makefile
@@ -118,10 +118,12 @@
$(build-testdata)
{ test -r $(@D)/Universal.test-result \
&& cp $(@D)/Universal.test-result $(@D)/UTC.test-result \
- && sed -i 's/Universal/UTC/' $(@D)/UTC.test-result ; exit 0; }
+ && sed 's/Universal/UTC/' $(@D)/UTC.test-result > $(@D)/UTC.test-resultT \
+ && mv -f $(@D)/UTC.test-resultT $(@D)/UTC.test-result ; exit 0; }
{ test -r $(@D)/UTC.test-result \
&& cp $(@D)/UTC.test-result $(@D)/Universal.test-result \
- && sed -i 's/UTC/Universal/' $(@D)/Universal.test-result ; exit 0; }
+ && sed 's/UTC/Universal/' $(@D)/Universal.test-result > $(@D)/Universal.test-resultT \
+ && mv -f $(@D)/Universal.test-resultT $(@D)/Universal.test-result ; exit 0; }
$(testdata)/%/Berlin $(testdata)/%/London: europe $(zic-deps)
$(build-testdata)
$(testdata)/Australia/Melbourne: australasia $(zic-deps)