gcc linker description file force symbol to be at specific address

后端 未结 2 598
一个人的身影
一个人的身影 2021-01-04 20:57

I have a very specific question about the gcc linker description file. I have an embedded project and have to make sure, that the main symbol or the address of the main symb

2条回答
  •  日久生厌
    2021-01-04 21:13

    Sure there is a way. Your best option is to use a section just for your function:

    int start(void) __attribute__((section(".start")));
    
    int start(void)
    {
    }
    

    And then in the linker script:

    SECTIONS
    {
        . = 0x1234; // <---- put here your address
        .start : 
        {
            *(.start)
        }
    }
    

    Or something like that (it's been quite a long time since I used that).

提交回复
热议问题