Remove script/llvm-objcopy-wrapper

The llvm-objcopy-wrapper script was introduced in commit 98d863a5c0b2
("Experimental Clang support") because llvm-objcopy would not support
some options needed to produce the final TEE binaries from tee.elf or
cause errors when building them. However, since commit 1a9edabc0ed4
("core: link.mk: use gen_tee_bin.py"), objcopy is not used for this
purpose anymore. Thus we can safely use llvm-objcopy.

Signed-off-by: Jerome Forissier <jerome@forissier.org>
Reviewed-by: Jens Wiklander <jens.wiklander@linaro.org>
diff --git a/mk/clang.mk b/mk/clang.mk
index 44cdd15..28367e7 100644
--- a/mk/clang.mk
+++ b/mk/clang.mk
@@ -23,7 +23,7 @@
 
 AR$(sm)		:= $(ccache-cmd)llvm-ar
 NM$(sm)		:= llvm-nm
-OBJCOPY$(sm)	:= $(SCRIPTS_DIR)/llvm-objcopy-wrapper
+OBJCOPY$(sm)	:= llvm-objcopy
 
 # llvm-objdump:
 # - Does not support mixed 32-bit ARM and Thumb instructions
diff --git a/scripts/llvm-objcopy-wrapper b/scripts/llvm-objcopy-wrapper
deleted file mode 100755
index fb67a98..0000000
--- a/scripts/llvm-objcopy-wrapper
+++ /dev/null
@@ -1,88 +0,0 @@
-#!/bin/bash
-# SPDX-License-Identifier: BSD-2-Clause
-#
-# Copyright (c) 2019, Linaro Limited
-#
-# This is a wrapper script to llvm-objcopy to add support for:
-#  - The --pad-to argument
-#  - Regular expressions in --only-section= and --remove-section
-#  - Creating empty output files when no section match
-#  - Allowing removal of sections that are referenced by some other sections
-#    by default (--allow-broken-links).
-#
-# Depends on llvm-readelf.
-
-args=("--allow-broken-links") # llvm-objcopy >= 9.0
-only_section_re=()
-remove_section_re=()
-for arg in "$@"; do
-	if [ "$pad_found" ]; then
-		pad_addr="$arg"
-		pad_found=
-		continue
-	fi
-	case "$arg" in
-		--pad-to)
-			pad_found=1
-			continue
-			;;
-		--only-section=*)
-			re=$(echo "$arg" | sed s/--only-section=//)
-			only_section_re+=("$re")
-			continue
-			;;
-		--remove-section=*)
-			re=$(echo "$arg" | sed s/--remove-section=//)
-			remove_section_re+=("$re")
-			continue
-			;;
-	esac
-	args+=("$arg")
-done
-
-in="${@: -2:1}"
-out="${@: -1:1}"
-if [ ! -e "$in" ]; then
-	in=$out # That is good enough for our use cases
-fi
-
-if [ '${only_section_re[@]}''${remove_section_re[@]}' ]; then
-	sections=$(llvm-readelf -sections $in | grep ' *\[ *[0-9]*] [^ ]' | sed 's/ *\[ *[0-9]*] \(.[^ ]*\).*/\1/')
-	for s in $sections; do
-		for re in "${only_section_re[@]}"; do
-			if [ "$(echo $s | grep -- $re)" != "" ]; then
-				args+=("--only-section=$s")
-				break
-			fi
-		done
-		for re in "${remove_section_re[@]}"; do
-			if [ "$(echo $s | grep -- $re)" != "" ]; then
-				args+=("--remove-section=$s")
-				break
-			fi
-		done
-	done
-fi
-
-pad_sz=0
-if [ "$pad_addr" ]; then
-
-	# Find address and size of last PROGBITS section in input file
-	addr_sz=$(llvm-readelf -sections $in | grep PROGBITS | sed 's/.*PROGBITS *\([^ ]*\) [^ ]* \([^ ]*\).*/\1 \2/' | sort -n | tail -1)
-	read addr sz <<< "$addr_sz"
-
-	# Now figure out the size of the padding. Can be 0.
-	pad_sz=$(($pad_addr - 0x$addr - 0x$sz))
-fi
-
-# Run llvm-objcopy without "--pad-to <addr>" and with expanded
-# --only-section/--remove-section
-if [ "$VV" = 1 ]; then
-	echo Running: llvm-objcopy "${args[@]}"
-fi
-llvm-objcopy "${args[@]}" || exit $?
-
-# Pad with zeroes if necessary
-if [ $pad_sz -gt 0 ]; then
-	truncate -s +$pad_sz $out
-fi
diff --git a/ta/ta.mk b/ta/ta.mk
index 522ab29..b961663 100644
--- a/ta/ta.mk
+++ b/ta/ta.mk
@@ -192,8 +192,7 @@
 	$(eval $(call copy-file, $(f), $(out-dir)/export-$(sm)/keys)))
 
 # Copy the scripts
-ta-scripts = scripts/sign_encrypt.py scripts/symbolize.py \
-	scripts/llvm-objcopy-wrapper
+ta-scripts = scripts/sign_encrypt.py scripts/symbolize.py
 $(foreach f, $(ta-scripts), \
 	$(eval $(call copy-file, $(f), $(out-dir)/export-$(sm)/scripts)))