blob: 3b42747b7772029212c2c2214dd63d83466a04c7 [file] [log] [blame]
Raef Colesb3d343b2020-12-08 09:31:43 +00001#!/usr/bin/env bash
2# Copyright (c) 2021, Arm Limited. All rights reserved.
3#
4# SPDX-License-Identifier: BSD-3-Clause
5
6
7set_default AXF_FILE ${BUILD_DIR}/bin/tfm_s.axf
8set_default OBJDUMP arm-none-eabi-objdump
9set_default GDB gdb-multiarch
10
11if ! test -f ${AXF_FILE}
12then
13 error "no such file ${AXF_FILE}"
14fi
15
16# Check if the ELF file specified is compatible
17if ! file ${AXF_FILE} | grep "ELF.*32.*ARM" &>/dev/null
18then
19 error "Incompatible file: ${AXF_FILE}"
20fi
21
22#TODO clean this up, and use less regex
23
24# Dump all objects that have a name containing FIH_LABEL
25ADDRESSES=$($OBJDUMP $AXF_FILE -t | grep "FIH_LABEL")
26# strip all data except "address, label_name"
27ADDRESSES=$(echo "$ADDRESSES" | sed "s/\([[:xdigit:]]*\).*\(FIH_LABEL_.*\)_[0-9]*_[0-9]*/0x\1, \2/g")
28# Sort by address in ascending order
29ADDRESSES=$(echo "$ADDRESSES" | sort)
30# In the case that there is a START followed by another START take the first one
31ADDRESSES=$(echo "$ADDRESSES" | sed "N;s/\(.*START.*\)\n\(.*START.*\)/\1/;P;D")
32# Same for END except take the second one
33ADDRESSES=$(echo "$ADDRESSES" | sed "N;s/\(.*END.*\)\n\(.*END.*\)/\2/;P;D")
34
35# Output in CSV format with a label
36echo "Address, Type" > ${BUILD_DIR}/fih_manifest.csv
37echo "$ADDRESSES" >> ${BUILD_DIR}/fih_manifest.csv