When playing with creating baremetal executables, I hit this error:
main.o:(.eh_frame+0x1c): relocation truncated to fit: R_AARCH64_PREL32 against `.text\'
c
As a workaround that allows it to compile without me fully understanding the situation, you can add:
-fno-unwind-tables -fno-asynchronous-unwind-tables
which removes the .eh_frame
frame from which the failing relocation was coming from: Why GCC compiled C program needs .eh_frame section?
I then noticed the binary doesn't work because _start
has the C function prologue and touches stack first thing, and I can't find an amazing solution for that: Creating a C function without compiler generated prologue/epilogue & RET instruction? (-O3
? :-) We need to invent a -fno-stack
option).