When using compile option
-ffunction-sections
in order to put each function in a separate segment, linking either fails or creates a very large binary, depending on the application or compiler version.
The problem could be fixed after changing
. = ALIGN(4);
*(.text);
to
. = ALIGN(4);
*(.text*);
in at91_rom.ld. The additional wildcard includes all segments named .text.function_name.