How to prevent “main.o:(.eh_frame+0x1c): relocation truncated to fit: R_AARCH64_PREL32 against `.text'” when creating an aarch64 baremetal program?

后端 未结 1 1386
夕颜
夕颜 2021-01-14 07:23

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         


        
相关标签:
1条回答
  • 2021-01-14 07:48

    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).

    0 讨论(0)
提交回复
热议问题