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
4
votes
1 answer

Keep rodata located with the function that created it

I'm trying to make .rodata section location stay with its associated function memory location. I'm using the GNU compiler/linker, bare metal, plain-jane c, with an STM32L4A6 micro-controller. I have a custom board using an STM32L4A6 controller with…
ICAVER
  • 43
  • 6
4
votes
1 answer

What memory is impacted using the location counter in linker script?

I am learning assembly for fun and its just my 3rd day today. Perhaps I mis-understood the location counter in linker script. As per my understanding, location counter defines at which address in memory, the sections must be loaded in memory…
Naveen
  • 7,944
  • 12
  • 78
  • 165
4
votes
1 answer

Role of linker scripts when writing x86 assembly

I am learning x86 assembly for my own curiosity to understand low-level stuff and came across this great repository herethat contains lots of examples that can be run from EFI shell. When I check this hello world example, there is a linker script…
Naveen
  • 7,944
  • 12
  • 78
  • 165
4
votes
0 answers

Why does the content of STM32 read-only data set by Rust differ between the target and the ELF file?

I'm trying to print a string through semihosting on STM32F4. I define a variable: let array: &[u8] = &[ 0x54, 0x68, 0x69, 0x73, 0x20, 0x69, 0x73, 0x20, 0x61, 0x20, 0x6e, 0x65, 0x77, 0x20, 0x77, 0x61, 0x79, 0x00, 0x00, 0x00, ]; This a…
phodina
  • 1,341
  • 1
  • 12
  • 25
4
votes
1 answer

Can you add two SECTION sections to ld script

I have an executable made by linking several .o files, using a somewhat involved linker script. If a particular environment flag is set, I'd like there to be another section involved. So, something like: /* withfoo.ld */ SECTIONS { .foo…
HardcoreHenry
  • 5,909
  • 2
  • 19
  • 44
4
votes
0 answers

Packaging of linker scripts: Should .so belong to -devel packages instead of following .so.1 files

Separating packages into main and -devel parts looks like a good established practice, which allows to save some space for those who are not building software. On Linux, a library that uses SONAME versioning can have two or more files representing a…
Anton
  • 6,349
  • 1
  • 25
  • 53
4
votes
1 answer

Is there a way to exclude a function/symbol from a particular section in linker script?

I have used EXCLUDE_FILE to explicitly omit placing certain sections of certain object files in the master object file that I want to generate. I was wondering if there is a way to omit out just a particular symbol rather than an entire…
whyme
  • 101
  • 5
4
votes
1 answer

rename a symbol using a linker script

Is it possible to use a linker script or mapfile to rename a symbol? I'm trying to adapt some code written in a mix of C++ and Fortran so that it will work with more than one Fortran compiler - on Linux. It is currently written for the Solaris…
okapi
  • 1,340
  • 9
  • 17
4
votes
3 answers

why need linker script and startup code?

I've read this tutorial I could follow the guide and run the code. but I have questions. 1) Why do we need both load-address and run-time address. As I understand it is because we have put .data at flash too; so why we don't run app there, but need…
dvn0zzz
  • 337
  • 3
  • 13
4
votes
1 answer

Linker Script Does Not Skip Bytes As Expected

So, I have this assembly file, which I assemble with GNU as and link with GNU ld using a linker script. Linker script (boot.ld): INPUT(boot.o) OUTPUT(boot.out) ENTRY(boot_start) SECTIONS { . = 0x7c00; .text : { *(.text) } …
cadaniluk
  • 15,027
  • 2
  • 39
  • 67
4
votes
3 answers

conditional statements for linker command language LD

Are there conditional statements for the GNU LD linker command language? Context: I am developing firmware for an arm cortex m0+, which consists of a bootloader and an application. Both are compiled and flashed to target in separate projects, but I…
joop
  • 43
  • 1
  • 1
  • 4
4
votes
1 answer

Put a bootloader program at the bottom of the FLASH memory

I try to creat a custom bootloader for STM32L1 serie card and I need to put my bootloader code at the bottom of my flash memory. Then i can flash my memory properly. I know it can be specified in the linker scrip but i don't know how to do that. I…
kidz55
  • 333
  • 4
  • 26
4
votes
2 answers

gcc-4.1 -> gcc-4.8 linker error. New ".text.unlikely" section overlap ".text" section

I'm trying to build cromwell (Original Xbox legal firmware replacement) using a more recent version of gcc but after altering the project compilation setup slightly, ld throws the following error: ld: section .text.unlikely loaded at…
4
votes
2 answers

Is there a safe way to refer to linker-only symbols that without taking the address of void expressions?

A file has a series of void declarations used as void* as follows: extern void __flash_rwdata_start; ... initialize(&__flash_rwdata_start, ... which are provided solely by the linker script as symbols referring to binary partitioning as…
Greg
  • 2,549
  • 2
  • 24
  • 30
4
votes
1 answer

where can I find the formal ld linker script syntax?

I am looking for the formal grammar of the linker script. Something similar to the ones given to lex and yacc but not with the other yacc baggage. May be I can find the yacc like grammar if I look directly in the source code of the ld. But I don't…
Tem Pora
  • 2,043
  • 2
  • 24
  • 30