Home > Mobile >  Difference between -Tlinker.ld vs linker.ld in an makefile
Difference between -Tlinker.ld vs linker.ld in an makefile

Time:06-06

I have this linker.ld where I want to remapped ram.

MEMORY
  {
    ram (rx) : ORIGIN = 0x80000000, LENGTH = 8M
  }

What is the difference between adding the linker like this:

sparc-gaisler-elf-gcc -O2 -std=c99 linker.ld -Ttext=0x80000000 -o main.o

vs.

sparc-gaisler-elf-gcc -O2 -std=c99 -Tlinker.ld -Ttext=0x80000000 -o main.o

The first one I get an warning:

redeclaration of memory region 

and the second one, I get

no memory region specified for loadable section .data

I don't really understand what is the difference in how -T<linker_file> and just adding <linker_file> directly.

CodePudding user response:

The answer is very simple.

With -T you replace the default linker script, without both will be used.

  1. Fist case both are used and both define the same memory region
  2. Second case - your linker script is far too trivial and misses all section definitions.
  • Related