474 questions
2
votes
1
answer
137
views
OSDev: Stuck at adding GDT
I've followed the book OS01 by Tuhdo, kind of made a simple bootloader, that loads the kernel. Then I tried to add some code to set up GDT, but I've witnessed unusual behavior in gdb.
Here I stopped ...
2
votes
1
answer
110
views
Is there a robust way to version all exported symbols with version script without changing the visibility?
GNU documentation is really poor and is worded in a way that seem to imply that you can only assign version only to symbols that are listed explicitly either under global: or local:, but those are ...
1
vote
0
answers
81
views
Dynamically generated export_name for extern C function?
I understand that I can give a function a static linker symbol name like this:
// The linker symbol produced for this function will be named
// "foo_bar", not "asdf" or some ...
0
votes
0
answers
36
views
Why is TI ARM Clang demoting my entry point to an undefined symbol?
Target Processor: ARM R5F
IDE: Texas Instruments Code Composer Version 12.0
COMPILER/LINKER: TI ARM Clang 3.2.2
OS: Windows 11
I am writing my own C runtime startup code that will run on an R5F ...
1
vote
1
answer
118
views
How can I make all functions from the HAL standard library file work from RAM at once?
There is a HAL library of functions for working with flash memory. I want all the functions of this library to work from RAM. How can I do this correctly, without writing _attribute_((section("....
0
votes
0
answers
59
views
How to generate correct options for the macOS linker from a linker script?
I did not find any related questions here on SO hence the new post.
I have tried to find out how to resolve my problem by reading the ld man page and asked both on reddit and a LLM. I have a linker ...
1
vote
1
answer
156
views
Get sizeof C-Symbol in GNU Linker script
I have a section in my linker script which needs to contain 2 things:
A variable length byte-array (used for heap)
A global variable called foo.
This can be done like this:
MEMORY {
APPL_STATE (...
1
vote
1
answer
234
views
Define a fixed-position section within a Linker Script of position-independent executable
I am trying to build a static position-independent executable with gcc provided option -static-pie. The target is bare-metal risc-v, so no OS, no dynamic loader. I have a linker script similar to ...
1
vote
1
answer
75
views
What Influences S0 record in srec?
I have a linker script which is used for ELF generation, which is then used to create a S19 file.
Since in S19, S0 is a header record which stores metadata of the firmware.
I want to store information ...
0
votes
1
answer
159
views
Why won't my linker put .rodata after .text?
I want to put my .text section at 0x80200000, but despite my every attempt, .rodata refuses to move out of my way, leaving .rodata at 0x80200000 instead:
Sections:
Idx Name Size VMA ...
0
votes
0
answers
128
views
.elf file has no sections
I'm currently trying to recreate the blinky example using low-level C++ using vscode for the STM32F446RE Nucleo-64 board. I took the linkerscript and startup code from dwelch67's stm32 sample code and ...
3
votes
1
answer
94
views
Calling C function from the .init3 section of a AVR-GCC compiled program
I am working on a project that contains a firmware update failure feature that :
notifies user/host that firmware update failed whenever the device gets unplugged in the middle of a firmware update ...
1
vote
1
answer
277
views
How to Initialize memory section during startup?
I have allocated a memory section my_data in the linker file to store some shared variables. However, I noticed that after startup, I see some (???) values when I take a memory dump. Below is my ...
1
vote
0
answers
24
views
gnu ld linker script LONG() not placing value as expected (ARM Cortex-M3) [duplicate]
gnu .ld linker script --
I have added a MEMORY definition to hold a checksum:
_CRC_Value = 0x12345678;
MEMORY
{
RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 80K
FLASH (rx) : ORIGIN = ...
1
vote
0
answers
92
views
GNU linker uses 0x200000000 as a base address for LMA and VMA
boot.s
.code16
.text
.global start
start:
jmp start
boot.ld
ENTRY(start)
SECTIONS
{
. = 0x00007C00; /* Set the location counter to 0x7C00 */
.text :
{
*(.text)
}
...
0
votes
1
answer
400
views
The use of linker files (.ld files) in embedded bare-metal programming
After the .LD file(linker file) of an embedded bare metal specifies that FLASH is not writable,
for example:
MEMORY {
{
FLASH (rx) : ORIGIN = 0x08000000, LENGTH = 64K
RAM (rwx) : ORIGIN = ...
1
vote
1
answer
201
views
Identifiers with leading underscore defined in a linker script
Per the C standard section 7.1.3 Reserved identifiers
All identifiers that begin with an underscore are always reserved for use as identifiers with file scope in both the ordinary and tag name spaces....
0
votes
0
answers
108
views
how to initialize my values in my table declare with an _attribute__((section())), of a section in my linker script
`Hello everyone,
I'm new in that domain (linker script and memory section).
I have an array that I want to declare in a section of my address space of my processor (neorv32). I do this for various ...
5
votes
1
answer
319
views
How to set alignment of a brand new section
in a software project of mine, on linux, I need to create a special section that needs to be populated with 40 bytes large structures. Then I would like to treat this section as an array.
For that I ...
3
votes
1
answer
217
views
Data Integrity Issue with Custom .rawdata Section in Linker Script
I'm working on an embedded project using an ARM Cortex-M4 processor (specifically, an STM32F4 microcontroller) and I've encountered a peculiar issue related to memory sections defined in my linker ...
0
votes
0
answers
98
views
Generate hex file from "c" program using riscv compiler , rodata must be aligned by 4 bytes
i want to generate hex file , that contains rodata as aligned 4 bytes . But my riscv compiler generate hex file ,that contains rodata as aligned 2 bytes. i have tried many methods
1.i have already ...
0
votes
0
answers
62
views
Re-exporting an import with gcc/llvm linker
I'm trying to re-create MSVC's behavior of the /export:myfunction=upstreamlib.myfunction linker flag in gcc/llvm (specifically Rust but I think this is a linker question rather than rust) which ...
-1
votes
1
answer
69
views
In Language Processing, What is making the console window of an exe file?
When a language gets processed into displaying its output, specifically for compiled languages, their code is compiled by a compiler, assembled by an assembler and linked by a linker to create the ...
2
votes
0
answers
161
views
Handling Empty Sections in Linker Script Causes Hard Fault on STM32H7
I'm working with an STM32H7 microcontroller and encountered a Hard Fault during the startup sequence while copying data from Flash to RAM (specifically to ITCM and DTCM sections). This issue arises ...
0
votes
1
answer
283
views
Linker script - exact memory align
I develop for the STM32 environment (same IDE), and I have to change the original Linker Script.
I would like to store a struct in the exact memory address.
If I create a new memory item (in the ...
0
votes
1
answer
79
views
Querying the Target of a Linker Script?
I have some C++ code that is dlopening the "libm.so" library:
dlopen("libm.so", RTLD_GLOBAL | RTLD_NOW);
Under RHEL7, this was a sym-link:
libm.so -> libm.so.6
Under RHEL9, ...
0
votes
1
answer
390
views
Changing program flash memory address for S32K312 target
We had the application up and running fine on NXP S32K312 target when the program flash address was 0x00400000.
When we needed to change the program flash address to start at 0x00440000 in the linker ...
2
votes
1
answer
108
views
unexpected memory corruption in baremetal environment
i have a simple 32 bit kernel which gets loaded succesfully by a bootloader shown below
[org 0x7c00]
; we can also alter the data segment register (ds) accordingly:
; mov ds, 0x7c0 (it will be 0x7c00 ...
1
vote
1
answer
745
views
Linker Script for RISCV CPU on FPGA, stack is not where I expect it to be?
In the last months I have implemented ad RV32I CPU on an FPGA. Until now I just tested it using some assembly code. This week I decided to try out a simple test program in C on it. The source code is ...
1
vote
0
answers
38
views
Creating a variable under specific section
I'm using linker .ld file to create a section called SECVAR
.SECVAR : {
*(.SECVAR )
}
using the below command in my .c file to create a variable called Dummy under section:
unsigned short ...
1
vote
0
answers
252
views
error due to section overlap in linker script
I am trying to compile a c program for baremetal riscv core. What I am trying to do is generate random values put them in a dynamic array and send them through ROCC instructions.
Here is the c program:...
1
vote
2
answers
162
views
CC2538 bare metal project compile but doesn't work
I'm new to embedded development and I'm currently trying to develop a project for a custom board based on TI's CC2538SF53 microcontroller. I've based the code on some tutorials I've seen online and on ...
1
vote
1
answer
91
views
How to add symbols from statically linked library to a particular section in linker script
Let's say I have a section in a linker script that describes some really fast ram:
.fastram __fastram_start : AT (__fastram_lma)
{
__fastram_start__ = ABSOLUTE(.) ;
*(.fastram....
3
votes
2
answers
813
views
Utilizing same header file for linker script and C program, is it possible?
For example I want to place a special data in 0x100000000, 0x100100000, 0x100200000, ... and for this I want to do in a header file,
#define DATA_START 0x100000000
#define DATA_GAP 0x100000
#define ...
0
votes
0
answers
56
views
Linker script bug regarding char pointers in c++
I am writing an OS in assembly and cpp.
I encountered a problem regarding char pointers in cpp:
for example, the following code:
#define VIDEO_MEMORY 0xB8000
#define COLUMNS 80
#define ROWS 25
#...
1
vote
1
answer
599
views
How does the linker assign anything to ITCMRAM on STM32 H7 series Arm Cortex M MCU?
How does the linker assign anything to ITCMRAM on STM32 H7 series Arm Cortex M MCU?
The linker script provided by ST has a section defining ITCMRAM:
/* Memories definition */
MEMORY
{
ITCMRAM (...
1
vote
0
answers
316
views
How can I set an "end of code" marker at the end of my binary?
I have a GNU linker script for my firmware with the following section defined:
.endc :
{
KEEP(*(.endc));
. = ALIGN(4);
_end_code_mark = .;
} >FLASH
This is the last time I'm ...
1
vote
1
answer
272
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
1
answer
166
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 ...
9
votes
1
answer
3k
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
596
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
122
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
546
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
273
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
122
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
174
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
1k
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
635
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 ...
3
votes
0
answers
375
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
55
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 ...