[J-core] What is the recomended binary header for compiler output?
dalias at libc.org
Sat Aug 20 22:29:03 EDT 2016
On Sat, Aug 20, 2016 at 10:12:25PM +0200, Daniel V wrote:
> If you have made a Compiler, what header would be best for programs?
> Should I use the FDPIC ELF? Or is Shared FLAT sufficient?
There is no shared flat support for sh at the gcc level or at any
upstream library level. There might be support in some long-abandoned
codesourcery toolchain and uclibc fork, but the only flat variant
that's maintained at all is completely non-shareable (requires memcpy
of whole program per process).
For a hosted, multi-process system (Linux or otherwise) you really
should be using FDPIC. It's much more capable and actually supported
in maintained versions of gcc and binutils.
If you're doing bare-metal binaries that don't have a need for
sharing, straight ELF with fixed load addresses matching physical
memory layout should work fine.
> And is there any file that documents the specific instructions the in
> J2? Like a technical document for J2.
I think in theory there's some way to generate documentation out of
the source, but I'm not sure how it's done. Maybe someone else can
This site has very nice documentation of all SH ISA levels:
J2 is not specifically documented there yet, but there are only 2
differences I'm aware of vs SH2:
- The variable-shift instructions shad Rm,Rn and shld Rm,Rn from SH3
- There is an atomic compare-and-swap instruction cas.l Rm,Rn, at R0 that
compares the value at address R0 with Rm and, if equal, stores the
value Rn. Either way, afterwards Rn contains the old value that was
read. The T flag is also set to indicate success/failure (I believe
T=1 on success but I'd have to check).
> And is there any VM in c-code, that can be used to simulate the
> instruction set, while developing the compiler on your own computer?
> Or is I best to write it yourself?
QEMU can do SH4, but for bare-metal stuff (including running a kernel)
SH4 is not a strict superset of SH2. Exceptions/interrupts work
differently and there are some other minor details that differ. For
running J2 Linux userspace binaries, though, qemu-sh4eb generally
works (modulo the usual bugs in qemu user-level emulation).
More information about the J-core