* [gentoo-commits] proj/sandbox:master commit in: scripts/
@ 2019-06-25 6:42 Sergei Trofimovich
0 siblings, 0 replies; 2+ messages in thread
From: Sergei Trofimovich @ 2019-06-25 6:42 UTC (permalink / raw
To: gentoo-commits
commit: ee52c156905c419323865e7cdd2deb46040f0c8a
Author: Sergei Trofimovich <slyfox <AT> gentoo <DOT> org>
AuthorDate: Sun Jun 23 20:50:54 2019 +0000
Commit: Sergei Trofimovich <slyfox <AT> gentoo <DOT> org>
CommitDate: Tue Jun 25 06:39:27 2019 +0000
URL: https://gitweb.gentoo.org/proj/sandbox.git/commit/?id=ee52c156
scripts/gen_symbol_header.awk: undefine libc symbol aliases
Avoid libc's symbol rename via #define. musl defines aliases as:
#define mkstemp64 mkstemp
#define mkstemps64 mkstemps
This causes libsandbox's aliases to clash with one another,
like mkstemp and mkstemp64.
The change does not break glibc and restores musl support.
Bug: https://bugs.gentoo.org/549108
Signed-off-by: Sergei Trofimovich <slyfox <AT> gentoo.org>
| 4 ++++
1 file changed, 4 insertions(+)
--git a/scripts/gen_symbol_header.awk b/scripts/gen_symbol_header.awk
index c9af7f9..3f23134 100644
--- a/scripts/gen_symbol_header.awk
+++ b/scripts/gen_symbol_header.awk
@@ -117,6 +117,10 @@ END {
gsub(/@|\./, "_", sym_real_name);
}
+ # Avoid libc's symbol rename via #define. musl defines aliases as:
+ # #define mkstemp64 mkstemp
+ # #define mkstemps64 mkstemps
+ printf("#undef %s\n", sym_index);
printf("#define symname_%s \"%s\"\n", sym_real_name, sym_index);
# We handle non-versioned libc's by setting symver_*
^ permalink raw reply related [flat|nested] 2+ messages in thread
* [gentoo-commits] proj/sandbox:master commit in: scripts/
@ 2021-10-23 22:19 Mike Frysinger
0 siblings, 0 replies; 2+ messages in thread
From: Mike Frysinger @ 2021-10-23 22:19 UTC (permalink / raw
To: gentoo-commits
commit: c681b2cadafca7fbc0b5059a7dcb1bd4f997ebca
Author: Mike Frysinger <vapier <AT> gentoo <DOT> org>
AuthorDate: Sat Oct 23 08:45:55 2021 +0000
Commit: Mike Frysinger <vapier <AT> gentoo <DOT> org>
CommitDate: Sat Oct 23 22:18:03 2021 +0000
URL: https://gitweb.gentoo.org/proj/sandbox.git/commit/?id=c681b2ca
scripts: rewrite main processing loops for significant speedup
The awk scripts iterate over all the possible symbols for each line of
readelf output. As we add more symbols, and as the C library grows,
the number of iterations explodes.
We iterate over the list of possible symbols by creating a regex to
match against the readelf output. We could create a large regex at
the start of the script to match all possible symbols, and then run
that against the readelf lines. This avoids the nested loop logic,
and speeds up the scripts significantly: from ~1.5sec to ~0.05sec.
Signed-off-by: Mike Frysinger <vapier <AT> gentoo.org>
| 128 ++++++++++++++++++-----------------
scripts/gen_symbol_version_map.awk | 132 +++++++++++++++++++------------------
2 files changed, 136 insertions(+), 124 deletions(-)
--git a/scripts/gen_symbol_header.awk b/scripts/gen_symbol_header.awk
index 3f23134..2d26c5a 100644
--- a/scripts/gen_symbol_header.awk
+++ b/scripts/gen_symbol_header.awk
@@ -1,5 +1,15 @@
BEGIN {
COUNT = split(" " SYMBOLS_LIST, SYMBOLS);
+
+ sym_regex = "";
+ for (x in SYMBOLS) {
+ symbol = SYMBOLS[x];
+ if (sym_regex)
+ sym_regex = sym_regex "|";
+ sym_regex = sym_regex symbol;
+ }
+ SYMBOL_REGEX = "^(" sym_regex ")(@|$)";
+ WEAK_SYMBOL_REGEX = "^__(" sym_regx ")(@@|$)";
}
/^ OS\/ABI:/ {
@@ -12,73 +22,69 @@ BEGIN {
if ($0 ~ "^Symbol (.*)table '.symtab'")
nextfile;
- for (x in SYMBOLS) {
- sym_regex = "^" SYMBOLS[x] "(@|$)";
- # On x86, x86_64 and others, $8 is the symbol name, but on
- # alpha, its $10, so rather use $NF, as it should be the
- # last field
- if ($NF ~ sym_regex) {
- split($NF, symbol_array, /@|@@/);
-
- # Don't add local symbols of versioned libc's
- if (VERSIONED_LIBC && !symbol_array[2])
- continue;
-
- # We have a versioned libc
- if (symbol_array[2] && !VERSIONED_LIBC)
- VERSIONED_LIBC = 1;
-
- ADD = 1;
- # Check that we do not add duplicates
- for (y in PROCESSED_SYMBOLS) {
- if (y == $NF) {
- ADD = 0;
- break;
- }
+ # On x86, x86_64 and others, $8 is the symbol name, but on
+ # alpha, its $10, so rather use $NF, as it should be the
+ # last field
+ if ($NF ~ SYMBOL_REGEX) {
+ split($NF, symbol_array, /@|@@/);
+
+ # Don't add local symbols of versioned libc's
+ if (VERSIONED_LIBC && !symbol_array[2])
+ next;
+
+ # We have a versioned libc
+ if (symbol_array[2] && !VERSIONED_LIBC)
+ VERSIONED_LIBC = 1;
+
+ ADD = 1;
+ # Check that we do not add duplicates
+ for (y in PROCESSED_SYMBOLS) {
+ if (y == $NF) {
+ ADD = 0;
+ break;
}
+ }
- if (ADD) {
- SYMBOL_LIST[symbol_array[1]] = SYMBOL_LIST[symbol_array[1]] " " $NF;
- PROCESSED_SYMBOLS[$NF] = $NF;
- }
+ if (ADD) {
+ SYMBOL_LIST[symbol_array[1]] = SYMBOL_LIST[symbol_array[1]] " " $NF;
+ PROCESSED_SYMBOLS[$NF] = $NF;
}
+ }
- # No apparent need to handle weak __XXX symbols ... so disable
- # until we have documentation on why ...
- # If we do re-add this, need to update the `readelf` call in
- # libsandbox/ to include the -h flag again.
- continue;
-
- sym_regex = "^__" SYMBOLS[x] "(@@|$)";
- if (($5 == "WEAK") && ($NF ~ sym_regex)) {
- split($NF, symbol_array, /@@/);
-
- # Don't add local symbols of versioned libc's
- if (VERSIONED_LIBC && !symbol_array[2])
- continue;
-
- # Blacklist __getcwd on FreeBSD
- # Unleashed - May 2006
- if ((symbol_array[1] == "__getcwd") && (ABI == "FreeBSD"))
- continue;
-
- # We have a versioned libc
- if (symbol_array[2] && !VERSIONED_LIBC)
- VERSIONED_LIBC = 1;
-
- ADD = 1;
- # Check that we do not add duplicates
- for (y in PROCESSED_SYMBOLS) {
- if (y == $NF) {
- ADD = 0;
- break;
- }
+ # No apparent need to handle weak __XXX symbols ... so disable
+ # until we have documentation on why ...
+ # If we do re-add this, need to update the `readelf` call in
+ # libsandbox/ to include the -h flag again.
+ next;
+
+ if (($5 == "WEAK") && ($NF ~ WEAK_SYMBOL_REGEX)) {
+ split($NF, symbol_array, /@@/);
+
+ # Don't add local symbols of versioned libc's
+ if (VERSIONED_LIBC && !symbol_array[2])
+ next;
+
+ # Blacklist __getcwd on FreeBSD
+ # Unleashed - May 2006
+ if ((symbol_array[1] == "__getcwd") && (ABI == "FreeBSD"))
+ next;
+
+ # We have a versioned libc
+ if (symbol_array[2] && !VERSIONED_LIBC)
+ VERSIONED_LIBC = 1;
+
+ ADD = 1;
+ # Check that we do not add duplicates
+ for (y in PROCESSED_SYMBOLS) {
+ if (y == $NF) {
+ ADD = 0;
+ break;
}
+ }
- if (ADD) {
- WEAK_SYMBOLS[SYMBOLS[x]] = WEAK_SYMBOLS[SYMBOLS[x]] " " $NF;
- PROCESSED_SYMBOLS[$NF] = $NF;
- }
+ if (ADD) {
+ WEAK_SYMBOLS[SYMBOLS[x]] = WEAK_SYMBOLS[SYMBOLS[x]] " " $NF;
+ PROCESSED_SYMBOLS[$NF] = $NF;
}
}
}
diff --git a/scripts/gen_symbol_version_map.awk b/scripts/gen_symbol_version_map.awk
index a0a43c0..c92e2f9 100644
--- a/scripts/gen_symbol_version_map.awk
+++ b/scripts/gen_symbol_version_map.awk
@@ -1,5 +1,15 @@
BEGIN {
split(" " SYMBOLS_LIST, SYMBOLS);
+
+ sym_regex = "";
+ for (x in SYMBOLS) {
+ symbol = SYMBOLS[x];
+ if (sym_regex)
+ sym_regex = sym_regex "|";
+ sym_regex = sym_regex symbol;
+ }
+ SYMBOL_REGEX = "^(" sym_regex ")(@|$)";
+ WEAK_SYMBOL_REGEX = "^__(" sym_regx ")(@@|$)";
}
/^ OS\/ABI:/ {
@@ -17,81 +27,77 @@ BEGIN {
if ($4 != "FUNC" || $5 == "LOCAL" || $6 != "DEFAULT")
next;
- for (x in SYMBOLS) {
- sym_regex = "^" SYMBOLS[x] "(@|$)";
- # On x86, x86_64 and others, $8 is the symbol name, but on
- # alpha, its $10, so rather use $NF, as it should be the
- # last field
- if ($NF ~ sym_regex) {
- split($NF, symbol_array, /@|@@/);
+ # On x86, x86_64 and others, $8 is the symbol name, but on
+ # alpha, its $10, so rather use $NF, as it should be the
+ # last field
+ if ($NF ~ SYMBOL_REGEX) {
+ split($NF, symbol_array, /@|@@/);
- # Don't add local symbols of versioned libc's
- if (VERSIONED_LIBC && !symbol_array[2])
- continue;
+ # Don't add local symbols of versioned libc's
+ if (VERSIONED_LIBC && !symbol_array[2])
+ next;
- # Handle non-versioned libc's like uClibc ...
- if (!symbol_array[2])
- symbol_array[2] = "";
-
- # We have a versioned libc
- if (symbol_array[2] && !VERSIONED_LIBC)
- VERSIONED_LIBC = 1;
-
- ADD = 1;
- # Check that we do not add duplicates
- for (y in PROCESSED_SYMBOLS) {
- if (y == $NF) {
- ADD = 0;
- break;
- }
+ # Handle non-versioned libc's like uClibc ...
+ if (!symbol_array[2])
+ symbol_array[2] = "";
+
+ # We have a versioned libc
+ if (symbol_array[2] && !VERSIONED_LIBC)
+ VERSIONED_LIBC = 1;
+
+ ADD = 1;
+ # Check that we do not add duplicates
+ for (y in PROCESSED_SYMBOLS) {
+ if (y == $NF) {
+ ADD = 0;
+ break;
}
+ }
- if (ADD) {
- SYMBOL_LIST[symbol_array[2]] = SYMBOL_LIST[symbol_array[2]] " " symbol_array[1];
- PROCESSED_SYMBOLS[$NF] = $NF;
- }
+ if (ADD) {
+ SYMBOL_LIST[symbol_array[2]] = SYMBOL_LIST[symbol_array[2]] " " symbol_array[1];
+ PROCESSED_SYMBOLS[$NF] = $NF;
}
+ }
- # No apparent need to handle weak __XXX symbols ... so disable
- # until we have documentation on why ...
- # If we do re-add this, need to update the `readelf` call in
- # libsandbox/ to include the -h flag again.
- continue;
+ # No apparent need to handle weak __XXX symbols ... so disable
+ # until we have documentation on why ...
+ # If we do re-add this, need to update the `readelf` call in
+ # libsandbox/ to include the -h flag again.
+ next;
- sym_regex = "^__" SYMBOLS[x] "(@@|$)";
- if (($5 == "WEAK") && ($NF ~ sym_regex)) {
- split($NF, symbol_array, /@@/);
+ if (($5 == "WEAK") && ($NF ~ WEAK_SYMBOL_REGEX)) {
+ split($NF, symbol_array, /@@/);
- # Don't add local symbols of versioned libc's
- if (VERSIONED_LIBC && !symbol_array[2])
- continue;
+ # Don't add local symbols of versioned libc's
+ if (VERSIONED_LIBC && !symbol_array[2])
+ next;
- # Blacklist __getcwd on FreeBSD
- # Unleashed - May 2006
- if ((symbol_array[1] == "__getcwd") && (ABI == "FreeBSD"))
- continue;
+ # Blacklist __getcwd on FreeBSD
+ # Unleashed - May 2006
+ if ((symbol_array[1] == "__getcwd") && (ABI == "FreeBSD"))
+ next;
- # Handle non-versioned libc's like uClibc ...
- if (!symbol_array[2])
- symbol_array[2] = "";
-
- # We have a versioned libc
- if (symbol_array[2] && !VERSIONED_LIBC)
- VERSIONED_LIBC = 1;
-
- ADD = 1;
- # Check that we do not add duplicates
- for (y in PROCESSED_SYMBOLS) {
- if (y == $NF) {
- ADD = 0;
- break;
- }
+ # Handle non-versioned libc's like uClibc ...
+ if (!symbol_array[2])
+ symbol_array[2] = "";
+
+ # We have a versioned libc
+ if (symbol_array[2] && !VERSIONED_LIBC)
+ VERSIONED_LIBC = 1;
+
+ ADD = 1;
+ # Check that we do not add duplicates
+ for (y in PROCESSED_SYMBOLS) {
+ if (y == $NF) {
+ ADD = 0;
+ break;
}
+ }
- if (ADD) {
- SYMBOL_LIST[symbol_array[2]] = SYMBOL_LIST[symbol_array[2]] " " symbol_array[1];
- PROCESSED_SYMBOLS[$NF] = $NF;
- }
+ if (ADD) {
+ SYMBOL_LIST[symbol_array[2]] = SYMBOL_LIST[symbol_array[2]] " " symbol_array[1];
+ PROCESSED_SYMBOLS[$NF] = $NF;
}
}
}
^ permalink raw reply related [flat|nested] 2+ messages in thread
end of thread, other threads:[~2021-10-23 22:19 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-10-23 22:19 [gentoo-commits] proj/sandbox:master commit in: scripts/ Mike Frysinger
-- strict thread matches above, loose matches on Subject: below --
2019-06-25 6:42 Sergei Trofimovich
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox