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
59
votes
0 answers

How to get the size of an input section (to place it at the end of memory)

I have the following linker script: .data & .bss are placed into ram, then a .heap section fills the remaining memory. Now I want to add a .noinit section that always gets placed at the end of the memory. That is so it gets ignored by bootloaders…
user1273684
  • 1,169
  • 11
  • 22
52
votes
3 answers

What does KEEP mean in a linker script?

The LD manual does not explain what the KEEP command does. Below is a snippet from a third-party linker script that features KEEP. What does the KEEP command do in ld? SECTIONS { .text : { . = ALIGN(4); _text = .; …
Randomblue
  • 98,379
  • 133
  • 328
  • 526
51
votes
5 answers

Limiting visibility of symbols when linking shared libraries

Some platforms mandate that you provide a list of a shared library's external symbols to the linker. However, on most unixish systems that's not necessary: all non-static symbols will be available by default. My understanding is that the GNU…
rafl
  • 11,160
  • 1
  • 49
  • 73
22
votes
1 answer

Difference between Program header and Section Header in ELF

Q1 What is the difference between Program header and Section Header in ELF? Q1.1 What is the difference between segment and a section? I believe pheaders point to sections only. Q2. What is the difference between File Header and Program Header? As…
user435739
19
votes
2 answers

How to correctly use a simple linker script? Executable gets SIGKILL when run

I'm trying to understand deeper linking process and linker scripts...looking at binutils doc i found a simple linker script implementation that i've improved by adding some commands: OUTPUT_FORMAT("elf32-i386", "elf32-i386", …
MirkoBanchi
  • 2,035
  • 5
  • 31
  • 49
19
votes
5 answers

Linker Script - Placing a section at the end of a memory region

I have searched far and wide for how to do this and have failed to come up with an answer. My memory layout is as follows: Fake Address | Section 0 | text 7 | relocate 15 | bss 23 | stack At the end of…
nonsensickle
  • 4,138
  • 2
  • 32
  • 58
16
votes
3 answers

ALIGN in Linker Scripts

What does the ALIGN keyword do in linker scripts? I read many tutorials about linker scripts but I cant understand what really ALIGN do. Can any one explain it simply. Thanks!
Jayanga Kaushalya
  • 2,462
  • 5
  • 34
  • 56
16
votes
1 answer

Actual default linker script and settings gcc uses

Where can I find the actual linker script and settings gcc uses? Things I've tried: For concreteness, let's consider a small program: empty.c int main(void) { return 0; } build it statically, and look at the result: $ gcc -static…
RabbitEars
  • 221
  • 1
  • 2
  • 6
16
votes
3 answers

Understanding the Location Counter of GNU Linker Scripts

I'm working on a university project where I'm writing software for an Atmel SAM7S256 microcontroller from the ground up. This is more in depth than other MCUs I've worked with before, as a knowledge of linker scripts and assembly language is…
Adam Goodwin
  • 3,390
  • 4
  • 25
  • 29
15
votes
2 answers

Linker scripts: strategies for debugging?

I'm trying to debug a linker problem that I have, when writing a kernel. The issue is that I have a variable SCAN_CODE_MAPPING that I'm not able to use -- it appears to be empty or something. I can fix this by changing the way I link my program, but…
jvns
  • 273
  • 2
  • 8
15
votes
4 answers

understanding the __libc_init_array

I viewed the source code of __libc_init_array from http://newlib.sourcearchive.com/documentation/1.18.0/init_8c-source.html . But I don't quite understand what this function does. I know that these symbols /* These magic symbols are provided by…
Pony279
  • 333
  • 1
  • 3
  • 12
14
votes
3 answers

When is .ARM.exidx is used

I am working on Contiki 2.7 with the mbxxx target. While building my code the linker complained about an overlap of .ARM.exidx and .data sections. After some tinkering around with the linker script contiki-2.7/cpu/stm32w108/gnu-stm32w108.ld I fixed…
user2668988
  • 257
  • 1
  • 2
  • 12
12
votes
2 answers

Understanding the linkerscript for an ARM Cortex-M microcontroller

I am using the STM32F746NG microcontroller from STMicroelectronics. This device is based on the ARM Cortex-M7 architecture. I invested quite some time in understanding the linkerscript from example projects. I figured out the basics, but I still…
K.Mulier
  • 6,430
  • 9
  • 58
  • 110
12
votes
2 answers

What does a dangerous relocation error mean?

I am getting a linking error: dangerous relocation: l32r: Literal placed after use: I am still trying to debug; however, I want to better understand this error. I understand what relocation is; however, I am not sure how it can be dangerous and…
Fred Thomsen
  • 1,440
  • 1
  • 12
  • 15
11
votes
1 answer

GNU LD: How to override a symbol value (an address) defined by the linker script specified using -T

My usecase is as follows: I am using a typical SDK that comes with Makefile based projects I belive the linker is patched gcc. gcc --version gives me 4.3.4 SDK defines the linker script (lets call it Linker.ld) Linker.ld includes LinkerMemMap.cfg,…
Aravind
  • 483
  • 1
  • 3
  • 11
1
2 3
23 24