Hi,
I try to run a simple hello world program on a Numato Mimasv2
FPGA board with J2 bitstream. It is a slightly modified sh2
architecture.
See here for more information: http://j-core.org
The board is working fine with a musl FDPIC system.
I am trying to use a uClibc-ng (git master) toolchain with elf2flt
(git a87f68ae9e879360a9624f2a02999e67cfbe5a2f is used) with
a small patch attached, to recognize big endian.
Furthermore I am attaching the verbose elf2flt output while
compiling the helloworld source code.
On bootup I get following after patching the 4.9 Linux kernel
with the flat-debug patch (from an old discussion about ARM noMMU
problems) and flthdr -k call on the binary:
[4.170119] binfmt_flat: Loading file: /sbin/init
[4.196837] binfmt_flat: Mapping is 12168000, Entry point is 44,
data_start is 1240
[4.238923] binfmt_flat: Load /sbin/init: TEXT=12168040-12169240
DATA=12169260-121693c4 BSS=121693c4-1216b410
[4.298258] binfmt_flat: reloc[24] outside program 0xef50 (0
- 0x33b0/0x1200), killing init!
[4.351864] Failed to execute /sbin/init (error -8)
Any ideas what is wrong?
DOPIC is disabled in uClibc-ng config and I removed a -fpic in
gcc 6.2.0 so that libgcc isn't compiled as position independent
code.
best regards
Waldemar
>From 123fe2e98cce5c82d81d2a350529a1ea712a4058 Mon Sep 17 00:00:00 2001
From: Waldemar Brodkorb
Date: Sat, 26 Mar 2016 10:26:56 +0100
Subject: [PATCH] fix sh2 toolchain building
Signed-off-by: Waldemar Brodkorb
---
elf2flt.c | 10 ++
1 file changed, 6 insertions(+), 4 deletions(-)
diff --git a/elf2flt.c b/elf2flt.c
index 7d0e639..3546341 100644
--- a/elf2flt.c
+++ b/elf2flt.c
@@ -101,8 +101,10 @@ const char *elf2flt_progname;
#define ARCH "sparc"
#elif defined(TARGET_v850)
#define ARCH "v850"
-#elif defined(TARGET_sh)
-#define ARCH "sh"
+#elif defined(TARGET_sh2)
+#define ARCH "sh2"
+#elif defined(TARGET_sh2eb)
+#define ARCH "sh2"
#elif defined(TARGET_h8300)
#define ARCH "h8300"
#elif defined(TARGET_microblaze)
@@ -1260,7 +1262,7 @@ NIOS2_RELOC_ERR:
#endif /* TARGET_sparc */
-#ifdef TARGET_sh
+#if defined(TARGET_sh2) || defined(TARGET_sh2eb)
case R_SH_DIR32:
relocation_needed = 1;
sym_vma = bfd_section_vma(abs_bfd, sym_section);
@@ -1271,7 +1273,7 @@ NIOS2_RELOC_ERR:
sym_addr += sym_vma + q->addend;
sym_addr -= q->address;
break;
-#endif /* TARGET_sh */
+#endif /* TARGET_sh2 / TARGET_sh2eb */
#ifdef TARGET_e1
#define htoe1l(x) htonl(x)
--
1.7.10.4
TEXT -> vma=0x0 len=0x1200
DATA -> vma=0x1200 len=0x164
BSS -> vma=0x1364 len=0x204c
SECTION: .text [0x116b1f0]: flags=0x11f vma=0x0
RELOCS: .text [0x116b1f0]: flags=0x11f vma=0x0
RELOC[0]: offset=0x24 symbol=main+0x0 section=.text size=18263848 fixup=0x150
(reloc=0x24)
reloc[0] = 0x24
RELOC[1]: offset=0x28 symbol=_init+0x0 section=.text size=18263848
fixup=0x11ac (reloc=0x28)
reloc[1] = 0x28
RELOC[2]: offset=0x2c symbol=_fini+0x0 section=.text size=18263848
fixup=0x11dc (reloc=0x2c)
reloc[2] = 0x2c
RELOC[3]: offset=0x30 symbol=__uClibc_main+0x0 section=.text size=18263848
fixup=0x634 (reloc=0x30)
reloc[3] = 0x30
RELOC[4]: offset=0x34 symbol=abort+0x0 section=.text size=18263848
fixup=0x524 (reloc=0x34)
reloc[4] = 0x34
RELOC[5]: offset=0x54 symbol=.tm_clone_table+0x0 section=.tm_clone_table
size=18263848 fixup=0x1308 (reloc=0x54)
reloc[5] = 0x54
RELOC[6]: offset=0x58 symbol=__TMC_END__+0x3 section=.tm_clone_table
size=18263848 fixup=0x130b (reloc=0x58)
reloc[6] = 0x58
RELOC[7]: offset=0x5c symbol=_ITM_deregisterTMCloneTable+0x0 section=*UND*
size=18263848 fixup=0x0 (reloc=0x5c)
reloc[7] = 0x5c
RELOC[8]: offset=0x88 symbol=.tm_clone_table+0x0 section=.tm_clone_table
size=18263848 fixup=0x1308 (reloc=0x88)
reloc[8] = 0x88
RELOC[9]: offset=0x8c symbol=__TMC_END__+0x0 section=.tm_clone_table
size=18263848 fixup=0x1308 (reloc=0x8c)
reloc[9] = 0x8c
RELOC[10]: offset=0x90 symbol=_ITM_registerTMCloneTable+0x0 section=*UND*
size=18263848 fixup=0x0 (reloc=0x90)
reloc[10] = 0x90
RELOC[11]: offset=0xf4 symbol=.bss+0x0 section=.bss size=18263848
fixup=0x1364 (reloc=0xf4)
reloc[11] = 0xf4
RELOC[12]: offset=0xf8 symbol=.data+0x100 section=.data size=18263848
fixup=0x1300 (reloc=0xf8)
reloc[12] = 0xf8
RELOC[13]: offset=0xfc symbol=__DTOR_END__+0x0 section=.data size=18263848
fixup=0x1304 (reloc=0xfc)
reloc[13] = 0xfc
RELOC[14]: offset=0x100 symbol=.bss+0x4 section=.bss size=18263848
fixup=0x1368 (reloc=0x100)
reloc[14] = 0x100
RELOC[15]: offset=0x104 symbol=.text+0x38 section=.text size=18263848
fixup=0x38 (reloc=0x104)
reloc[15] = 0x104
RELOC[16]: offset=0x108 symbol=__deregister_frame_info+0x0 section=*UND*
size=18263848 fixup=0x0 (reloc=0x108)
reloc[16] = 0x108
RELOC[17]: offset=0x10c symbol=.eh_frame+0x0 section=.eh_frame size=18263848
fixup=0x1324 (reloc=0x10c)
reloc[17] = 0x10c
RELOC[18]: offset=0x138 symbol=__register_frame_info+0x0