Note option is only meant this only for advanced debugging with Synopsys
proprietary MetaWare debugger which is capable of accessing much more
specific hardware resources compared to gdb. For example it may show
contents of L1 and L2 caches, internal states of some hardware blocks
etc.

But on the downside MetaWare debugger still cannot work with PIE.
Even though that limitation could be work-arounded with change of ELF's
header and stripping down all debug info but with it we won't have debug
info for source-level debugging which is quite inconvenient.

So to make developer's life a bit easier we're introducing that feature.

Note these are prerequisites:
 [1] http://patchwork.ozlabs.org/patch/556899/
 [2] http://patchwork.ozlabs.org/patch/557541/

Signed-off-by: Alexey Brodkin <abrod...@synopsys.com>
---
 arch/arc/Kconfig        | 17 +++++++++++++++++
 arch/arc/config.mk      |  4 ++++
 arch/arc/lib/relocate.c |  9 +++++++++
 arch/arc/lib/start.S    |  7 ++++++-
 4 files changed, 36 insertions(+), 1 deletion(-)

diff --git a/arch/arc/Kconfig b/arch/arc/Kconfig
index f1dc6c8..32b8adc 100644
--- a/arch/arc/Kconfig
+++ b/arch/arc/Kconfig
@@ -116,6 +116,23 @@ config SYS_DCACHE_OFF
        bool "Do not use Data Cache"
        default n
 
+config DO_NOT_RELOCATE
+       bool "Do not relocate U-Boot"
+       default n
+       help
+         This option is only meant to be used for debugging purposes.
+         Note that U-Boot will be loaded and executed from
+         CONFIG_SYS_TEXT_BASE which is most probably quite low location
+         and there're chances to overwrite U-Boot's .text section with
+         another payload (for example Linux kernel that is linked to the
+         same start base or close to it.
+         Still if this option is enabled it allows for usage of propietary
+         MetaWare tools for source-level debugging.
+         Once debugging is complete make sure this option is disabled in all
+         production configurations.
+
+         If not sure leave NO here.
+
 choice
        prompt "Target select"
        default TARGET_AXS101
diff --git a/arch/arc/config.mk b/arch/arc/config.mk
index 74943d9..f8b7c67 100644
--- a/arch/arc/config.mk
+++ b/arch/arc/config.mk
@@ -52,8 +52,12 @@ endif
 
 PLATFORM_CPPFLAGS += -ffixed-r25 -D__ARC__ -gdwarf-2
 
+# MetaWare debugger still doesn't support PIE (Position-Independent 
Executables)
+# See STAR 9000707007 "Add support of position-independent executables"
+ifndef CONFIG_DO_NOT_RELOCATE
 # Needed for relocation
 LDFLAGS_FINAL += -pie
+endif
 
 # Load address for standalone apps
 CONFIG_STANDALONE_LOAD_ADDR ?= 0x82000000
diff --git a/arch/arc/lib/relocate.c b/arch/arc/lib/relocate.c
index 5c2c2d1..d72342e 100644
--- a/arch/arc/lib/relocate.c
+++ b/arch/arc/lib/relocate.c
@@ -14,6 +14,9 @@ int copy_uboot_to_ram(void)
 {
        size_t len = (size_t)&__image_copy_end - (size_t)&__image_copy_start;
 
+       if (gd->flags & GD_FLG_SKIP_RELOC)
+               return 0;
+
        memcpy((void *)gd->relocaddr, (void *)&__image_copy_start, len);
 
        return 0;
@@ -24,6 +27,9 @@ int clear_bss(void)
        ulong dst_addr = (ulong)&__bss_start + gd->reloc_off;
        size_t len = (size_t)&__bss_end - (size_t)&__bss_start;
 
+       if (gd->flags & GD_FLG_SKIP_RELOC)
+               return 0;
+
        memset((void *)dst_addr, 0x00, len);
 
        return 0;
@@ -40,6 +46,9 @@ int do_elf_reloc_fixups(void)
        Elf32_Addr *offset_ptr_rom, *last_offset = NULL;
        Elf32_Addr *offset_ptr_ram;
 
+       if (gd->flags & GD_FLG_SKIP_RELOC)
+               return 0;
+
        do {
                /* Get the location from the relocation entry */
                offset_ptr_rom = (Elf32_Addr *)re_src->r_offset;
diff --git a/arch/arc/lib/start.S b/arch/arc/lib/start.S
index 26a5934..63f6027 100644
--- a/arch/arc/lib/start.S
+++ b/arch/arc/lib/start.S
@@ -8,6 +8,7 @@
 #include <config.h>
 #include <linux/linkage.h>
 #include <asm/arcregs.h>
+#include <asm/global_data.h>
 
 ENTRY(_start)
        /* Setup interrupt vector base that matches "__text_start" */
@@ -62,8 +63,12 @@ ENTRY(_start)
        mov     %sp, %r0
        mov     %fp, %sp
 
-       /* Zero the one and only argument of "board_init_f" */
+#ifndef CONFIG_DO_NOT_RELOCATE
+       /* Normally we don't pass any flags to "board_init_f" */
        mov_s   %r0, 0
+#else
+       mov_s   %r0, GD_FLG_SKIP_RELOC
+#endif
        j       board_init_f
 ENDPROC(_start)
 
-- 
2.4.3

_______________________________________________
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot

Reply via email to