From: Alexey Brodkin Date: Fri, 26 Dec 2014 12:51:56 +0300 Subject: [U-Boot] [PATCH] arc: introduce "mdbtrick" target Message-ID: <1419587516-30541-1-git-send-email-abrodkin@synopsys.com> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de MetaWare debugger doesn't support PIE (position-independent executable) so the only way to load U-Boot in MDB is to fake it by: 1. Reset PIE flag in ELF header 2. Strip all debug information from elf Even though it could be done manually but having this automated way is very convenient. User may build U-Boot that will be loaded on target via MDB saying "make mdbtrick". Signed-off-by: Alexey Brodkin Cc: Tom Rini --- arch/arc/Makefile | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/arch/arc/Makefile b/arch/arc/Makefile index de25cc9..03ea6db 100644 --- a/arch/arc/Makefile +++ b/arch/arc/Makefile @@ -6,3 +6,18 @@ head-y := arch/arc/cpu/$(CPU)/start.o libs-y += arch/arc/cpu/$(CPU)/ libs-y += arch/arc/lib/ + +# MetaWare debugger doesn't support PIE (position-independent executable) +# so the only way to load U-Boot in MDB is to fake it by: +# 1. Reset PIE flag in ELF header +# 2. Strip all debug information from elf +ifdef CONFIG_SYS_LITTLE_ENDIAN + EXEC_TYPE_OFFSET=16 +else + EXEC_TYPE_OFFSET=17 +endif + +mdbtrick: u-boot + $(Q)printf '\x02' | dd of=u-boot bs=1 seek=$(EXEC_TYPE_OFFSET) count=1 \ + conv=notrunc &> /dev/null + $(Q)$(CROSS_COMPILE)strip -g u-boot -- 2.1.0