]> git.ipfire.org Git - ipfire-3.x.git/commitdiff
naoki: Add feature to find weak symbols.
authorMichael Tremer <michael.tremer@ipfire.org>
Wed, 15 Sep 2010 21:43:29 +0000 (23:43 +0200)
committerMichael Tremer <michael.tremer@ipfire.org>
Wed, 15 Sep 2010 21:43:29 +0000 (23:43 +0200)
Closes #71.

tools/functions-packager-find

index 197cdb0f9ad49e65a384604ed7ad0247c6b132ee..e89831afe4cd502fddfe4f176c6ff39517672c61 100644 (file)
@@ -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
+}