ld

gcc/ld: Allow Code Placement And Removal of Unused Functions

跟風遠走 提交于 2019-12-11 10:03:19
问题 I am trying to allow specifying the location of particular symbols in my output binary without giving up the garbage collection feature of ld. For example: if I have in MyInclude.h #ifndef MY_INCLUDE_H_ #define MY_INCLUDE_H_ void CalledFunc(void); void UncalledFunc(void); #endif and a main program: #include "MyInclude.h" int main(void) { CalledFunc(); return 0; } compiling with gcc with ffunction-sections -fdata-sections and linking with --gc-sections shows in the map file that .text

collect2: fatal error: ld terminated with signal 9 [Killed]

蓝咒 提交于 2019-12-11 09:05:46
问题 I'm trying to build precimonious on Ubuntu 16.04.3 x64. I allocated 1GB memory for it. My file structure looks like ~ |--- llvm/ |--- precimonious/ where the llvm is on version 3.0 as mentioned at https://github.com/corvette-berkeley/precimonious#requirement. Then I followed the steps on the README but command make ended with ... llvm[1]: Linking Debug Shared Library libLLVM-3.0.so collect2: fatal error: ld terminated with signal 9 [Killed] compilation terminated. ... I went through some

ld complains: in function “_start”, undefined reference to “__libc_csu_fini” & “__libc_csu_init”

☆樱花仙子☆ 提交于 2019-12-11 07:14:43
问题 I'm compiled a GTK+ program using clang, rather than gcc. So far so good, except I can't have ld link correctly. Original makefile called gcc to do the linking, like this: gcc -g -O2 -export-dynamic -o my_application somefile.o another.o -pthread -lgnomeui-2 -lSM -lICE -lbonoboui-2 -lgnomevfs-2 -lgnomecanvas-2 -lgnome-2 -lpopt -lbonobo-2 -lbonobo-activation -lORBit-2 -lart_lgpl_2 -lgconf-2 -lglade-2.0 -lgtk-x11-2.0 -lgdk-x11-2.0 -latk-1.0 -lgio-2.0 -lpangoft2-1.0 -lpangocairo-1.0 -lgdk_pixbuf

Linking SDL_image errors

心不动则不痛 提交于 2019-12-11 07:09:49
问题 I am trying to install UltraStarDeluxe on a linux machine. The make uses compile scripts generated by fpc (Free Pascal) . On invoking make , the following is the error+warning message before ld exits: /usr/bin/ld: warning: ../game/link.res contains output sections; did you forget -T? /usr/bin/ld: cannot find -lSDL_image /home/sriram/ultraDX/ultrastardx-1.1-src/src/ultrastardx.dpr(344,1) Error: Error while linking /home/sriram/ultraDX/ultrastardx-1.1-src/src/ultrastardx.dpr(344,1) Fatal: There

Why do I get a zombie when I link assembly code without stdlib?

送分小仙女□ 提交于 2019-12-11 06:36:16
问题 I was experimenting with assembly code and the GTK+ 3 libraries when I discovered that my application turns into a zombie if I don't link the object file with gcc against the standard library. Here is my code for the stdlib -free application %include "gtk.inc" %include "glib.inc" global _start SECTION .data destroy db "destroy", 0 ; const gchar* strWindow db "Window", 0 ; const gchar* SECTION .bss window resq 1 ; GtkWindow * SECTION .text _start: ; gtk_init (&argc, &argv); xor rdi, rdi xor

LD_PRELOAD and linkage

喜欢而已 提交于 2019-12-11 06:23:55
问题 I have this small testcode atfork_demo.c : #include <stdio.h> #include <pthread.h> void hello_from_fork_prepare() { printf("Hello from atfork prepare.\n"); fflush(stdout); } void register_hello_from_fork_prepare() { pthread_atfork(&hello_from_fork_prepare, 0, 0); } Now, I compile it in two different ways: gcc -shared -fPIC atfork_demo.c -o atfork_demo1.so gcc -shared -fPIC atfork_demo.c -o atfork_demo2.so -lpthread My demo main atfork_demo_main.c is this: #include <dlfcn.h> #include <stdio.h>

compiling wget with static linking

瘦欲@ 提交于 2019-12-11 06:04:23
问题 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 -L/usr/lib/ssl -lz -static -o wget connect.o convert.o cookies.o ftp.o css-url.o ftp-basic.o ftp-ls.o hash.o host.o html-parse.o html-url.o http.o init.o log.o main.o netrc.o progress.o ptimer.o recur.o res.o retr.o spider.o url.o utils.o exits.o build

Missing library issues in compiling C code: ld can't find libraries

泄露秘密 提交于 2019-12-11 05:34:55
问题 I am trying to compile some C code which I inherited from a colleague. I am running into some missing library issues - that is, the output of make is gcc -L. -L/lib -L/lib -L/lib -L/lib64 -o gnd2fmdpara gnd2fmdpara.o git_version.o -lfmd -lnumerics -lmisc -llapack -lblas -lgfortran -lm -lz /usr/bin/ld: cannot find -llapack /usr/bin/ld: cannot find -lblas /usr/bin/ld: skipping incompatible /lib/libm.so when searching for -lm I have put the libraries where the LAPACK and BLAS stuff resides on

Symbol lookup error undefined symbol, but all symbols seem to be present

一曲冷凌霜 提交于 2019-12-11 05:04:45
问题 An executable seemingly can't resolve a symbol in a linked library. The relevant output of LD_DEBUG=libs shows that the correct library is loaded: 6557: /usr/lib/libcharon.so.0: error: symbol lookup error: undefined symbol: auth_class_names (fatal) /usr/libexec/ipsec/charon: symbol lookup error: /usr/lib/libcharon.so.0: undefined symbol: auth_class_names nm -D shows that the symbol auth_class_names is defined: nm -D /usr/lib/libcharon.so.0|grep auth_class_names U auth_class_names All clues

clone system call OS X not linking - undefined symbols [duplicate]

妖精的绣舞 提交于 2019-12-11 04:36:43
问题 This question already has answers here : Where is clone() method in sched.h on Mac OS X (2 answers) Closed 5 years ago . I would like to use the clone system call on OS X. It's a Unix system call so it shouldn't be a problem, right? I have successfully tried using fork , vfork and other similar functions. Here is the program I'm trying: #include <sched.h> //Clone resides here #include <stdlib.h> //standard library #include <stdio.h> #include <time.h> #include <limits.h> #include <sys/shm.h>