lib.prov, lib.req: enhance ProvidedSymbols

This enhances ProvidedSymbols() in two ways:
* fixes st_shndx check for the case when it is not $7 in
"readelf --wide --dyn-syms" output as it happens on some architectures
like ppc64le;
* filters out special symbols (__bss_start, _edata, _end, _fini, _init)
after stripping of versioning.

Co-Authored-by: Dmitry V. Levin <ldv@altlinux.org>
This commit is contained in:
Gleb Fotengauer-Malinovskiy 2018-12-05 19:18:46 +03:00 committed by Dmitry V. Levin
parent 3081d856c6
commit 4f4a1d1465
2 changed files with 42 additions and 38 deletions

View File

@ -117,25 +117,27 @@ ProvidedSymbols()
{
readelf --wide --dyn-syms "$1" |
awk '+$1 && NF>=8 &&
# dl-lookup.c: /st_value
($2!="00000000" && $2!="0000000000000000" || $4=="TLS") &&
# dl-lookup.c: /st_shndx
($7!="UND") &&
# dl-lookup.c: /ALLOWED_STT
($4=="NOTYPE" || $4=="OBJECT" || $4 == "FUNC" || $4=="COMMON" || $4=="TLS" || $4=="IFUNC") &&
# dl-lookup.c: /hidden
($6=="DEFAULT" || $6=="PROTECTED") &&
# dl-lookup.c: /switch.*ST_BIND
($5=="GLOBAL" || $5=="WEAK" || $5 == "UNIQUE") &&
# Ignore special symbols found in each library:
($8!="__bss_start" && $8!="_edata" && $8!="_end" && $8!="_fini" && $8!="_init") {
sym = $8
# No symbol versioning yet.
ix = index(sym, "@")
if (ix > 1)
sym = substr(sym, 0, ix-1)
print sym
}' |
# dl-lookup.c: /st_value
($2!="00000000" && $2!="0000000000000000" || $4=="TLS") &&
# dl-lookup.c: /ALLOWED_STT
($4=="NOTYPE" || $4=="OBJECT" || $4 == "FUNC" || $4=="COMMON" || $4=="TLS" || $4=="IFUNC") &&
# dl-lookup.c: /hidden
($6=="DEFAULT" || $6=="PROTECTED") &&
# dl-lookup.c: /switch.*ST_BIND
($5=="GLOBAL" || $5=="WEAK" || $5 == "UNIQUE") {
# dl-lookup.c: /st_shndx
match($0, "[[:space:]][[:digit:]]+[[:space:]]+([^[:space:]()@]+)(@+[^[:space:]()@]+)?$", a)
sym = a[1]
if (sym == "" ||
# ignore special symbols found in each library
sym == "__bss_start" ||
sym == "_edata" ||
sym == "_end" ||
sym == "_fini" ||
sym == "_init")
next
print sym
}' |
LC_ALL=C sort -u
}

View File

@ -221,25 +221,27 @@ ProvidedSymbols()
{
readelf --wide --dyn-syms "$1" |
awk '+$1 && NF>=8 &&
# dl-lookup.c: /st_value
($2!="00000000" && $2!="0000000000000000" || $4=="TLS") &&
# dl-lookup.c: /st_shndx
($7!="UND") &&
# dl-lookup.c: /ALLOWED_STT
($4=="NOTYPE" || $4=="OBJECT" || $4 == "FUNC" || $4=="COMMON" || $4=="TLS" || $4=="IFUNC") &&
# dl-lookup.c: /hidden
($6=="DEFAULT" || $6=="PROTECTED") &&
# dl-lookup.c: /switch.*ST_BIND
($5=="GLOBAL" || $5=="WEAK" || $5 == "UNIQUE") &&
# Ignore special symbols found in each library:
($8!="__bss_start" && $8!="_edata" && $8!="_end" && $8!="_fini" && $8!="_init") {
sym = $8
# No symbol versioning yet.
ix = index(sym, "@")
if (ix > 1)
sym = substr(sym, 0, ix-1)
print sym
}' |
# dl-lookup.c: /st_value
($2!="00000000" && $2!="0000000000000000" || $4=="TLS") &&
# dl-lookup.c: /ALLOWED_STT
($4=="NOTYPE" || $4=="OBJECT" || $4 == "FUNC" || $4=="COMMON" || $4=="TLS" || $4=="IFUNC") &&
# dl-lookup.c: /hidden
($6=="DEFAULT" || $6=="PROTECTED") &&
# dl-lookup.c: /switch.*ST_BIND
($5=="GLOBAL" || $5=="WEAK" || $5 == "UNIQUE") {
# dl-lookup.c: /st_shndx
match($0, "[[:space:]][[:digit:]]+[[:space:]]+([^[:space:]()@]+)(@+[^[:space:]()@]+)?$", a)
sym = a[1]
if (sym == "" ||
# ignore special symbols found in each library
sym == "__bss_start" ||
sym == "_edata" ||
sym == "_end" ||
sym == "_fini" ||
sym == "_init")
next
print sym
}' |
LC_ALL=C sort -u
}