I should preface this by noting I'm very unfamiliar with how linkers work, so I've just been following instructions in various README's pretty blindly.
I'm currently trying to compile a binary to run on verilated hardware with custom instructions inside, using a fork of the toolchain compiler (riscv64-unknown-elf-gcc and friends) that can generate said instructions. The details of the fork are private, but it shouldn't be a major modification relative to the 9.2 version of the toolchain compiler (which is what chipyard uses, i think), and it definitely doesn't differ at all in the linker, which is where I'm getting errors.
So, if I use the chipyard version of the toolchain compiler, following the instructions here:
I can successfully and easily generate binaries to run on bare metal verilated hardware, which is great. Trying to use it with that compiler fork initially failed, of course, since I didn't have libgloss-htif installed. Once I figured that out, I just followed the installation instructions there:
With the prefix set to point at the elf version of the forked compiler's install directory. The install seemed to be straightforwardly successful, and generating the object file with “-fno-common -fno-builtin-printf -specs=htif_nano.specs” options seemed to work fine. But the final step, linking with
“-static -specs=htif_nano.specs", failed with a TON of "relocation truncated to fit" errors, and a "additional relocation overflows omitted from the output" at the bottom. Googling around turned up a lot about the technical details behind this error, but didn't provide much guidance towards a solution ("mmodel" and "mcmodel" gcc options don't seem to be available for riscv gcc).
So yeah, feeling pretty stuck, and hoping this is something someone knows about, or can at least provide guidance towards a potential solution.