2021-11-17 19:41:16 +01:00
|
|
|
# sh-elf-vhex - modified GCC for the Vhex kernel projet
|
|
|
|
|
|
|
|
## 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
|
|
|
|
dependent on a library called `libgcc`, which provide some useful critical
|
|
|
|
primitives and which is generated only statically (therefore with
|
|
|
|
non-relocatable code), which broke all shared object file generated with this
|
|
|
|
dependencie (and a lot of cases can involve this librarie).
|
|
|
|
|
|
|
|
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
|
|
|
|
* we use the stdint header from `newlib`. Otherwise, the generation of `stdint.h` is incomplete
|
|
|
|
* we only target the `SH4A-NOFPU` processor (no backward compatibility with the SH3 assembler)
|
|
|
|
* each public symbol begins with an underscore
|
|
|
|
* by default, we link our own C library to each generation of an object file
|
|
|
|
* we do not provide a specialized default linker script (for the moment)
|
|
|
|
* compilation of the shared libgcc (`t-slibgcc`)
|
|
|
|
* the compilation of the libgcc in PIC (`t-libgcc-pic`)
|
|
|
|
* compilation of the library for emulated floating point numbers (`t-fdpbit`)
|
|
|
|
|
2023-12-16 18:25:13 +01:00
|
|
|
## Technical notes
|
2021-11-17 19:41:16 +01:00
|
|
|
|
2023-12-16 18:52:43 +01:00
|
|
|
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/`
|
2021-11-17 19:41:16 +01:00
|
|
|
|
2023-12-16 18:52:43 +01:00
|
|
|
The project also automatically install
|
|
|
|
[vxOpenLibm](https://github.com/YannMagnin/vxOpenLibm)
|
|
|
|
and [vxLibc](https://github.com/YannMagnin/vxLibc)
|
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
|
|
|
|
|
|
|
```bash
|
2023-12-16 18:25:13 +01:00
|
|
|
curl -s "https://github.com/YannMagnin/sh-elf-vhex/+/HEAD/scripts/bootstrap.sh?format=TEXT" | base64 --decode | bash
|
2021-11-17 19:41:16 +01:00
|
|
|
```
|
|
|
|
|
2023-12-16 18:25:13 +01:00
|
|
|
Or by cloning the project and using the `bootstrap.sh` script, see
|
|
|
|
`./scripts/bootstrap.sh --help` for more information about possible operation
|
|
|
|
you can do with it (like uninstalling the compiler)
|
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
|
|
|
|
./script/bootstrap.sh
|
2021-11-17 19:41:16 +01:00
|
|
|
```
|
|
|
|
|
|
|
|
It takes about twenty minutes for the build.
|
|
|
|
|
2023-12-16 18:25:13 +01:00
|
|
|
## Supported version list
|
2021-11-17 19:41:16 +01:00
|
|
|
|
2023-12-16 18:25:13 +01:00
|
|
|
Note that GCC `12.x` will never be supported since many critical bugs has been
|
|
|
|
found for the superh backend
|
|
|
|
(https://gcc.gnu.org/bugzilla/show\_bug.cgi?id=106609)
|
2021-11-17 19:41:16 +01:00
|
|
|
|
2023-12-16 18:25:13 +01:00
|
|
|
- GCC `11.2.0` and binutils `2.31`
|
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!
|