AVR-GCC can't call function located on fixed address I wrote the following code:

#include &lt;avr/io.h&gt;

__attribute__((noinline, section(".app_start"))) void app_start() //app_start section starts at 0xFA0
{
    //register_packet_dispatch(packet_received);
    PORTB = 0xFF;
}

__attribute__ ((noinline)) void call_app()
{
    asm ("call 0xFA0\nret");
    //app_start();
}

int main()
{
    DDRB = 0xFF;
    //call_app();
    app_start();
    while(1){}
}


What I compiled with:

avr-gcc -Wl,--section-start=.reg_dispatch=0xdac -Wl,--section-start=.app_start=0xFA0 -mmcu=atmega328p -Os -o ubb.o ub_bootloader.cpp -DF_CPU=16000000


Which tries to simulate a host application that tries to call a relocated client application, begins from the 4000 address (0xFA0). If it would work, it's light up the LED wired to the arduino's 13. pin. But why app_start won't be called?

I've also inspected the output assemlby:

avr-objcopy -j .text -j .data -O ihex ubb.o ubb.hex

00000fa0 &lt;_Z9app_startv&gt;:
 fa0:   8f ef           ldi r24, 0xFF   ; 255
 fa2:   85 b9           out 0x05, r24   ; 5
 fa4:   08 95           ret

00000080 &lt;main&gt;:
  80:   8f ef           ldi r24, 0xFF   ; 255
  82:   84 b9           out 0x04, r24   ; 4
  84:   0e 94 d0 07     call    0xfa0   ; 0xfa0 &lt;_Z9app_startv&gt;
  88:   ff cf           rjmp    .-2         ; 0x88 &lt;main+0x8&gt;


Everything seems correct, why it isn't working at all?
Of course, if i remove the "noinline" attribute, it works. But that's a mirage, the compiler inlines the content of the function, but when I build this into an application, the code after the 0xFA0 address will be rewritten by the host application.
I've tried this code with arduino and it worked (i taught, of course, i can't add the "-Wl,--section-start=.app_start=0xFA0" flag to the compilation process so the function not gonna be moved to other section)
So i set the arudino IDE to show every command from the compilation to the end of the upload process.

The problem lies in the usage of avr-objdump, whose i found somewhere and used witouth overview the CLI switches.

I've also made a mistake when i wrote the question. To disassemble the object file, the right command is:

avr-objdump -S --disassemble  ubb.o &gt; ubb.asm


THe command i've used to create hex file:

avr-objcopy -j .text -j .data -O ihex ubb.o ubb.hex


The working one (extracted from arduino):

avr-objcopy -O ihex -R .eeprom ubb.o ubb.hex


-j means keep only the given section(s)

while

-R means, remove only the given section(s)