GCC -nostdlib失败未定义参考`__libc_csu_fini“ [英] GCC -nostdlib fails with undefined reference to `__libc_csu_fini'

查看:2974
本文介绍了GCC -nostdlib失败未定义参考`__libc_csu_fini“的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我公司提供的链接我的文件:ld-2.7.so,libc-2.7.so和crt1.o但未能成功编译。是有可能从默认的链接到不同的glibc?

(静态编译或安装的独立的glibc不是一个选项。)

 的gcc -Wl,-dynamic-连接,ld-2.7.so,libc-2.7.so,crt1.o -nostdlib program.ccrt1.o:在功能`_start:
(+的.text×12):未定义的参考`__libc_csu_fini
crt1.o:在功能`_start:
(+的.text的0x19):未定义的参考`__libc_csu_init
/tmp/user/1000/ccauFlwt.o:在功能`findsize:
。program.c :(文字+ 0×21):未定义引用'统计'
/tmp/user/1000/ccauFlwt.o:在功能`findtime:
program.c :(文字+ 0x4c):未定义引用'统计'
collect2:劳工处返回1退出状态


解决方案

我发现了如何做到这一点:

rpath的规定,其中所提供的库的位置。此文件夹应包含:libc.so.6的,libdl.so.2,libgcc_s.so.1和也许更多。请与使用strace找出哪些库的二进制文件使用。

ld.so是所提供的链接

GCC -Xlinker -rpath = /默认/路径/要/库-Xlinker -I /默认/路径/要/库/ ld.so program.c

I provide the linker with my files: ld-2.7.so, libc-2.7.so and crt1.o but it fails to compile successfully. Is it possible to link to a different glibc from the default one ?

(Static compilation or installing a separate glibc is not an option.)

gcc -Wl,-dynamic-linker,ld-2.7.so,libc-2.7.so,crt1.o -nostdlib program.c

crt1.o: In function `_start':  
(.text+0x12): undefined reference to `__libc_csu_fini'  
crt1.o: In function `_start':  
(.text+0x19): undefined reference to `__libc_csu_init'  
/tmp/user/1000/ccauFlwt.o: In function `findsize':  
program.c:(.text+0x21): undefined reference to `stat'  
/tmp/user/1000/ccauFlwt.o: In function `findtime':  
program.c:(.text+0x4c): undefined reference to `stat'  
collect2: ld returned 1 exit status  

解决方案

I found out how to do it:

rpath specifies where the provided libraries are located. This folder should contain: libc.so.6, libdl.so.2, libgcc_s.so.1 and maybe more. Check with strace to find out which libraries your binary file uses.

ld.so is the provided linker

gcc -Xlinker -rpath=/default/path/to/libraries -Xlinker -I/default/path/to/libraries/ld.so program.c

这篇关于GCC -nostdlib失败未定义参考`__libc_csu_fini“的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆