plugin: more aggressive name change to avoid conflicts
[ia32rtools.git] / run_exp.sh
index edcc3b0..319c2ab 100755 (executable)
@@ -1,15 +1,31 @@
 #!/bin/sh
 
-grep '@' $1 | awk '{print $1}' > $2_explist
+# export decorated symbols using undecorated ones from .asm
+# $1 - .def
+# $2 - .in_c
+outf=$3
 
-echo ".text" > $2
-echo ".align 4" >> $2
+grep '@' $1 | grep -v '\<DATA\>' | grep -v '=' | \
+  awk '{print $1}' > ${outf}_explist
 
-cat $2_explist | while read i; do
-  sym=`echo $i | awk -F@ '{print $1}'`
+echo ".text" > $outf
+echo ".align 4" >> $outf
 
-  echo ".globl _$i" >> $2
-  echo "_$i:" >> $2
-  echo "  jmp $sym" >> $2
-  echo >> $2
+cat ${outf}_explist | while read i; do
+  s0=`echo $i | cut -c 1`
+  if [ "$s0" = "@" ]; then
+    sym=`echo $i | awk -F@ '{print $2}'`
+    pre=""
+  else
+    sym=`echo $i | awk -F@ '{print $1}'`
+    pre="_"
+  fi
+  if grep -q "$sym" $2; then
+    continue
+  fi
+
+  echo ".globl $pre$i" >> $outf
+  echo "$pre$i:" >> $outf
+  echo "  jmp $sym" >> $outf
+  echo >> $outf
 done