Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FEATURE REQ/BUG REP] SH4 endianas #1273

Open
QBos07 opened this issue Jun 3, 2024 · 7 comments
Open

[FEATURE REQ/BUG REP] SH4 endianas #1273

QBos07 opened this issue Jun 3, 2024 · 7 comments

Comments

@QBos07
Copy link

QBos07 commented Jun 3, 2024

The existing SuperH code is endianess defined by the host system, wich would either make littel-endian or more possible big-edian not work depending on what opposite the host is using.

TL;DR:

  • SH4 little-endian only works on litte-enadian hosts
  • SH4 big-endian only work on big-endian hosts
@rui314
Copy link
Owner

rui314 commented Jun 3, 2024

mold support big-endian sh4 as a target. As far as I know, big-endian sh4 systems are extremely rare if ever exists. sh4 is becoming a retro computer, though. Are you using sh4?

@QBos07
Copy link
Author

QBos07 commented Jun 3, 2024

Yes I am using big-endian SH4 as part of a calculator in wich modding community I am.
Mold fails by reading an absurdly high e_shnum in little-endian from the big-endian field. elf/input-files.cc:84

@rui314
Copy link
Owner

rui314 commented Jun 4, 2024

It shouldn't be too hard to support sh4eb, but the problem is there's no easy way to test it. Ubuntu provide only sh4 little endian cross toolchains, so we cannot build object files for sh4eb and try to link them using mold (that's how we test mold). Given the situation, it is realistically not very practical to support sh4eb.

If you want to try yourself, you may try to change the following line from true to false.

mold/elf/elf.h

Line 2198 in 8cd85aa

static constexpr bool is_le = true;

@rui314
Copy link
Owner

rui314 commented Jun 4, 2024

I also want to point out that mold does not depend host endianness. You can for example build a big-endian sparc executable on a little-endian machine using mold. Speaking of SH4, it's just that mold supports only little-endian SH4 output.

@QBos07
Copy link
Author

QBos07 commented Jun 6, 2024

I made a custom mold that supports sh4eb instead of the little-endian variant. Is there intrest in bringing it upstream from this side and if so what is the plan?

@QBos07
Copy link
Author

QBos07 commented Jun 6, 2024

main...QBos07:mold:main

@rui314
Copy link
Owner

rui314 commented Jun 8, 2024

As I said, supporting sh4eb itself isn't hard, but testing it is hard. We cannot support it unless we can run our unit test suite for the target.

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

No branches or pull requests

2 participants