Questions tagged [linker-scripts]
The linker command language used to control the memory layout of computer programs and details of the linking process.
459
questions
0
votes
0
answers
8
views
Is it possible to use a linker script with Apple ld64 linker?
As in the title, can you use a linker script with Apple ld64 linker? I mean an option similar to -T of GNU ld.
0
votes
0
answers
8
views
Workaround to linker script "INSERT BEFORE" with GNU gold
I have a linker script that currently works with GNU ld.
I wanted to link using GNU gold but I am hitting an issue because currently GOLD does not support "INSERT BEFORE" in linker scripts, ...
0
votes
0
answers
7
views
Specify output sections in LD linker script to be both OVERLAY and NOLAOD
I have a use case where I want an output section type to be NOLOAD and OVERLAY.
In the below linker-script, sections ".LOCAL_0_0" and ".LOCAL_1_1" are to be run at the same memory ...
0
votes
0
answers
11
views
Making Sections Absolute / Not-Relocatable in a Linker Script
I am trying to write a linker script such that certain sections will be relocatable and other sections will be not. I am aware of the -r flag, which makes all sections relocatable. However, for a ...
0
votes
0
answers
31
views
Default linker files and sections: Explain their origin/history and their purpose
I have a Linux Ubuntu(20.04) machine with gcc and clang installed. I figured out the directory containing the default linker script:
/usr/lib/x86_64-linux-gnu/ldscripts$ ls
elf32_x86_64.x ...
0
votes
1
answer
26
views
CMAKE: How to add a dependency to the link phase of the add_executable() command? [duplicate]
I would like to build an executable with a specific linker script file (my.linkcmds).
And when I update my linker script, I would like to trigger the linker part of the add_executable().
I use the ...
0
votes
0
answers
8
views
Where is the official documentation of gnu linker script command language?
Search engine results for gnu linker script command language return pretty old (pre 1998) documentation. So where can one find the documentation for gnu ld's script command language?
What did I try? ...
0
votes
2
answers
55
views
ARM microcontroller loading raw binary
I am learning how bare metal programming on ARM works and I am having difficulties understanding how the addresses defined in the linker script are used.
This is my linker script:
ENTRY(ResetHandler)
...
0
votes
0
answers
13
views
PIC24HJ XC16 Linker Script Interrupt Vector Table
I am working on a bootloader for a PIC24HJ series MCU.
While going through the linker script I noticed something, tried a google search, searched documentation, GCC linker documentation, I'm out of ...
1
vote
1
answer
63
views
STM32 CubeIDE Place a static library in specified memory region and mapped to the absolute memory address
I have an STM32 CubeIDE project.
I want to place a static library in an absolute memory address in the upper part of the internal flash while the application code will be placed at the beginning of ...
0
votes
1
answer
20
views
objdump -i doesn't show all possible output formats
I was trying to understand command OUTPUT_FORMAT() in GCC linker, they didn't mention what are the possible values for the arguments like for example :
OUTPUT_FORMAT("elf32-littlearm", "...
0
votes
0
answers
35
views
how to define a variable in linker script that's aligned upward to a 4 byte boundary?
I was trying to learn how to write a linker script from this tutorial till I came to a section called Assigning values to symbols, they gave this example:
floating_point = 0;
SECTIONS
{
.text :
...
0
votes
0
answers
20
views
How can I place my variable into a specific section using lld or mold linker?
A.ld
SECTIONS
{
.rel.rodata.func_reg : {
PROVIDE(func_reg_start = .);
*(.func_reg.aaa.*)
PROVIDE(func_reg_end = .);
...
}
}
INSERT AFTER .text;
A.hpp
typedef ...
0
votes
0
answers
40
views
Is it possible to set ram start address at a value higher than 0x80000000(32 bits) in riscv bare metal?
I am using a linker script to compile a program in riscv64 .I need my ram start address to be higher than 32 bits but whenever i try to modify the address in the linker script i get the following ...
1
vote
2
answers
83
views
Import symbols from an existing binary in a linker script
I am creating a binary for a microprocessor with flash and ram. The regular build process uses a linker script to declare where different sections should go and also exports parameters to the code, ...
2
votes
0
answers
325
views
Array alignment with different linkers
I'm working on a big embedded project and I'm facing an issue that I cannot explain with my limited knowledge of linkers.
I've managed to recreate the problem in a really simple program.
I have a ...
2
votes
0
answers
40
views
configuring the overlapping address for code and data in linker script
I am newbie to linker script. In my design, RISCV has the code space and data space seperately. The code address is 0~0xFFFF, the data address is 0~0xFFFFFF. Here is my linker scprit:
MEMORY
{
CODE (...
1
vote
0
answers
42
views
Use linker script to convert identifier from CamelCase to snake_case?
i am working on a C project using a snake_case syntax for naming my functions.
However, a lib i need to uses CamelCase for all of its function names.
To avoid doing a long header full of static inline ...
0
votes
0
answers
38
views
How to put an input section in front of .bss in a linker script?
One of my ELF .o files have section named .mybss (similar to .bss). I'd like to put the contents of this section to the beginning of the output section .bss. What should I pass to GNU ld(1)?
Probably ...
0
votes
1
answer
40
views
How to fail on non-empty sections in a GNU ld linker script?
I have this in my GNU ld linker script:
.ctors : ALIGN(4) SUBALIGN(4) {
*(.ctors)
ASSERT(0, "Constructors (.ctors) are not supported.");
}
In earlier versions of GNU ld (such as ...
1
vote
0
answers
44
views
Re-locating App in FLASH not working, entry point unclear (STM32F072)
I'm currently trying to understand how bootloaders work and wanted to create a small example for this.
My first step was to just re-locate my application code into a different area of the FLASH for my ...
0
votes
2
answers
97
views
How can I specifically exclude a libgcc function from being placed in flash memory?
I want to place a certain section of libgcc in RAM instead of in Flash of my STM32L053R8T6 microcontroller. Even while explicitly excluding a specific function in the specific object file in my linker ...
0
votes
2
answers
105
views
How to split code and data into 2 different ELF files?
I have a code for an embedded microncontroller in an FPGA that contains variables stored in the stack and I would like to seperate the code from those variables and put those into 2 ELF files. The ...
0
votes
0
answers
17
views
ld script does not link objects from my lib with INPUT command
I have the small ld linker script bellow that is used to build a x86 bootloader.
OUTPUT_FORMAT(binary)
SECTIONS
{
. = 0x7c00;
.code :
{
* (.text)
* (....
0
votes
0
answers
40
views
Hiding/deleting elf symbols using visbility or linker, without shared library
I would like to hide some symbols from normal usage from a C library/file to prevent name clashes and to avoid possible expansion of the API (Hyrum's Law). Static symbols are hidden (but my use case ...
0
votes
0
answers
47
views
How to initialize an array when variable is placed into separate section (GNU ARM GCC)
I tried to initialize an array that is placed into a separate section. But had no success. Background story is that I want to emulate an external memory in an embedded system for some testing.
...
1
vote
0
answers
148
views
How link var to specifical address using TASKING compiler?
I want to link a var to specific address, so I tried as follwing
Step1. using #pragma to define a section
#pragma section farbss "user_test_bss"
volatile int run_cnt1;
#pragma section farbss ...
0
votes
0
answers
52
views
How to implement -z separate-code with linker script?
The system ld.bfd linker supports options such as -z separate-code and -z noseparate-code.
With -z separate-code, there are 4 LOAD segments, and its layout is R RE R RW.
With -z noseparate-code, ...
0
votes
2
answers
134
views
Which part of Embedded toolchain generates the linker script
Which part of the Embedded toolchain is responsible for generating the linker script?
And if it is the linker, why would the linker generate a script for itself to define the memory segments? Aren't ...
0
votes
0
answers
53
views
Force compiler to use Position Independent Code for a particular symbol
I am trying to create a linker script which maps some memory in SRAM and DRAM. The memory is then referenced by symbols in the C code. The DRAM starts at address 0x0 and the SRAM at 0x820000000. The ...
0
votes
0
answers
20
views
Wrong section LMA address when using LD file
I need to load the data sections in different address from VMA.
so I defined 2 typed of memory and updated the LD file,
for example bss section:
.bss : ALIGN(0x20) {
PROVIDE(__bss_start = ...
1
vote
0
answers
40
views
What is the proper ld link script syntax for aliasing missnamed symbols with the PROVIDE statement?
I'm trying to understand how I can provide aliases to missnamed
symbols when linking libraries with gnu ld. If I understand
correctly it should be sufficient to define an addition to the default
link ...
0
votes
0
answers
17
views
Correct ld link PROVIDE syntax for translating symbol names
I am trying to statically link a blas library mingw compiled without underscores, with a library that uses underscoring for symbols, so for example the dgemm_ symbol cannot be found during linking.
nm ...
2
votes
0
answers
62
views
GCC linker incorrectly defining startup variable
I am trying to initialize some RAM variables from FLASH in a STM32F7 device. The flash is located at 0x8018000 while the RAM position I want to load that flash is at 0x2007A000
I have my linker file ...
0
votes
0
answers
71
views
GNU LD section attributes and flags for 64-bit kernel ELF
I am trying to link a 64-bit kernel ELF using GNU LD. I have a executable section named lowerhalf and then the other usual sections. The linker script I use is this
ENTRY(kernelCompatibilityModeStart);...
0
votes
0
answers
61
views
How to force my section in the very end of flash?
I have my linker script with such memory layout
MEMORY{
ram : ORIGIN = 0x0, LENGTH = 0x1000 /* 4KB of RAM starting at address 0x0 */
flash : ORIGIN = 0x20000000, LENGTH = 0xC000 /* 48KB of ...
0
votes
1
answer
151
views
How can I make sure that my struct fits in a memory area defined in a linker script?
I'm having a problem very similar to this one, but no answer there is helping me. Building with gcc on ARM Cortex M4.
I have:
a memory area defined in a linker script
a complex structure, the size of ...
0
votes
0
answers
102
views
Place a section inbetween another section in a linker script
I'm trying to write an mbr-manager in GNU-assembler, everything works great except that I'm doing an .include "print_routines" and I want that to change but I don't know how I could write a ...
0
votes
0
answers
25
views
gcc linker : force section to be not empty
given:
SECTIONS
{
.text:
{
*(.text.start)
*(.text)
*(.text.*)
*(.text.end)
}
}
Is it possible to make gcc raise a link error if symbols text.start and ...
1
vote
0
answers
90
views
How to align sections defined in the default linker script?
ld has currently two ways to extend the default linker script that is compiled in:
by supplying an additional linker script on the command line without using the -T option (i.e., just like object ...
0
votes
0
answers
47
views
Linking additional module against already built main microcontroller firmware
I'm working on a bare-metal microcontroller project that needs to be able to execute a blob of code loaded at runtime. The basic implementation is simple enough - write a linker script that can handle ...
3
votes
3
answers
167
views
Member variable allocated at start of memory
I'm trying to use c++ on an STM32 device compiling with gcc. The device loads the code and start executing it but hard faults on any member variable write.
I can see with GDB that member variables are ...
0
votes
2
answers
350
views
Relocating interrupt vector table using linker script
I'm trying to move interrupt vector to DTCMRAM. The test code is simple blinking LED by timer interrupt.
There I've changed load adress of .isr_vector:
MEMORY
{
ITCMRAM (xrw) : ORIGIN = 0x00000000, ...
0
votes
1
answer
156
views
What is the difference between *(.text) vs *(.text*) in c linker?
I want to know the exact difference between two:
*(.text) /* .text sections (code) */
*(.text*) /* .text* sections (code) */
Note that this exist for others like .bss, .rodata .etc,...
0
votes
1
answer
87
views
How can I access specific memory regions from x86-64 linux Assembly or Linker Script?
I am writing a utility that needs to test specific memory region.
I need something similar to linux's mmap routine but without linking any libraries.
The utility is running on x86-64 linux and has ...
0
votes
0
answers
21
views
Set virtual address of section to custom byte
I'm trying to put a small boot loader into the mbr of an exfat drive, but I'm having trouble getting ld to set the virtual address correctly.
according to the ExFat Specification, I need to put the ...
2
votes
1
answer
182
views
Using #define (preprocessor values) from a C/H file in IAR linker script (.icf)
I need the usage of a certain #define value from a header into an icf file. Consider this,
I have a line in a certain header file like this. #define LINKER_VALUE 0
If this LINKER_VALUE changes to 1, I ...
0
votes
1
answer
100
views
How does one add a RWX section to a gcc executable for Raspberry Pi
I am trying to add a section (in addition to predefined ones). I want the section to be RWX.
What I have so far is:
SECTIONS
{
.dictionary :
{
*(.dictionary)
}
}
INSERT AFTER .text;
I ...
1
vote
1
answer
85
views
How to place code to a specific address using gas?
I used IDA Pro to disassemble an existing software running on a Motorola 68K CPU. The output of IDA is a disassembly that follows the MRI notation. I analyzed it and found that it consists of five ...
2
votes
0
answers
154
views
Debug symbols corresponding to a part of the code disappear if that part is placed in a subsection inside .text
I'm developing a very simple bootloader. I need to assure that my startup code is placed at address 0x0, so I place it in a 'subsection' called .isr_vector inside .text as explanined below. The ...