Questions tagged [ld]

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.

Filter by
Sorted by
Tagged with
0 votes
0 answers
17 views

Clang ld failure in yocto build

While generating SDK for hardknott-based distro the following error occured from clang_git.bb:do_compile(): qemux86-64/tmp-glibc/hosttools/ld: cannot find -ltinfo qemux86-64/tmp-glibc/hosttools/ld: ...
Wojciech Siudy's user avatar
1 vote
0 answers
82 views

How to compile x86 Assembly generated via rustc into an executable?

I am having difficulties assembling the x86 Assembly that is compiled by the rustc compiler. I have tried various methods of assembling it, but am getting no output. The code in itself is very simple, ...
kush's user avatar
  • 11
1 vote
1 answer
54 views

Linking an object file to the C standard library with ld

Say I'm trying to create an executable binary from: // main.c #include <stdio.h> int main() { printf("Hello, world!"); return 0; } I can just run gcc main.c and I get the ...
fmg's user avatar
  • 825
1 vote
0 answers
59 views

Macos C compilation error "ld: Undefined symbols: _main, referenced from: <initial-undefines>"

I am having a compilation error on mac when I try to compile my c program error ld: Undefined symbols: _main, referenced from: <initial-undefines>` #include <stdio.h> int main()...
Flames's user avatar
  • 11
4 votes
1 answer
114 views

Apple Linker Warning "ld: warning: -undefined error is deprecated"

Currently seeing this linker warning in our C++ builds for macOS: [build] [430/431 99% :: 9.484] Linking CXX executable foobar [build] ld: warning: -undefined error is deprecated We set this linker ...
jpr42's user avatar
  • 1,001
0 votes
1 answer
39 views

why does the arm-poky-linux-gnueabi-gcc linker not use the definition of a symbol that it says it found on the C-library?

#include<stdio.h> //#include<sys/io.h> extern int ioperm(unsigned long from, unsigned long num, int turn_on); int main() { unsigned long from, num; int turn_on; ioperm( from,...
krammer's user avatar
  • 11
-1 votes
0 answers
35 views

Regex in linker script

I'm trying to place printf function on the top of .text section: ... GROUP: { .text? ALIGN(64): { *(.text._Z7my_funcv) *printf.o(.text) ... } ...
Defex's user avatar
  • 135
0 votes
1 answer
39 views

ld: multiple definitions of const variable

I am going through the PintOS project using the JHU version of PintOS. But when I make under src/userprog(which is ~/Documents/PintOS/userprog/ on my local machine), it throws this error to me: cd ...
Pairman's user avatar
  • 23
-2 votes
0 answers
19 views

linking problems undefined symbols for architecture [duplicate]

what is equivalent linux ld -Wl,-z,relro -Wl,-z,now --gcc-sections? I try add to LDFLAGS LDFLAGS= -Wl,-dead_strip but this not helping i compile program with automatic generated flags CFLAGS=-march=...
ProBo's user avatar
  • 7
1 vote
0 answers
112 views

Xcode 15.0.1, macOS Sonoma: Clang archive or linking issue

I have issues building my project on C, and I have created minimal build to reproduce the issue. Project build and use .a library, the error: linker-test$ make gcc -Wall -g -c -o main.o main.c gcc -...
Sergey Rybalko's user avatar
2 votes
0 answers
29 views

What is the correct way of using --retain-symbol-file? when using the ld

I want to use the linker flag --retain-symbols-file=filename but I am not getting the answer as expected. This is my project where I am having two cpp files (File1.cpp, File2.cpp) I am converting them ...
Rohan Pande's user avatar
0 votes
2 answers
110 views

I Can't compile c++ with SFML library by gcc

so first there is a file named main.cpp and I want to compile it using this: g++ -o sfml_example main.cpp -lsfml-graphics -lsfml-window -lsfml-system btw this is the code: #include <SFML/Graphics....
SI TUKANG GAMBAR's user avatar
0 votes
1 answer
57 views

g++ "/ld.exe: cannot find l:mylib.a: No such file or directory

After I have read several forum posts to my problem which not helped me at all, I ask you for help. I am trying to create a .dll with GNU compiler on Windows. This .dll needs a library, we call it ...
gollerxd's user avatar
0 votes
0 answers
20 views

Manually linked file doesn't exist when trying to run it, but does otherwise [duplicate]

I'm messing around with some assembler and trying to assemble it with nasm and link it with ld on my ubuntu machine. This is my code EXTERN puts SECTION .data hello: db "Hello world!\0" ...
FalcoGer's user avatar
  • 2,386
0 votes
0 answers
13 views

What's the meaning for "-z" ld command line option

The ld doc shows that some of the options are prefixed with -z: -z keyword The recognized keywords are: ‘call-nop=prefix-addr’ ‘call-nop=suffix-nop’ ‘call-nop=prefix-byte’ ‘call-nop=suffix-...
Hsu Hau's user avatar
  • 604
0 votes
2 answers
115 views

AVR: Creating and understanding minimum startup code and linker scripts from scratch

EDITED AND SHORTENED My goal is to write the minimum necessary startup-code and linker script "from scratch" for a system which is new to me and reach main(). I only want to use the ...
Alex's user avatar
  • 45
0 votes
0 answers
35 views

Calculate Symbol-Size From Linker-Map-File

I'm trying to understand linker map files. This is the beginning of my text-section: .text 0x08000400 0x14ba0 0x08000400 . = ALIGN (_flash_alignment) *(....
Tim Hilt's user avatar
  • 635
2 votes
1 answer
81 views

Can I prevent the linker from adding fill bytes?

I am experimenting with some x86 bare metal code, specifically a simple bootloader which loads a second stage etc., all packed into one image. Right now, I have the following linker script: ...
milck's user avatar
  • 650
0 votes
0 answers
116 views

collect2: error: ld returned 1 exit status; ld error; gcc

my code: #include <iostream> #include <random> int main(){ std::default_random_engine generator; std::uniform_int_distribution dice_roll(1,6); std::cout << dice_roll(...
BigBunny's user avatar
3 votes
1 answer
87 views

How to use GNU Assembler (GAS) to create a hand-written ELF File from the corresponding .s file

Introduction I am trying to learn about ELF Files, and also experiment with them a little bit. Currently, I am following the tutorial here, which is about creating a tiny 32-bit ELF file that just ...
pikafan_8080's user avatar
0 votes
0 answers
24 views

Filling unused space between sections with GNU LD

I'm linking some code for 8088 CPU (loaded at 0xF0000..0xFFFFF) with the following LD script: SECTIONS { .code 0x0000 : AT(0xF0000) { *(.rodata); *(.text); } .reset 0xFFF0 :...
Andrew Dunai's user avatar
  • 3,071
2 votes
1 answer
47 views

How to get the missing table Schema while using quantumleap in cratedb using orion LD context broker though the subscriptions are working?

{ "cols": [ "schema_name" ], "rows": [ [ "blob" ], [ "doc" ], [ ...
Tony Rosset's user avatar
1 vote
1 answer
43 views

C++ linker options for RPATH of linked library

I have a MyApp project which is dependent of lib1.so library. lib1.so has own dependency lib2.so: MyApp -> lib1.so -> lib2.so I want to run MyApp with all dependencies in one directory. For ...
Kosterio's user avatar
  • 121
3 votes
0 answers
196 views

Calling native code from an AOT-compiled Java application using CNI

GNU Compiler for Java provides two methods to invoke native code from a Java application. First, there's a JNI specification authored by Sun Microsystems, and GCJ adheres to this specification. ...
Bass's user avatar
  • 5,014
0 votes
0 answers
35 views

Unable to start wails app due to linking error: undefined reference to `gst_query_set_selectable`

I am trying to test out wails on my Opensuse workstation. I've installed all the dependencies, but when I run wails dev on a fresh project I am met with a linking error: Building application for ...
richbai90's user avatar
  • 5,024
0 votes
0 answers
39 views

"Permission denied" when linker tries to open output executable? [duplicate]

I was trying to add texture in my freeglut opengl code: #include <GL/glut.h> #define STB_IMAGE_IMPLEMENTATION #include "stb_image.h" GLuint texture; void loadTexture(const char* ...
Priyamwada Sonnet's user avatar
0 votes
1 answer
92 views

x86 procedure (32-bit) only works on certain parts of my code

All genuine solutions/advice/help is welcome. Thank you in advance. Here is my basic question: Why does the 'ClrScreen' procedure at the bottom of my 'Print.asm' file not work in certain locations of ...
HerrWeishaupt's user avatar
0 votes
0 answers
18 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 ...
Madhav's user avatar
  • 84
0 votes
0 answers
51 views

What could cause this binutils gold linker internal error?

I'm trying to link some C++ code, C code (the bridge), and Swift code. Unfortunately I'm getting this error: /usr/bin/ld.gold: internal error in format_file_lineno, at ../../gold/dwarf_reader.cc:2278 ...
s_question's user avatar
0 votes
0 answers
14 views

GNU Binutils ld Final Link Error: file truncated

trying to manually link some object file archives (.a) files, no obvious warnings besides overlay symbols not being in segment (this compiled in a different configuration so I wasn't concerned), now ...
David Xie's user avatar
0 votes
0 answers
18 views

The linker is not linking the C and asm object files [duplicate]

I'm working on an OS and I'm trying to get it to load. I have a dummy kernel for now, and I'm trying to get my bootloader to load it im using a make file to do it faster and it keeps giving the same ...
Minecraft Teen's user avatar
1 vote
1 answer
55 views

Can I enforce a linker warning/error when multiple symbol definitions are present?

Assume I have liba.so and libb.so and both define a symbol foo. For better comprehension, let's assume both libraries are compiled from a single file each and foo is a C function like this: int foo(...
andreee's user avatar
  • 4,489
0 votes
0 answers
68 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 ...
Self's user avatar
  • 135
1 vote
1 answer
88 views

Multiple definition errors when compiling gcc 4 with gcc 11

I am following along an operating systems class from Spring 2023 and trying to setup an environment using their instructions so that I can do the class assignments. Part of those instructions are ...
whaleshark's user avatar
0 votes
0 answers
178 views

How to install and add google re2 to a c++ application

Background I'm trying to use Google re2 in my c++ application to evaluate regex. I've done these to install abseil first, and then re2: abseil cd ~/Desktop git clone https://github.com/abseil/abseil-...
Shahaboddin's user avatar
0 votes
0 answers
79 views

Cannot install Python from source on Apple Silicon M1

I am trying to install Python from source according to the readme using: ./configure make <-- Error happens here make test sudo make altinstall However, I cannot complete the make command since it ...
gernophil's user avatar
  • 168
0 votes
1 answer
62 views

GCC cannot find existing library

I am trying to write a small web application in C, which connects to PostgreSQL using libpq. I installed libpq on Debian 13, and have used the following Makefile to build the source code: CC = gcc ...
Nexuss's user avatar
  • 57
2 votes
3 answers
76 views

Linking a shared library

Trying to link a shared library throws an undefined reference in main. The exact error is: /usr/bin/ld: /tmp/cc3pGAwi.o: in function `main': main.c:(.text+0x1e): undefined reference to `sum' collect2: ...
lonk's user avatar
  • 21
0 votes
0 answers
21 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? ...
codepoet's user avatar
  • 154
0 votes
1 answer
32 views

Why does GNU ld linker doesn't remember all the symbols it sees

When linking with GNU ld, the order is important. The dependent library must appear before the dependency. For instance, if a function in file1.a calls a function in file2.a, then the linking order ...
Pier-Yves Lessard's user avatar
2 votes
1 answer
70 views

Why is symbol binding maintained in a dynamic symbol table?

My understanding is that - (1) Symbol binding (global/local/weak) is used by the linker to limit the scope of a symbol to its defining object file or other object files/ libraries linked together, and ...
Ofek Shilon's user avatar
  • 15.2k
0 votes
0 answers
16 views

Fedora RiscV64:the following error when switching the gcc version from 13 to 12

When I use dnf on the command line for update or install, the following error message will appear. [fedora@fedora-riscv libdnf]$ sudo dnf upgrade --refresh -y ... ImportError: /usr/local/gcc-12.2.0/...
JSkion's user avatar
  • 1
0 votes
1 answer
46 views

Assembly always returns 0 [duplicate]

This are the instructions that I have: global _start _start: mov ecx, 0x12 mov ebx, 0x2 label: add ebx, ebx dec ecx cmp ecx, 0 jg label mov eax, 1 int 0x80 I am new ...
Osman Afandiyev's user avatar
0 votes
0 answers
12 views

gcc ld objdump. What tool should I use in order to have an the section of an object file having all three permissions read write and execute?

I am using g++ on ubuntu. I compile some code and I need to unify the code section ".text" with the data section ".data" regarding a specific compilation unit ( object file ). I ...
George Kourtis's user avatar
1 vote
1 answer
56 views

Global offset table .got section does not take into account some variables in a position idependent program for stm32

I have been trying to implement position independent code in my firmware for a bootloader + dual slot application firmware fota strategy on a stm32 microcontroller. The firmware is correctly launched ...
Matteo Vittorio Ricciutelli's user avatar
0 votes
0 answers
35 views

g++ failed to print meaningful error message in linking

In my environment, in failed linking case of g++, only collect2: error: ld returned 1 exit status reported: bsl@ubuntu:~/compiletest$ g++ -v main.o Using built-in specs. COLLECT_GCC=g++ ...
fulltopic163's user avatar
0 votes
0 answers
23 views

AIX build getting symbol from wrong .a library but works well on legacy HP-UX

On a large legacy build on HP-UX with many static libraries. Two of which have the same function, call it "dupxyz". All works fine as dupxyz is pulled out of the desired module. On the AIX ...
Gilbert's user avatar
  • 3,740
0 votes
0 answers
19 views

Is using the INFO, DSECT, COPY, and OVERLAY output section types discouraged?

From the LD docs: DSECT COPY INFO OVERLAY These type names are supported for backward compatibility, and are rarely used. They all have the same effect: the section should be marked as not ...
oyvind's user avatar
  • 1,459
0 votes
1 answer
221 views

ld: library not found for -lSystem error when linking for Apple Silicon

xcode is Version 14.3.1 (14E300c) Mac OS is Ventura 13.5 Command I am running: ld hello.o -o hello -l System -syslibroot 'xcrun -sdk macosx --show-sdk-path' -e _main -arch arm64 The linker produces ...
William Casperson's user avatar
0 votes
1 answer
88 views

Set symbol value by -defsym in makefile

I want to set a symbol defined in the linker script dynamically by makefile. In the target rules I've the following code : $(OBJCOPY) -O binary --only-section=.text $(APPNAME).elf $(APPNAME).bin $(...
babylone's user avatar

1
2 3 4 5
57