-
-
Notifications
You must be signed in to change notification settings - Fork 523
Description
I have been quite successful with mold in bare metal systems. I am also quite happy to not having to write magic linker scripts.
In those systems you want to create a raw binary that starts with a structure that contains addresses to the interrupt service routines and usually an address that gives you the starting point of the stack. In the past it was considered common sense to mark the "reset" service routine as entry point, I think it makes more sense to select the whole initial structure, to ensure that all of the necessary functions would be added.
I.e. on a STM32H7432 I use:
arm-none-eabi-g++ -mthumb -mcpu=cortex-m7 -march=armv7e-m -mfpu=fpv5-d16 -mfloat-abi=hard \
-ffunction-sections -fdata-sections -fstack-usage -MMD -MP -gdwarf-4 -Os -g3 -nostartfiles --specs=nano.specs\
--specs=nosys.specs -Wl,--icf=all -Wl,--relocatable-merge-sections -Wl,--no-undefined -lstdc++ -lsupc++ \
-Wl,-u,vector_table -Wl,-e,vector_table -Wl,--gc-sections -Wl,--nmagic -Wl,--no-omagic -Wl,--Bno-symbolic -Wl,--static\
-Wl,--stats -Wl,--start-stop -Wl,--image-base=0x24000000 -Wl,--physical-image-base=0x8000000 \
-Wl,--section-align=TEXT=8 -Wl,--section-align=BSS=8 -Wl,--section-align=RODATA=8 -Wl,--section-align=DATA=8
"-Wl,--section-order==0x8000000 isr_vec TEXT RODATA =0x30000000 .data_sram1 =0x20000000 .data_dtcm =0x20018000 !__start_stack =0x20020000 !__stop_stack =0x24000000 DATA BSS" -fuse-ld=mold ...
I want to point towards the -e vector_table and -u vector_table parameters. This is an array of addresses of functions. It uses [[gnu::section("isr_vec")]] so that I can order it in the section order parameter:
[[gnu::section("isr_vec")]] VectorAddress vector_table[] = {
(VectorAddress)(&__stop_stack),
reset_handler,
nmi_handler,
hard_fault_handerl,
....
};With the above I do get the desired behavior, but I still get a warning: mold: warning: entry symbol is not defined: vector_table.
According to objdump vector_table is found and placed at 0x800000.
Am I mis-using the entry point parameter?