[U-Boot] [PATCH] arc: introduce "mdbtrick" target

Alexey Brodkin Alexey.Brodkin at synopsys.com
Fri Dec 26 10:51:56 CET 2014


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 <abrodkin at synopsys.com>
Cc: Tom Rini <trini at ti.com>
---
 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



More information about the U-Boot mailing list