Reputation: 55
I designed RISCV32IM processor, and i used "riscv32/64-unknown-elf-gcc" to generate code for test. Instruction memory setting has been solved with the options below(-Ttext option), but data memory setting has not been solved yet.
riscv64-unknown-elf-gcc -v -march=rv32im -mabi=ilp32 -nostartfiles -x c -Ttext 40000000 -o main.o main.c
Can I know if I can set the data memory address I want?
Upvotes: 1
Views: 961
Reputation: 444
looks like you need to link linker script
, something like:
OUTPUT_ARCH( "riscv" )
ENTRY(_start)
SECTIONS
{
. = 0x40000000;
.text.init : { *(.text.init) }
. = ALIGN(0x1000);
.text : { *(.text) }
. = ALIGN(0x1000);
.data : { *(.data) }
.bss : { *(.bss) }
_end = .;
}
_start
is a start symbol and 0x40000000 is a memory start address,
followed by the section names aligned by 0x1000.text
this is the program itselfdata
is a statically initialized variablesbss
is a statically allocated variablesUpvotes: 2