Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
456 views
in Technique[技术] by (71.8m points)

riscv - How do I build a newlib RISC-V toolchain with a modified linker script?

I'm trying to build a GCC/newlib cross compilation toolchain targeting an embedded OS on RISC-V. For this purpose, I need to modify the virtual addresses that binaries are linked at.

One way to achieve this is to modify the default linker script that ships with the toolchain. I'm trying to find the best location in the involved components (newlib, binutils, gcc) where I can tweak the default linker script that is shipped with the toolchain.

For some platforms, newlib already provides partial or complete linker scripts. It seems for RISC-V the default linker script produced by binutils is used.

I'm fine with patching binutils, but I can't find how the RISC-V linker script is actually built or how I would modify anything in it. Any pointers are appreciated!


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

The different linker scripts for riscv are build from :
binutils/ld/scripttempl/elf.sc
binutils/ld/emulparams/elf32lriscv*
binutils/ld/emulparams/elf64lriscv*

You will need to modifiy these files or create your own and modify the Makefiles.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...