2023-12-22 14:32:55 +01:00
|
|
|
# sh-elf-vhex - v2.0.0
|
|
|
|
|
|
|
|
Modified GCC for the Vhex kernel projet
|
2021-11-17 19:41:16 +01:00
|
|
|
|
|
|
|
## Context
|
|
|
|
|
|
|
|
This project was born following the discovery of a limitation with GCC on the
|
2023-12-16 18:25:13 +01:00
|
|
|
SuperH architecture
|
|
|
|
[see on this subject from 2 years ago](
|
|
|
|
https://gcc.gnu.org/legacy-ml/gcc-help/current/000075.html
|
|
|
|
):
|
2021-11-17 19:41:16 +01:00
|
|
|
|
2023-12-16 18:52:43 +01:00
|
|
|
The generation of dynamic libraries is blocked by GCC (the `--shared` flag is
|
|
|
|
ignored), because the `sh3eb-elf` target (the one used for cross-compiling on
|
|
|
|
Casio calculators), does not support this functionality.
|
2021-11-17 19:41:16 +01:00
|
|
|
|
2023-12-16 18:25:13 +01:00
|
|
|
I am currently building a kernel for Casio's calculator for a graduation
|
|
|
|
project and I need this functionality. I had discovered, thanks to
|
|
|
|
[Lephenixnoir](https://silent-tower.net/research/),
|
2021-11-17 19:41:16 +01:00
|
|
|
that we could generate 'shared' libraries by using directly `ld` with a custom
|
|
|
|
linker script, but this workaround was of short duration. Indeed, we are
|
2023-12-17 11:06:14 +01:00
|
|
|
dependent on a library called `libgcc`, which provides some useful critical
|
|
|
|
primitives and is generated only in static (therefore with
|
|
|
|
non-relocatable code) which breaks all shared object files generated with this
|
|
|
|
dependency (and a lot of cases can involve this library).
|
2021-11-17 19:41:16 +01:00
|
|
|
|
|
|
|
With the help of Lephenixnoir, we tried to add a target for the
|
|
|
|
superH architecture called `sh-elf-vhex`, allowing us to enable these features
|
|
|
|
and that's what we finally came up with.
|
|
|
|
|
|
|
|
This repository gathers only the files that we had to modify for
|
|
|
|
`binutils` and` GCC`, as well as scripts to automate the installation of this
|
|
|
|
particular GCC.
|
|
|
|
|
2023-12-16 18:52:43 +01:00
|
|
|
## Features/Limitations
|
|
|
|
|
|
|
|
* only C is supported
|
|
|
|
* only big endian encoding is supported
|
2023-12-17 11:06:14 +01:00
|
|
|
* we use the `stdint` header from `newlib`. Otherwise, the generation of `stdint.h` is incomplete
|
2023-12-16 18:52:43 +01:00
|
|
|
* we only target the `SH4A-NOFPU` processor (no backward compatibility with the SH3 assembler)
|
|
|
|
* each public symbol begins with an underscore
|
2023-12-17 11:06:14 +01:00
|
|
|
* by default, we link our own C library to each generation of object files
|
2023-12-16 18:52:43 +01:00
|
|
|
* we do not provide a specialized default linker script (for the moment)
|
|
|
|
* compilation of the shared libgcc (`t-slibgcc`)
|
2023-12-17 11:06:14 +01:00
|
|
|
* compilation of the libgcc in PIC (`t-libgcc-pic`)
|
2023-12-16 18:52:43 +01:00
|
|
|
* compilation of the library for emulated floating point numbers (`t-fdpbit`)
|
|
|
|
|
2023-12-16 18:25:13 +01:00
|
|
|
## Installing
|
|
|
|
|
|
|
|
The build is relatively simple and can be done in two different ways:
|
2021-11-17 19:41:16 +01:00
|
|
|
|
2023-12-19 19:13:36 +01:00
|
|
|
Using `curl`:
|
|
|
|
```bash
|
|
|
|
curl -fsSL https://raw.githubusercontent.com/YannMagnin/sh-elf-vhex/HEAD/scripts/install.sh | bash
|
|
|
|
```
|
|
|
|
|
|
|
|
Note that you can do the uninstallation using `curl` too:
|
2021-11-17 19:41:16 +01:00
|
|
|
```bash
|
2023-12-19 19:13:36 +01:00
|
|
|
curl -fsSL https://raw.githubusercontent.com/YannMagnin/sh-elf-vhex/HEAD/scripts/uninstall.sh | bash
|
2021-11-17 19:41:16 +01:00
|
|
|
```
|
|
|
|
|
2023-12-19 19:13:36 +01:00
|
|
|
Or by cloning the project and using the `install.sh` script, see
|
|
|
|
`./scripts/install.sh --help` for more information about possible operations
|
|
|
|
you can do with it
|
2021-11-17 19:41:16 +01:00
|
|
|
|
|
|
|
```bash
|
2023-12-16 18:25:13 +01:00
|
|
|
cd /tmp/
|
|
|
|
git clone 'https://github.com/YannMagnin/sh-elf-vhex.git' --depth=1
|
|
|
|
cd /tmp/sh-elf-vhex || exit 1
|
2023-12-19 19:13:36 +01:00
|
|
|
./script/install.sh
|
2021-11-17 19:41:16 +01:00
|
|
|
```
|
|
|
|
|
|
|
|
It takes about twenty minutes for the build.
|
|
|
|
|
2023-12-22 10:21:04 +01:00
|
|
|
Do not forget to add the install prefix (`~/.local/bin`) path to your `PATH`
|
|
|
|
environment variable:
|
|
|
|
|
|
|
|
> [!WARNING]
|
|
|
|
> You must add the absolute path to your PATH environment variable
|
|
|
|
|
|
|
|
```bash
|
|
|
|
# *unix-like
|
|
|
|
export PATH="$PATH:/home/<your_login>/.local/bin"
|
|
|
|
|
|
|
|
# macos (darwin-like)
|
|
|
|
export PATH="$PATH:/Users/<your_login>/.local/bin"
|
|
|
|
```
|
|
|
|
|
2023-12-16 18:25:13 +01:00
|
|
|
## Supported version list
|
2021-11-17 19:41:16 +01:00
|
|
|
|
2023-12-17 11:06:14 +01:00
|
|
|
Note that GCC `12.x` will never be supported since many critical bugs have been
|
2023-12-16 18:25:13 +01:00
|
|
|
found for the superh backend
|
2023-12-20 15:34:53 +01:00
|
|
|
(https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106609)
|
2021-11-17 19:41:16 +01:00
|
|
|
|
2023-12-17 11:06:14 +01:00
|
|
|
- GCC `13.2.0` and binutils `2.41`
|
2023-12-16 18:25:13 +01:00
|
|
|
- GCC `11.2.0` and binutils `2.31`
|
2021-11-17 19:41:16 +01:00
|
|
|
|
2023-12-19 19:13:36 +01:00
|
|
|
## Technical notes
|
|
|
|
|
|
|
|
The bootstrap process will clone this repository at
|
|
|
|
`~/.local/share/sh-elf-vhex` then will start the installation using:
|
|
|
|
|
|
|
|
* `prefix-clone` = `~/.local/share/sh-elf-vhex`
|
|
|
|
* `prefix-sysroot` = `~/.local/share/sh-elf-vhex/_sysroot`
|
|
|
|
* `prefix-install` = `~/.local/bin/`
|
|
|
|
|
|
|
|
The project also automatically installs
|
|
|
|
[vxOpenLibm](https://github.com/YannMagnin/vxOpenLibm)
|
|
|
|
and [vxLibc](https://github.com/YannMagnin/vxLibc)
|
|
|
|
|
|
|
|
|
|
|
|
|
2021-11-17 19:41:16 +01:00
|
|
|
## Special thanks
|
|
|
|
|
2023-12-16 18:25:13 +01:00
|
|
|
A big thanks to [Lephenixnoir](https://silent-tower.net/research/) who helped
|
|
|
|
me a lot for the modification of the sources and made this project possible!
|