diff options
Diffstat (limited to 'scripts/gen_symbol_version_map.awk')
-rw-r--r-- | scripts/gen_symbol_version_map.awk | 137 |
1 files changed, 73 insertions, 64 deletions
diff --git a/scripts/gen_symbol_version_map.awk b/scripts/gen_symbol_version_map.awk index a0a43c0..661cb1d 100644 --- a/scripts/gen_symbol_version_map.awk +++ b/scripts/gen_symbol_version_map.awk @@ -1,5 +1,18 @@ +# Read the symbols list and create regexs to use for processing readelf output. BEGIN { - split(" " SYMBOLS_LIST, SYMBOLS); + sym_regex = ""; + while ((getline line < SYMBOLS_FILE) > 0) { + if (line ~ /^ *#/ || line ~ /^$/) + continue; + split(line, fields); + symbol = fields[1]; + + 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 +30,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; } } } |