Commit Graph

9 Commits

Author SHA1 Message Date
Lei Wen
145e9a0d27 [arch] fix link script not include global array init
Using wild match init_array* to include global array init ctor

Before:

 10 .ctors             00000040 ffff0000001e6b80 00000000401e6b80 DATA
 11 .dtors             00000000 ffff0000001e6bc0 00000000401e6bc0 DATA
 12 .got               00000060 ffff0000001e6bc0 00000000401e6bc0 DATA
 13 .init_array.1      00000470 ffff0000001e6c20 00000000401e6c20
 14 .fini_array.1      00000470 ffff0000001e7090 00000000401e7090
 15 .dummy_post_data   00000000 ffff0000001e7500 00000000401e7500 DATA
 16 .bss               00009460 ffff0000001e8000 00000000401e8000 BSS

After:

 10 .ctors             000004b0 ffff0000001e6b80 00000000401e6b80 DATA
 11 .dtors             00000470 ffff0000001e7030 00000000401e7030
 12 .got               00000060 ffff0000001e74a0 00000000401e74a0 DATA
 13 .dummy_post_data   00000000 ffff0000001e7500 00000000401e7500 DATA
 14 .bss               00009460 ffff0000001e8000 00000000401e8000 BSS

Signed-off-by: Lei Wen <leiwen@asrmicro.com>
2025-09-29 22:40:41 -07:00
Travis Geiselbrecht
8869020ae2 [arch][riscv] fix bug with gcc 10.2 & binutils 2.35 with section padding
In a two segment binary was previously trying to use MAXPAGESIZE set to 4
to cram the sections in very tight for embedded. This seemed to with this
toolchain cause the linker to get confused and sometimes appear to stuff in
an extra 4 bytes in the output file, thus misaligning the data segment.

It's possible it's still a bug on my side in the linker, but setting
max_page_size to 8 seems to work around it for now. Possible there's some
implicit 64bit aligning slipped in a stage somewhere in binutils thats
causing it to get confused. Either way, 8 byte alignment is no large loss
here.
2020-12-09 01:59:16 -08:00
Travis Geiselbrecht
7707ab3897 [arch][riscv] specify the target binary format on links, expand exception code
This allows the use of the riscv64-elf toolchain to link riscv32 binaries
and vice versa.

Also add some helpful printfs to the exception code.
2020-07-26 23:41:27 -07:00
Travis Geiselbrecht
4ca59c9237 [arch][riscv] tweak the linker scripts to better place .sdata and .sbss
Refactor the two linker scripts to put .sdata at the end of the data segment
and .sbss at the start of the bss segment to try to maximize the reach of
the global pointer.

Also generally tries to clean up and align the two linker scripts as a new
golden standard for other architectures.
2020-07-11 15:33:14 -07:00
Travis Geiselbrecht
52862d04c7 [arch][riscv] Add a space in some linker script logic
For some reason on older binutils the lack of space around the divide
seems to be a problem.
2020-05-17 13:54:52 -07:00
Travis Geiselbrecht
225bef5a4b [riscv][linker] general cleanup of the linker scripts
Start using PHDRS and MAXPAGESIZE, remove some extraneous stuff.

Possible we can combine a lot of these linker scripts for various arches
if we're careful.
2020-05-15 02:06:23 -07:00
Elliot Berman
acfe991c7f [arch][riscv] Expose RISC-V mp kernel start
Support mp lk start on RISC-V. Several changes throughout were required:
- Add signal in asm start to force secondary harts to wait for bss to be
  cleared.
- Use mhartid in arch_curr_cpu_num, PLIC, and CLINT
- Use tp register as thread pointer instead of global variable.
- Support sending IPIs between harts using CLINT
- Add spinlock implementation
2020-01-16 23:06:28 -08:00
Travis Geiselbrecht
fdc08a8446 [arch][riscv] port to riscv64
Very little needed to port except to conditionalize some assembly in the
context switch and exception code. Mostly needed to move build system
stuff around and add a new project.
2019-11-02 17:21:13 -07:00
Travis Geiselbrecht
ae5200595c [platform][riscv-virt] added support for QEMU's riscv 'virt' machine
The virt machine is a generic target, much like the arm virt machine.
Intended to be simple to use and a good target to run large systems like
linux on. At the moment simply support booting and simple uart and timer
support.
2019-11-02 14:19:36 -07:00