2021-02-18 04:20:28 +00:00
|
|
|
#!/bin/bash
|
|
|
|
|
2021-02-27 01:43:40 +00:00
|
|
|
allProgramRadixFile="FunctionRadix"
|
2021-03-10 17:00:51 +00:00
|
|
|
programToIndexMap="ProgramMap.txt"
|
2021-02-27 01:43:40 +00:00
|
|
|
index=0
|
|
|
|
|
2021-03-10 17:00:51 +00:00
|
|
|
# clear the files
|
|
|
|
rm -rf $allProgramRadixFile.addr $allProgramRadixFile.do $programToIndexMap
|
|
|
|
|
|
|
|
echo "radix define Functions {" > $allProgramRadixFile.do
|
|
|
|
|
2021-02-18 04:20:28 +00:00
|
|
|
for objDumpFile in "$@";
|
|
|
|
do
|
|
|
|
# get the lines with named labels from the obj files.
|
2021-02-27 01:43:40 +00:00
|
|
|
# 64 bit addresses
|
|
|
|
listOfAddr16=`egrep -i '^[0-9]{16} <[0-9a-zA-Z_]+>' $objDumpFile`
|
|
|
|
# 32 bit addresses
|
|
|
|
listOfAddr8=`egrep -i '^[0-9]{8} <[0-9a-zA-Z_]+>' $objDumpFile`
|
|
|
|
listOfAddr=`echo "$listOfAddr16" "$listOfAddr8"`
|
2021-02-18 04:20:28 +00:00
|
|
|
|
|
|
|
# parse out the addresses and the labels
|
|
|
|
addresses=`echo "$listOfAddr" | awk '{print $1}'`
|
|
|
|
labels=`echo "$listOfAddr" | awk '{print "\""$2"\"", "-color \"SpringGreen\","}' | tr -d '<>:'`
|
|
|
|
|
|
|
|
echo "$addresses" > $objDumpFile.addr
|
|
|
|
|
|
|
|
# need to add some formatting to each line
|
|
|
|
numLines=`echo "$listOfAddr" | wc -l`
|
|
|
|
prefix=`yes " 16#" | head -n $numLines`
|
|
|
|
midfix=`yes "# " | head -n $numLines`
|
|
|
|
|
|
|
|
# paste echos each of the 4 parts on a per line basis.
|
|
|
|
#-d'\0' sets no delimiter
|
|
|
|
temp=`paste -d'\0' <(echo "$prefix") <(echo "$addresses") <(echo "$midfix") <(echo "$labels")`
|
|
|
|
|
|
|
|
# remove the last comma
|
|
|
|
temp2=${temp::-1}
|
|
|
|
|
|
|
|
echo "radix define Functions {" > $objDumpFile.do
|
|
|
|
echo "$temp2" >> $objDumpFile.do
|
|
|
|
echo " -default hex -color green" >> $objDumpFile.do
|
|
|
|
echo "}" >> $objDumpFile.do
|
|
|
|
|
2021-02-27 01:43:40 +00:00
|
|
|
# now create the all in one version
|
|
|
|
# put the index at the begining of each line
|
|
|
|
|
2021-03-10 17:00:51 +00:00
|
|
|
# first convert the index to a string, 16 bits length
|
|
|
|
# then duplicate the index numlines times
|
|
|
|
# concat the index with the address
|
|
|
|
indexStr=`printf "%04x" "$index"`
|
|
|
|
copyIndex=`yes "$indexStr" | head -n $numLines`
|
|
|
|
allAddresses=`paste -d'\0' <(printf "%s" "$copyIndex") <(echo "$addresses")`
|
|
|
|
printf "%s\n" "$allAddresses" >> $allProgramRadixFile.addr
|
|
|
|
|
|
|
|
allAddressesTemp=`paste -d'\0' <(echo "$prefix") <(echo "$allAddresses") <(echo "$midfix") <(echo "$labels")`
|
|
|
|
printf "%s\n" "$allAddressesTemp" >> $allProgramRadixFile.do
|
|
|
|
|
|
|
|
testName=`echo "$objDumpFile" | sed -e "s/.*work\/\(.*\)\.elf\.objdump/\1/g"`
|
|
|
|
printf "$testName\n" >> $programToIndexMap
|
2021-02-27 01:43:40 +00:00
|
|
|
|
|
|
|
index=$(($index+1))
|
|
|
|
|
2021-02-18 04:20:28 +00:00
|
|
|
done
|
2021-03-10 17:00:51 +00:00
|
|
|
|
|
|
|
# remove the last comma from the all radix
|
|
|
|
# '$ selects the last line
|
|
|
|
sed -i '$ s/,$//g' $allProgramRadixFile.do
|
|
|
|
|
|
|
|
echo "}" >> $allProgramRadixFile.do
|