The ld (linker or loader) program combines object files, archive files and (references from) shared libraries, relocates their data and addresses together with symbol references. Linking is usually the final step of compiling a program.
Questions tagged [ld]
2795 questions
1
vote
0 answers
Get section length in linker script
I have a makefile which compiles modules written in assembler into a binary file to be loaded by another software. The interesting part of the makefile looks like this:
$(BUILD_ALL)/mod.elf.ld.inc:
$(LOG)
$Qecho "#define MOD(id, addr, ...)…

Florian Bach
- 919
- 7
- 22
1
vote
0 answers
gcc automatic method to figure out the order of dependent libraries
As known, when linking target to a series of libraries using gcc, we need to give the compiler (gcc) the correct order of the linked libraries. For example:
Source file a.cpp depends on libb.a, libc.a and libd.a.
Library libb.a depends on libc.a and…

user3677630
- 635
- 6
- 14
1
vote
2 answers
Makefile not working when changing function argument to const
I have a strange problem when compiling a C++ code using a makefile. The code first compiles perfectly. Then I change one function argument to "const". If I then compile, I will receive the error message when the code tries to use the function in…

Jonathan Lindgren
- 1,192
- 3
- 14
- 31
1
vote
1 answer
Unable to link nasm assembly with libc function (requires dynamic R_X86_64_PC32 reloc)
From the nasm tutorial here I got the following code for an assembly program:
global main
extern puts
section .text
main:
mov rdi, message
call puts
mov rax, 0
ret
message:
db "Hola, mundo", 0
I assemble it with…

Thayne
- 6,619
- 2
- 42
- 67
1
vote
1 answer
Linker error: How can there be a duplicate symbol in just one file?
From what I understand, a linker error due to a duplicate symbol means that:
a symbol was defined in more than one source file
resulting in the same symbol in two different object files after compilation
so the linker does not know which of the two…

303
- 888
- 1
- 11
- 31
1
vote
1 answer
Linker warning - Linking two modules of different target triples
I got this linker warning:
WARNING: Linking two modules of different target triples!
It sounds serious but not really clear to me.
What is the problem and what should I do about it?
Btw, I'm using Xcode 3.2.5 and LLVM Compiler 1.6
Thanks in…

adib
- 8,285
- 6
- 52
- 91
1
vote
3 answers
GNU linker ARM - why my sections overlap?
I need to add a small heap to use standard library functions on a TM4C ARM microcontroller (_sbrk requires the end symbol).
This is my linker script (came with a microcontroller demo):
/* Entry Point */
ENTRY(Reset_Handler)
HEAP_SIZE =…

filo
- 223
- 3
- 14
1
vote
0 answers
Problems with asm code inside a c script (at linking with other asm script)
i will explain my problem...
I'm coding a kernel in c + assembly, and when I coded some asm in-line in the main c script with gcc as compiler I had this problem:
All looked fine, the script compiled as always, without errors or warnings, but when I…

Rottenheimer2
- 425
- 1
- 5
- 13
1
vote
2 answers
linker - use own stdlib implementation
I have a problem. Requirement for the project is that we cannot link our app with standard library ( so -nostdlib is on in gcc).
my_stdlib.c contains implementation of all functions my_memset, my_memcpy ... but linker needs memcpy to copy…

bataliero1234
- 145
- 10
1
vote
0 answers
Linker (ld) crashes on Mac OS X when compiling with debuginfo, but works fine without
I'm working on a snow leopard machine (10.6.5) and I'm hunting a bug in our C++ application. However, I can't build our app with g++ -O0 -g, because the linker crashes:
g++-4.0 -arch i386 -arch x86_64 ... -dynamic -bundle -o SOMELIB.dylib

anrieff
- 619
- 1
- 6
- 15
1
vote
0 answers
compiling wget with static linking
I've tried to statically build wget ,
./bootstrap
env CPPFLAGS="-I/usr/include" LDFLAGS="-L/usr/lib/ssl" ./configure --with-ssl=openssl
make CPPFLAGS="-I/usr/include" LDFLAGS="-L/usr/lib -L/usr/lib/ssl -static"
cd src/
gcc -O2 -Wall -L/usr/lib…

mpapec
- 50,217
- 8
- 67
- 127
1
vote
0 answers
GAS assembly code exit()'s with SIGSEGV
I'm playing with GAS assembly and linking it without using gcc. Instead I'm using the as assembler and linking with ld.
My code:
.section .text
.globl _start
_start:
xorq %rax, %rax
movb $60, %al
movb $1, %dil
int $0x80
The command…
user2347437
1
vote
0 answers
'undefined reference' for only ONE function in entire shared library
I'm compiling a CPython Extension for an in-house library, and I'm pretty sure one of the functions that I'm using from the library is cursed.
When I run ld on the CPython Extension .so, it prints
./pyextension.so: undefined reference to…

Dmiters
- 2,011
- 3
- 23
- 31
1
vote
0 answers
In function `_start': undefined reference to `main'
I am working on a project that has more than 30 source files and some sub dirs>
I added the i2c support and I am trying to compile it but I got the following errors:
=== Making Control Interface Type.
make[1]: Entering directory…

Nizarkh
- 13
- 1
- 4
1
vote
1 answer
Make unable to link something it literally just compiled
I am in a rather small hobby project, we are creating a game, or at least trying to do so... The main issue we are facing is the fact that we are able to compile the project on MacOS and Linux, but not on Windows.
We are using GLFW as an interface…

7H3_H4CK3R
- 133
- 8