diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/romlib/Makefile | 3 | ||||
-rwxr-xr-x | lib/romlib/gen_combined_bl1_romlib.sh | 53 | ||||
-rwxr-xr-x | lib/romlib/genwrappers.sh | 2 | ||||
-rw-r--r-- | lib/romlib/jmptbl.i | 17 |
4 files changed, 67 insertions, 8 deletions
diff --git a/lib/romlib/Makefile b/lib/romlib/Makefile index 46b920682..00dde31cd 100644 --- a/lib/romlib/Makefile +++ b/lib/romlib/Makefile @@ -15,6 +15,7 @@ LIBS = -lmbedtls -lfdt -lc INC = $(INCLUDES:-I%=-I../../%) PPFLAGS = $(INC) $(DEFINES) -P -D__ASSEMBLY__ -D__LINKER__ -MD -MP -MT $(BUILD_DIR)/romlib.ld OBJS = $(BUILD_DIR)/jmptbl.o $(BUILD_DIR)/init.o +MAPFILE = ../../$(BUILD_PLAT)/romlib/romlib.map V ?= 0 ifeq ($(V),0) @@ -25,7 +26,7 @@ endif ifeq ($(DEBUG),1) CFLAGS := -g - LDFLAGS := -g + LDFLAGS := -g --gc-sections -O1 -Map=$(MAPFILE) endif diff --git a/lib/romlib/gen_combined_bl1_romlib.sh b/lib/romlib/gen_combined_bl1_romlib.sh new file mode 100755 index 000000000..1e3f73a0f --- /dev/null +++ b/lib/romlib/gen_combined_bl1_romlib.sh @@ -0,0 +1,53 @@ +#!/bin/sh +# Copyright (c) 2018, ARM Limited and Contributors. All rights reserved. +# +# SPDX-License-Identifier: BSD-3-Clause + +set -e + +output="bl1_romlib.bin" + +# Set trap for removing temporary file +trap 'r=$?;rm -f $bin_path/$$.tmp;exit $r' EXIT HUP QUIT INT TERM + +# Read input parameters +for i +do + case $i in + -o) + output=$2 + shift 2 + ;; + --) + shift + break + ;; + -*) + echo usage: gen_combined_bl1_romlib.sh [-o output] path_to_build_directory >&2 + ;; + esac +done + + +bin_path=$1 +romlib_path=$1/romlib +bl1_file="$1/bl1/bl1.elf" +romlib_file="$1/romlib/romlib.elf" +bl1_end="" +romlib_begin="" + +# Get address of __BL1_ROM_END__ +bl1_end=`nm -a "$bl1_file" | +awk '$3 == "__BL1_ROM_END__" {print "0x"$1}'` + +# Get start address of romlib "text" section +romlib_begin=`nm -a "$romlib_file" | +awk '$3 == ".text" {print "0x"$1}'` + +# Character "U" will be read as "55" in hex when it is +# concatenated with bl1.bin. Generate combined BL1 and ROMLIB +# binary with filler bytes for juno +(cat $bin_path/bl1.bin + yes U | sed $(($romlib_begin - $bl1_end))q | tr -d '\n' + cat $bin_path/romlib/romlib.bin) > $bin_path/$$.tmp && +mv $bin_path/$$.tmp $bin_path/$output diff --git a/lib/romlib/genwrappers.sh b/lib/romlib/genwrappers.sh index bcf670b98..48ee5a43b 100755 --- a/lib/romlib/genwrappers.sh +++ b/lib/romlib/genwrappers.sh @@ -31,7 +31,7 @@ do done awk '{sub(/[:blank:]*#.*/,"")} -!/^$/ {print $1*4, $2, $3}' "$@" | +!/^$/ && !/\\tpatch$/ {print $1*4, $2, $3}' "$@" | while read idx lib sym do file=$build/${lib}_$sym diff --git a/lib/romlib/jmptbl.i b/lib/romlib/jmptbl.i index 338cd8a71..5eca5aab3 100644 --- a/lib/romlib/jmptbl.i +++ b/lib/romlib/jmptbl.i @@ -3,6 +3,10 @@ # # SPDX-License-Identifier: BSD-3-Clause # +# Format: +# index lib function [patch] +# Add "patch" at the end of the line to patch a function. For example: +# 14 mbedtls mbedtls_memory_buffer_alloc_init patch 0 rom rom_lib_init 1 fdt fdt_getprop_namelen @@ -27,9 +31,10 @@ 20 mbedtls mbedtls_pk_init 21 mbedtls mbedtls_pk_parse_subpubkey 22 mbedtls mbedtls_pk_verify_ext -23 mbedtls mbedtls_platform_set_snprintf -24 mbedtls mbedtls_x509_get_rsassa_pss_params -25 mbedtls mbedtls_x509_get_sig_alg -26 mbedtls mbedtls_md_info_from_type -27 c exit -28 c atexit +23 mbedtls mbedtls_platform_set_calloc_free +24 mbedtls mbedtls_platform_set_snprintf +25 mbedtls mbedtls_x509_get_rsassa_pss_params +26 mbedtls mbedtls_x509_get_sig_alg +27 mbedtls mbedtls_md_info_from_type +28 c exit +29 c atexit
\ No newline at end of file |