This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Placing sections at a specific address

I used the following code to specify
the address of variable bar at 0x4000 and
the address of function fun at 0x8002000.

int bar __attribute__((section(".ARM.__at_0x4000")));

void fun(void) __attribute__((section(".ARM.__at_0x8002000")));
void fun(void)
{
        // some code here
}

However, if I print out the address of the above two:

printf("0x%08X 0x%08X\r\n", (uint32_t)&bar, (uint32_t)&fun);

It outputs: 0x4000 0x8002001

If function pointer is used to jump to 0x8002000 it results in HardFault.
If jump to 0x8002001 it will execute the function fun correctly.

Could anyone explain why the function not located at 0x8002000?

(But if I look at the output .hex file, there is some data in the address 0x8002000!)

Thanks in advance!