From: Michael Tremer Date: Wed, 15 Sep 2010 21:43:29 +0000 (+0200) Subject: naoki: Add feature to find weak symbols. X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e3df4e6669058446c21756605ba8f171ffa17abd;p=ipfire-3.x.git naoki: Add feature to find weak symbols. Closes #71. --- diff --git a/tools/functions-packager-find b/tools/functions-packager-find index 197cdb0f9..e89831afe 100644 --- a/tools/functions-packager-find +++ b/tools/functions-packager-find @@ -36,6 +36,7 @@ function find_requires() { # Others local others=$(find_python_requires ${dirs}) + others="${others} $(find_weak_symbols_requires ${dirs})" # Get provides, because packages should not depend on features they provide # by themselves. @@ -45,6 +46,7 @@ function find_requires() { local require local requires for require in $(listsort ${interpreters} ${neededs} ${links} ${others}); do + [ "${require:0:3}" = "ld-" ] && continue listmatch ${require} ${provides} || requires="${requires} ${require}" done @@ -63,6 +65,7 @@ function find_provides() { # Others local others=$(find_python_provides ${dirs}) + others="${others} $(find_weak_symbols_provides ${dirs})" listsort ${sonames} ${others} } @@ -148,3 +151,44 @@ function find_python_requires() { fi done } + +function find_weak_symbols_provides() { + local dirs=$@ + + local file + local soname + local symbol + for file in $(find_elf_files ${dirs}); do + soname=$(file_get_soname ${file}) + [ -z "${soname}" ] && continue + + for symbol in $(objdump -p ${file} | grep -E "^[0-9]+" | awk '{ print $4 }'); do + [ "${symbol}" = "${soname}" ] && continue + + echo "${soname}(${symbol})" + done + done | sort -u +} + +function find_weak_symbols_requires() { + local dirs=$@ + + local file + for file in $(find_elf_files ${dirs}); do + objdump -p ${file} | awk 'BEGIN { START=0; LIBNAME=""; } + /^$/ { START=0; } + /^Dynamic Section:$/ { START=1; } + (START==1) && /NEEDED/ { + print $2; + } + (START==2) && /^[A-Za-z]/ { START=3; } + /^Version References:$/ { START=2; } + (START==2) && /required from/ { + sub(/:/, "", $3); + LIBNAME=$3; + } + (START==2) && (LIBNAME!="") && ($4!="") && (($4~/^GLIBC_*/) || ($4~/^GCC_*/)) { + print LIBNAME "(" $4 ")"; + }' + done | sort -u +}