aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFeng Tang <feng.tang@intel.com>2010-06-13 17:10:09 +0800
committerFeng Tang <feng.tang@intel.com>2010-07-20 11:10:03 +0800
commitcc4e4dffafddf46546cf3667ca62b2fed303f3d9 (patch)
tree7e6f0a777841ad08714914fc312fdd6293fa790f
parent406b3ea5275361e75db5bcba912e4d364e8f65df (diff)
downloadsyslinux-cc4e4dffafddf46546cf3667ca62b2fed303f3d9.tar.gz
syslinux-cc4e4dffafddf46546cf3667ca62b2fed303f3d9.tar.xz
syslinux-cc4e4dffafddf46546cf3667ca62b2fed303f3d9.zip
elflink: add modules.dep gen sh
-rwxr-xr-xelf_gen_dep.sh111
1 files changed, 111 insertions, 0 deletions
diff --git a/elf_gen_dep.sh b/elf_gen_dep.sh
new file mode 100755
index 00000000..654f96d5
--- /dev/null
+++ b/elf_gen_dep.sh
@@ -0,0 +1,111 @@
+#!/bin/sh
+
+#######################################################
+# Round 1: get all the loacl and external symbols
+#######################################################
+
+for i in com32/elflink/modules/*.c32 core/extlinux.elf core/isolinux.elf core/pxelinux.elf
+do
+ # module=$(echo $i | sed "s/^\(.*\).o$/\1/")
+
+ # remove the path infomation
+ module=$(echo $i | sed "s/^.*\/\(.*\)$/\1/")
+
+ readelf -s $i > temp.txt
+ #Get the last 2 items of each line
+ cut -c47- temp.txt > $module.txt
+ rm temp.txt
+
+ #Get the unresolved symbols
+ sed -n -e "/UND $/d" -e "/_GLOBAL_OFFSET_TABLE_/d" -e "s/^.UND.\(.*\)$/\1/p" $module.txt > $module.ext
+
+ #Get the local symbols
+ sed -n -e "/UND/d" -e "/ABS/d" -e "/...[0-9] $/d" -e "/...[0-9] \./d" -e "/...[0-9]/p" $module.txt > $module.int
+ sed -i -e "s/^.....//g" $module.int
+ sed -i -e "s/^\(.*\)$/\1 <$module>/g" $module.int
+
+ cat $module.int >> all.txt
+done
+
+
+touch modules.dep
+
+#######################################################
+# Round 2: get all the loacl and external symbols
+#######################################################
+
+# Consolidate the dependent modules to one line and remove
+# the redundant ones, and the "core"
+rm_cr ()
+{
+ touch rmcr.tmp
+ all_dep=$module:
+ space=' '
+
+ while read line
+ do
+ # skip the module which is alreay on the list
+ grep $line rmcr.tmp > /dev/null && continue
+
+ # grep extlinux/isolinux and remove them
+ echo $line | grep extlinux > /dev/null && continue
+ echo $line | grep isolinux > /dev/null && continue
+ echo $line | grep pxelinux > /dev/null && continue
+
+ all_dep=$all_dep$space$line
+ echo $all_dep > rmcr.tmp
+ done
+
+ echo $all_dep >> modules.dep
+ rm rmcr.tmp
+}
+
+# Find the symbol belongs to which module by screening all.txt, do it
+# one by one, and the result "resolve.tmp" will be a file like:
+# a.c32
+# b.c32
+# c.c32
+resolve_sym ()
+{
+ touch resolve.tmp
+
+ while read symbol
+ do
+ #echo $symbol
+ sed -n -e "s/^$symbol <\(.*\)>/\1/p" all.txt >> resolve.tmp
+ #grep $symbol all.txt
+ done
+
+ rm_cr < resolve.tmp
+ rm resolve.tmp
+}
+
+#only test name start with a/b
+#rm [c-z]*.ext
+
+if [ -e modules.dep ]
+then
+ rm modules.dep
+ touch modules.dep
+fi
+
+# Don't need to resolve the core symbols
+for i in extlinux isolinux pxelinux
+do
+ if [ -e $i.elf.ext ]
+ then
+ rm $i.elf.ext
+ fi
+done
+
+for i in *.ext
+do
+ module=$(echo $i | sed "s/^\(.*\).ext$/\1/")
+ resolve_sym < $i
+done
+
+# Do some cleanup
+rm *.txt
+rm *.ext
+rm *.int
+echo ELF modules dependency is bult up, pls check modules.dep!