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.

453 questions
5
votes
3 answers

GCC for ARM -- ELF output file segment misplaced

Edited to add: I have now cross-posted this to the GNU ARM Embedded Toolchain site, as I am fairly certain that it's a linker bug. Also, I have noticed that it seems to happen when the first program segment fits into the first page in the ELF file…
TonyK
  • 16,761
  • 4
  • 37
  • 72
5
votes
4 answers

Really Minimal STM32 Application: linker failure

I'm building a tiny microcontroller with only the bare essentials for self-educational purposes. This way, I can refresh my knowledge about topics like the linkerscript, the startup code, ... EDIT: I got quite a lot of comments pointing out that…
K.Mulier
  • 8,069
  • 15
  • 79
  • 141
5
votes
0 answers

Linker script: defining symbol size and type

I know I can define a symbol/label in my (GNU binutils ld) linker script simply by assigning an address to the symbol like so: my_symbol = 0xdeadbeef; But, what if I wanted to give that symbol a size (like 0x02) and a type (like OBJECT or FUNC) as…
Isabell Cowan
  • 113
  • 2
  • 9
5
votes
0 answers

How can I fix overlapping sections in a linker script with a phdrs command?

I'm trying to make a simple operating system kernel higher half. When using Grub as a bootloader as I am, there must also be some lower half (32 bit) code. Because I want to keep this 32 bit code as brief as possible, I do not want to write an ELF…
hacatu
  • 638
  • 6
  • 15
5
votes
1 answer

What is absolute symbol and how to define it in C?

In the man page of nm. It says “A” The symbol's value is absolute, and will not be changed by further linking. However, I don't know what that means. How can I define a variable or something else to make its value absolute in C? If I declare a…
KenKenKen
  • 467
  • 1
  • 5
  • 18
5
votes
2 answers

Splitting embedded program in multiple parts in memory

I am working on an embedded system (Stellaris Launchpad) and writing a simple OS (as a hobby project). The used toolchain is gcc-none-eabi. My next step is to get used to the MPU to allow the kernel to prevent user programs from altering specific…
Cheiron
  • 3,620
  • 4
  • 32
  • 63
5
votes
3 answers

__isr_vectors variable not found when placed inside a static library

As a spin-off of a previous question (sbrk function not found when placed in a static library): I'm creating a bare-metal application for the stm32f407 microcontroller, which has an ARM Cortex M4 core. I'm trying to create a static library…
Richard
  • 212
  • 3
  • 8
5
votes
1 answer

Moving memcpy into another code section

I am building a piece of software meant to run on an ARM Cortex-M0+ microcontroller. It includes a USB bootloader of sorts that runs as a secondary program upon a call to a function. I'm having an issue with the insertion of the memcpy function…
Los Frijoles
  • 4,771
  • 5
  • 30
  • 49
5
votes
2 answers

Linker script: insert absolute address of the function to the generated code

I have a question related to gcc's linker. I'm working with embedded stuff (PIC32), but PIC32's compiler and linker are based on gcc, so, main things should be common for "regular" gcc linker and PIC32 linker. In order to save flash space (which is…
Dmitry Frank
  • 10,417
  • 10
  • 64
  • 114
4
votes
0 answers

Could array and structures be initialized in a different way?

My question could looks weird, indeed, here's the context: I am currently facing a strange issue, while switching - on the project i'm working on - the core from pulpino to CV32 (some other changes have happend too, for instance about the crt0, like…
Guillaume D
  • 2,202
  • 2
  • 10
  • 37
4
votes
0 answers

Documentation for initialization-related linker sections in GCC

I'm using the Gnu Arm Embedded Toolchain and I'm writing a custom linker file for a project. I'm writing custom startup/initialization code too. The project uses lots of C++ code, in addition to C and some assembler. I'm looking for documentation…
jgreen81
  • 705
  • 1
  • 6
  • 14
4
votes
1 answer

How can I access a symbol from the linker script in my Ada code?

I am building my Ada/SPARK project using GNAT and I am using a linker script. Here is an excerpt: SECTIONS { .code : { . = ALIGN(0x4); *(.text.section1) _end_of_section1 = .; *(.text.section2) ... …
Nola
  • 436
  • 4
  • 12
4
votes
1 answer

GCC linker script - split .bss section to multiple RAM regions

The embedded device has two SRAM regions. First at 0x20000000 and length 16k. Then at 0x20040000 length 96k. In the application, the resulting .bss section size is 102k so it doesn't fit to either RAM region fully. It needs to be split between the…
ckain
  • 383
  • 5
  • 13
4
votes
1 answer

How to make a custom section executable (other than .text)

Basic Hello World as seen many times before on x86_64 Linux: global my_start_symbol section .my_section my_start_symbol: mov rax, 1 mov rdi, 1 mov rsi, msg mov rdx, msg_len syscall mov rax, 60 …
4
votes
1 answer

GCC LD NOLOAD linker section generates loadable segment

I'm working on an Arm bare-metal application and I've marked some sections with NOLOAD. According to the explanation in Understanding linker script NOLOAD sections in embedded software , I expected the resulting ELF file to not have a loadable…
Leonardo
  • 1,533
  • 17
  • 28