diff options
author | Mike Frysinger <vapier@gentoo.org> | 2021-10-23 04:54:55 -0400 |
---|---|---|
committer | Mike Frysinger <vapier@gentoo.org> | 2021-10-23 18:18:03 -0400 |
commit | 3f38f41fc1ea418fb9aa57e24ae29b4319066ae6 (patch) | |
tree | f45fe59adaa19d53caadb5d766ac41368bd6211a | |
parent | scripts: rewrite main processing loops for significant speedup (diff) | |
download | sandbox-3f38f41f.tar.gz sandbox-3f38f41f.tar.bz2 sandbox-3f38f41f.zip |
libsandbox: move symbols.h.in parsing to scripts
In preparation for extending the symbol format, move parsing out of
the makefile (which is a basic sed expression) to the awk scripts.
This also has a nice side benefit of removing one automake warning.
It is slightly more code, but the scripts will be diverging shortly,
so it's unavoidable.
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
-rw-r--r-- | libsandbox/local.mk | 3 | ||||
-rw-r--r-- | scripts/gen_symbol_header.awk | 10 | ||||
-rw-r--r-- | scripts/gen_symbol_version_map.awk | 9 | ||||
-rw-r--r-- | scripts/gen_trace_header.awk | 13 |
4 files changed, 25 insertions, 10 deletions
diff --git a/libsandbox/local.mk b/libsandbox/local.mk index 1a9c5f9..a386505 100644 --- a/libsandbox/local.mk +++ b/libsandbox/local.mk @@ -48,12 +48,11 @@ TRACE_FILES = $(wildcard $(top_srcdir)/%D%/trace/*.[ch] $(top_srcdir)/%D%/trace/ SCRIPT_DIR = $(top_srcdir)/scripts SYMBOLS_FILE = $(top_srcdir)/%D%/symbols.h.in -SYMBOLS_LIST = $(shell $(SED) -n '/^[^\#]/p' $(SYMBOLS_FILE)) SYMBOLS_WRAPPERS = $(wildcard $(top_srcdir)/%D%/wrapper-funcs/*.[ch]) GEN_VERSION_MAP_SCRIPT = $(SCRIPT_DIR)/gen_symbol_version_map.awk GEN_HEADER_SCRIPT = $(SCRIPT_DIR)/gen_symbol_header.awk GEN_TRACE_SCRIPT = $(SCRIPT_DIR)/gen_trace_header.awk -SB_AWK = LC_ALL=C $(AWK) -v SYMBOLS_LIST="$(SYMBOLS_LIST)" -v srcdir="$(top_srcdir)/%D%" -f +SB_AWK = LC_ALL=C $(AWK) -v SYMBOLS_FILE="$(SYMBOLS_FILE)" -v srcdir="$(top_srcdir)/%D%" -f %D%/libsandbox.map: $(SYMBOLS_FILE) $(GEN_VERSION_MAP_SCRIPT) @$(MKDIR_P) %D% diff --git a/scripts/gen_symbol_header.awk b/scripts/gen_symbol_header.awk index 2d26c5a..48d2f9d 100644 --- a/scripts/gen_symbol_header.awk +++ b/scripts/gen_symbol_header.awk @@ -1,9 +1,13 @@ +# Read the symbols list and create regexs to use for processing readelf output. BEGIN { - COUNT = split(" " SYMBOLS_LIST, SYMBOLS); + COUNT = 0; sym_regex = ""; - for (x in SYMBOLS) { - symbol = SYMBOLS[x]; + while ((getline symbol < SYMBOLS_FILE) > 0) { + if (symbol ~ /^ *#/ || symbol ~ /^$/) + continue; + + SYMBOLS[++COUNT] = symbol; if (sym_regex) sym_regex = sym_regex "|"; sym_regex = sym_regex symbol; diff --git a/scripts/gen_symbol_version_map.awk b/scripts/gen_symbol_version_map.awk index c92e2f9..cd0aa84 100644 --- a/scripts/gen_symbol_version_map.awk +++ b/scripts/gen_symbol_version_map.awk @@ -1,9 +1,10 @@ +# Read the symbols list and create regexs to use for processing readelf output. BEGIN { - split(" " SYMBOLS_LIST, SYMBOLS); - sym_regex = ""; - for (x in SYMBOLS) { - symbol = SYMBOLS[x]; + while ((getline symbol < SYMBOLS_FILE) > 0) { + if (symbol ~ /^ *#/ || symbol ~ /^$/) + continue; + if (sym_regex) sym_regex = sym_regex "|"; sym_regex = sym_regex symbol; diff --git a/scripts/gen_trace_header.awk b/scripts/gen_trace_header.awk index 846294c..e9d84a6 100644 --- a/scripts/gen_trace_header.awk +++ b/scripts/gen_trace_header.awk @@ -1,5 +1,16 @@ +# Read the symbols list and create regexs to use for processing readelf output. +function read_symbols() { + COUNT = 0; + while ((getline symbol < SYMBOLS_FILE) > 0) { + if (symbol ~ /^ *#/ || symbol ~ /^$/) + continue; + + SYMBOLS[++COUNT] = symbol; + } +} + BEGIN { - COUNT = split(" " SYMBOLS_LIST, SYMBOLS); + read_symbols(); if (MODE == "gen") { for (x in SYMBOLS) { |