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

LD and NOLOAD sections: Understanding strange LMA value

I'm writing a baremetal kernel, and I have trouble understanding the output of ld in the case of a NOLOAD section. I am declaring symbols that only exists with MMU activated, so the VMA and LMA are not the same. I used to declaring such a section…
Vinz
  • 5,997
  • 1
  • 31
  • 52
0
votes
0 answers

IAR linker configuration, copy ROM to RAM for initialization

I try to define a separate RAM region/section in an IAR linker configuration file (.icf). The section should contain variables that are initialized like this: #pragma default_variable_attributes = @ "MY_SECTION" int a = 0; int b = 666; #pragma…
Silicomancer
  • 8,604
  • 10
  • 63
  • 130
0
votes
1 answer

How can I initialise the GDT?

I'm making an operating system and I'm stuck at the GDT. I've tried different tutorials, such as http://www.osdever.net/bkerndev/Docs/gdt.htm and http://www.jamesmolloy.co.uk/tutorial_html/4.-The%20GDT%20and%20IDT.html, but my os crashes always. How…
user7330717
0
votes
1 answer

How to override `--prefix` option in NASM per symbol?

I'm compiling C code with GCC and assembling some x86 code with NASM on Windows. Now, GCC by default (and I haven't been able to find an option to change this) prepends an underscore _ to all external symbol names (and expected names). I need this…
Noein
  • 522
  • 1
  • 6
  • 16
0
votes
0 answers

Pad each function with fixed number of nops

I want to pad each function with a required number of nops using linker script. I figured I would need -ffunction-sections switch during compilation. And add some QUAD(0) in the .text() defination of linker script. But it seems it is not working.…
zephyr0110
  • 223
  • 1
  • 11
0
votes
0 answers

How to put object files in a static library into output section?

How to put all object files into a section? For example, i have a.obj b.obj c.obj and main.obj. where a``b``care in a static library lib.lib. Now my linker script is like this: MYSECTION 0x1800000: { a*(*); b*(*); c*(*); main*(*); …
demonguy
  • 1,977
  • 5
  • 22
  • 34
0
votes
0 answers

Linker script location counter invalid value

I am writing a linker script as: SECTIONS { . = 0x100000; .phys . : { *(.phys.text) *(.phys.data) . = ALIGN(4K); } .phys.bss . (NOLOAD) : { boot_stack_bottom = .; . = . + 4K; …
amrzar
  • 355
  • 6
  • 22
0
votes
1 answer

Huge Binary size while ld Linking

I have a linker script that links code for imx6q(cortex-A9): OUTPUT_FORMAT("elf32-littlearm", "elf32-bigarm", "elf32-littlearm") OUTPUT_ARCH(arm) ENTRY(Reset_Handler) /* SEARCH_DIR(.) */ GROUP(libgcc.a libc.a) /* INPUT (crtbegin.o crti.o crtend.o…
Ajeesh
  • 95
  • 2
  • 15
0
votes
1 answer

ld ignores size of nobits input section

When working on a small 32-bit kernel for the x86 architecture I discovered something strange with how ld handles nobits sections. In my kernel I define a .bootstrap_stack section which holds a temporary stack for the initialisation part of the…
Alexguitar
  • 722
  • 4
  • 15
0
votes
0 answers

Trouble explaining gap between _edata_loc and __bss_start in linux linker file

I have trouble understanding gap between addresses _edata_loc and __bss_start symbols. According to the linker file there should not be any gap, yet symbol __bss_start, seems to be aligned to 0x2000 byte boundary ? Am I missing something here? I am…
nagla
  • 87
  • 1
  • 9
0
votes
0 answers

Global/static variables in boot loader

I tried to use below sample bootloader from Internet. __asm__(".code16gcc\n"); __asm__ ("jmpl $0, $main\n"); #define __NOINLINE __attribute__((noinline)) #define __REGPARM __attribute__ ((regparm(3))) #define __NORETURN …
0
votes
1 answer

cmake assembly: /usr/bin/ld: no input files

I'm trying to familiarize myself with cmake and I've chosen a very simple hobby kernel written in assembly as a test-bed. The problem is, it seems like the linker is called prior to compiling the sources, I'm getting this error: $ make [100%]…
ben lemasurier
  • 2,582
  • 4
  • 22
  • 37
0
votes
0 answers

How to generate Proteus compatible debug files using gcc-arm-none-eabi toolchain

I am developing a new project using LPC2138, an ARM7TDMI based micro-controller. I have already developed code for this micro-controller in Keil IDE. My intention here is to experiment with ARM code development using GNU toolchain in a Linux host…
0
votes
1 answer

Cortex-M3 realtime interrupt vector remap

I use GCC 4.9 (arm-none-eabi) with STM32 and want to place an interrupt table into an array in order to change interrup handler adresses when it's needed in my code. I read existing manuals and articles and did the following: I have to align the…
pugnator
  • 665
  • 10
  • 27
0
votes
1 answer

Implement a similar module_init as Linux kernel, but meet some trouble in ld script

I like the linux kernel module_init function very much, I would like to implement the same function for my user space applications. I try to modify the linker script to do this: 1, copy a x86-64 standard ld script 2, add my customized section …
user14944
  • 43
  • 6