Skip to content

SH2/J2: add support - #36

Merged
gregungerer merged 2 commits into
uclinux-dev:mainfrom
wbx-github:main
Oct 28, 2026
Merged

gregungerer merged 2 commits into
uclinux-dev:mainfrom
wbx-github:main

Conversation

@wbx-github

Copy link
Copy Markdown
Contributor

Hi,
these two patches get a uClibc-ng based system with Linux Kernel 6.18.x boot up on a Numato MimasV2 FPGA with J2 core.
There is a small kernel patch required, which was sent to the Linux SH kernel mailing list. Another fixup is in uClibc-ng required which is already upstream.
thanks in advance,
Waldemar

Replace the generic TARGET_sh guards with TARGET_sh2 and TARGET_sh2eb
so the SH-2 (J2 core) targets get their own handling, and report ARCH
as "sh2" for both endiannesses.

Also handle R_SH_DIR32 and R_SH_REL32 in the output_relocs() first
pass: DIR32 is treated as a good resolved 32-bit reloc, and REL32 is
skipped since PC-relative values need no runtime fixup in flat.

Signed-off-by: Waldemar Brodkorb <wbx@openadk.org>
On SH targets, text relocations must be processed regardless of
pic/got settings, as is already the case for Blackfin. Default
--enable-always-reloc-text to yes for sh* and mention SuperH in the
option's help string.

Signed-off-by: Waldemar Brodkorb <wbx@openadk.org>

@gregungerer gregungerer left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't see any specific differences between handling TARGET_sh2 and TARGET_sh2eb in the code. Is there something that needs to be done differently based on endian?

None of the other architecture support for processors that support big and little endian have separate configure targets - like ARM for example. So I guess what I am asking is do we really need to have a separate TARGET_sh2eb?

@wbx-github

Copy link
Copy Markdown
Contributor Author

But how do I handle this error then?
cc -MM -idirafter /home/wbx/j2-flat/adk/include -DPACKAGE_NAME="" -DPACKAGE_TARNAME="" -DPACKAGE_VERSION="" -DPACKAGE_STRING="" -DPACKAGE_BUGREPORT="" -DPACKAGE_URL="" -DHAVE_STDIO_H=1 -DHAVE_STDLIB_H=1 -DHAVE_STRING_H=1 -DHAVE_INTTYPES_H=1 -DHAVE_STDINT_H=1 -DHAVE_STRINGS_H=1 -DHAVE_SYS_STAT_H=1 -DHAVE_SYS_TYPES_H=1 -DHAVE_UNISTD_H=1 -DHAVE_WCHAR_H=1 -DSTDC_HEADERS=1 -D_ALL_SOURCE=1 -D_COSMO_SOURCE=1 -D_DARWIN_C_SOURCE=1 -D_GNU_SOURCE=1 -D_HPUX_ALT_XOPEN_SOCKET_API=1 -D_NETBSD_SOURCE=1 -D_OPENBSD_SOURCE=1 -D_POSIX_PTHREAD_SEMANTICS=1 -D__STDC_WANT_IEC_60559_ATTRIBS_EXT__=1 -D__STDC_WANT_IEC_60559_BFP_EXT__=1 -D__STDC_WANT_IEC_60559_DFP_EXT__=1 -D__STDC_WANT_IEC_60559_EXT__=1 -D__STDC_WANT_IEC_60559_FUNCS_EXT__=1 -D__STDC_WANT_IEC_60559_TYPES_EXT__=1 -D__STDC_WANT_LIB_EXT2__=1 -D__STDC_WANT_MATH_SPEC_FUNCS__=1 -D_TANDEM_SOURCE=1 -D__EXTENSIONS__=1 -DHAVE_LIBZ=1 -DHAVE_LIBZSTD=1 -DHAVE_FCNTL_H=1 -DHAVE_UNISTD_H=1 -DHAVE_VPRINTF=1 -DHAVE_DCGETTEXT=1 -DHAVE_GETLINE=1 -DHAVE_STRSIGNAL=1 -DTARGET_sh2eb -DTARGET_CPU="sh2eb" -DSYMBOL_PREFIX="" -DBINUTILS_LDSCRIPTDIR="/../sh2eb-openadk-linux-uclibc/lib" -DTARGET_ALIAS="sh2eb-openadk-linux-uclibc" -DNO_GOT_CHECK=1 -DUSE_EMIT_RELOCS=1 -DEMIT_CTOR_DTOR=0 -DALWAYS_RELOC_TEXT=0 -DHAVE_BFD_XTENSA_PDIFF_RELOCS=0 -I. -Ibfd-headers ./*.c > .deps
./elf2flt.c:138:2: error: #error "Don't know how to support your CPU architecture??"
138 | #error "Don't know how to support your CPU architecture??"
| ^~~~~

The tuple is sh2eb-openadk-linux-uclibc. Not sure how to handle this in another way.

@gregungerer

gregungerer commented Oct 26, 2026 via email

Copy link
Copy Markdown
Contributor

@wbx-github

Copy link
Copy Markdown
Contributor Author

BTW, if someone want to test this change in Qemu, following fork has support for J2 machine via qemu-system-sh4eb:
https://github.com/lordrasmus/qemu/tree/uclibc-ng
@gregungerer: anything else I need to do before you merge my changes?

@gregungerer
gregungerer merged commit 33c05c4 into uclinux-dev:main Oct 28, 2026
1 check failed
@gregungerer

gregungerer commented Oct 28, 2026 via email

Copy link
Copy Markdown
Contributor

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants