Questions tagged [linker-scripts]

The linker command language used to control the memory layout of computer programs and details of the linking process.

Linker scripts contain a command language processed by the linker to determine how sections in input files are mapped into the output file. Most often used to control the memory layout in computer programs, they can also exercise fine control over details of the linking process.

360 questions
10
votes
1 answer

Is it possible to pass command line arguments to GNU LD to create a section, define size and place it in a specific memory?

I want to create a section in RAM, allocate a specific size and place it an an address? Is it possible to do all these operations without passing a linker script "file" or w/o modifying the existing linker script ? .myspace : { . =…
ted
  • 3,397
  • 3
  • 21
  • 44
10
votes
3 answers

GCC: how to tell GCC to put the 'main' function at the start of the .text section?

I've just started learning some ARM programming and I've got stuck in a slightly annoying problem. The toolchain I'm using to compile my sources is Sourcery CodeBench Lite 2013.05-23 (can be found here:…
Zuzu Corneliu
  • 1,286
  • 12
  • 23
9
votes
2 answers

' __exidx_start' and '__exidx_end' what do they do?

Hello I have a linker script in which i found this code "__exidx_start = .;" which sets label value to the value of location counter ".". This label isn't used anywhere within the same linker script. There is a similar label defined couple of lines…
71GA
  • 1,666
  • 5
  • 30
  • 53
9
votes
1 answer

Using a Linker Script on Mac OS X

Is there any way to use a linker script with ld on Mac OS X? The GNU ld program on Linux accepts a -T option, but on Mac OS -T is an unknown command option. Using an alternative installation of GCC is okay with me, if that solves the…
Andres Jaan Tack
  • 21,282
  • 10
  • 57
  • 75
9
votes
3 answers

Offset of global const variable in executable

Would like to have an executable save its state by modifying its own global constants. Just for the kicks of having a totally self-contained executable. A few solutions/hacks that come to mind: Use libelf and have the program parse itself to find…
Sussch
  • 1,077
  • 1
  • 9
  • 13
8
votes
1 answer

What is the memory attribute 'p' in my linker file?

In GCC, the MEMORY command describes the location and size of blocks of memory in the target. The command must be used this way. MEMORY { name [(attr)] : ORIGIN = origin, LENGTH = len ... } Now, I have a linker file used by the linker…
djondal
  • 2,434
  • 3
  • 21
  • 38
8
votes
1 answer

Why does GCC put calls to constructors of global instances into different sections (depending on the target)?

I have some simple declarations of a global instances with non-empty constructors. These constructors are called during startup automatically. I am cross-compiling C++ on Linux to different microcontroller targets. As…
Beryllium
  • 12,164
  • 9
  • 52
  • 81
8
votes
3 answers

How to use the INCLUDE command in ld linker script

I have two linker scripts: common.ld which defines some symbols, and app.ld which positions the sections, using these defines. If I just cat the two files together, and feed that to ld (via gcc), it works. If I use the INCLUDE command: INCLUDE…
parvus
  • 4,939
  • 6
  • 32
  • 54
8
votes
3 answers

It is possible to get linker script symbols addresses as compile time constant values in C code?

I want to get the address of the end of my program and check at compilation/linker time if I have enough space, after the code, to place some random data in execution time. But as the symbols provided by PROVIDE keyword are like normal variables in…
Lilás
  • 956
  • 12
  • 24
7
votes
2 answers

Advice on linker script creation and verification

Long story short. I wish to learn how to create a good linker script so that should I change platforms/architectures/vendors, I'm not stuck at ground zero again with not knowing what to do. I'm not concerned with the difficulty of the task, so much…
Crewe
  • 303
  • 2
  • 8
7
votes
1 answer

linking problem: i386:x86-64 architecture of input file *.o is incompatible with i386 output

I got a problem in linking when I moved my osdev to linux where it worked previously on gcc 3.5.* and binutils 2.18 (compiled to output x86_64-elf) running under cygwin. Here are the infos: gcc -v Using built-in specs. Target:…
prinzrainer
  • 199
  • 1
  • 4
  • 12
7
votes
2 answers

How can the --add-section switch of OBJCOPY be used?

There are really two questions that revolve around the use of --add-section. The simple one is in the title. Based on my reading, I haven't been able to figure out how one could execute --add-section. To use add-section, I have to pass a section…
user2600958
  • 103
  • 1
  • 5
6
votes
1 answer

Are all RAM-sections used in this linkerscript of a STM32H743 microcontroller (Cortex-M7)?

I know that the RAM-memory in the latest STM32 microcontrollers contains several sections with remarkable speed differences. That's why I'm trying to wrap my head around the linkerscripts for these devices (note: arm-none-eabi-gcc toolchain).…
K.Mulier
  • 6,430
  • 9
  • 58
  • 110
6
votes
1 answer

Explicitly set starting stack pointer with linker script

I'd like to create a program with a special section at the end of Virtual Memory. So I wanted to do a linker script something like this: /* ... */ .section_x 0xffff0000 : { _start_section_x = .; . = . + 0xffff; _end_section_x =…
HardcoreHenry
  • 3,775
  • 2
  • 11
  • 33
6
votes
2 answers

gcc/ld - create a new libc.so with __isoc99_sscanf@@GLIBC_2.7 symbol from glibc.2.6

I have an application, which does a error when I try to run it: /lib/libc.so.6: version `GLIBC_2.7' not found But the only symbol it needs from glibc 2.7 is __isoc99_sscanf@@GLIBC_2.7 I want to write a small single function "library" with this…
osgx
  • 80,853
  • 42
  • 303
  • 470
1
2
3
23 24