1#!/bin/bash 2 3# Copyright (c) 2020 Arm Limited 4# 5# Licensed under the Apache License, Version 2.0 (the "License"); 6# you may not use this file except in compliance with the License. 7# You may obtain a copy of the License at 8# 9# http://www.apache.org/licenses/LICENSE-2.0 10# 11# Unless required by applicable law or agreed to in writing, software 12# distributed under the License is distributed on an "AS IS" BASIS, 13# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14# See the License for the specific language governing permissions and 15# limitations under the License. 16 17OBJDUMP=arm-none-eabi-objdump 18GDB=gdb-multiarch 19 20# Check if the ELF file specified is compatible 21if test $# -eq 0 || ! file $1 | grep "ELF" | grep "ARM" | grep "32" &>/dev/null; then 22 echo "Incompatible file: $1" 1>&2 23 exit 1 24fi 25 26# Extract the full path 27AXF_PATH=$(realpath $1) 28#Dump all objects that have a name containing FIH_LABEL 29ADDRESSES=$($OBJDUMP $AXF_PATH -t | grep "FIH_LABEL") 30# strip all data except "address, label_name" 31ADDRESSES=$(echo "$ADDRESSES" | sed "s/\([[:xdigit:]]*\).*\(FIH_LABEL_FIH_CALL_[a-zA-Z]*\)_.*/0x\1, \2/g") 32# Sort by address in ascending order 33ADDRESSES=$(echo "$ADDRESSES" | sort) 34# In the case that there is a START followed by another START take the first one 35ADDRESSES=$(echo "$ADDRESSES" | sed "N;s/\(.*START.*\)\n\(.*START.*\)/\1/;P;D") 36# Same for END except take the second one 37ADDRESSES=$(echo "$ADDRESSES" | sed "N;s/\(.*END.*\)\n\(.*END.*\)/\2/;P;D") 38 39# Output in CSV format with a label 40echo "Address, Type" 41echo "$ADDRESSES" 42