GNU linker script: Assigning VMA to object files

Asked by Prakash K Balasubramanian

I am on 4.6.

    .text :
    {
        sText = .;
       *(EXCLUDE_FILE ( *Algo.o ) .text .text.*);
        *(.text .text.*);
    } > FLASH

    LoadAddress = Some address in flash;
    Code_In_RAM : AT (LoadAddress)
    {
      *Algo.o (.text .text.*);
    } > RAM

    The linker assigns VMA and LMA of the flash. I have been successful with .bss and COMMON sections before. But I simply cannot get the linker to assign VMA (RAM) and LMA (flash).

What is the correct syntax?

Question information

Language:
English Edit question
Status:
Solved
For:
GNU Arm Embedded Toolchain Edit question
Assignee:
No assignee Edit question
Solved by:
Joey Ye
Solved:
Last query:
Last reply:
Revision history for this message
Joey Ye (jinyun-ye) said :
#1

Prakash,

Can you please share a rather complete case and point out the exact problematic places? I'm kind of don't get your issue.

Thanks - Joey

Revision history for this message
Prakash K Balasubramanian (prakash-balasubramanian) said :
#2

Hi Joey.

Sloppy of me indeed.

I have 2 C files, File_A.c and File_B.c

I would like all input .text sections of File_A.o to be assigned VMA and LMA in flash (and assigned to an output section FLASH_TEXT)

I would like all input .text sections of File_B.o to be assigned a VMA in SRAM and LMA in flash (and assigned to output section RAM_TEXT)

For this, I must exclude File_B.o from FLASH_TEXT and create a new output section for File_B.o as below.

FLASH_TEXT :
    {
        sText = .;
       *(EXCLUDE_FILE ( *File_B.o ) .text .text.*);
        *(.text .text.*);
    } > FLASH

    LoadAddress = Some address in flash;

   RAM_TEXT : AT (LoadAddress)
    {
      *File_B.o (.text .text.*);
    } > RAM

But I notice that the linker assigns both LMA and VMA of flash to functions in File_B.o. This is the problem.

Revision history for this message
Best Joey Ye (jinyun-ye) said :
#3

The line of EXCLUDE_FILE already pulls in all .text except File_B.o.
*(.text .text.*); put File_B.o in FLASH section.
Remove above line from FLASH section and it should just work as expected.

FLASH_TEXT :
    {
        sText = .;
       *(EXCLUDE_FILE ( *File_B.o ) .text .text.*);
/* *(.text .text.*); */
    } > FLASH

- Joey

Revision history for this message
Prakash K Balasubramanian (prakash-balasubramanian) said :
#4

Thanks a lot. This really helps.