diff options
Diffstat (limited to 'scripts')
-rw-r--r-- | scripts/gen_symbol_header.awk | 128 | ||||
-rw-r--r-- | scripts/gen_symbol_version_map.awk | 132 |
2 files changed, 136 insertions, 124 deletions
diff --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; } } } |