从the link,我想自己编译一个新的glibc。我知道编译glic是很困难的,因此在第一步中,我想对一个新的glibc进行匹配,使其与Linux系统上已经运行的完全相同的版本相匹配。我可以跳过工具链依赖性检查,而开始专注于glic iteself。
我的ubuntu信息如下:
abbott@abbott-VirtualBox:/software/glibc/code$ uname -a
Linux abbott-VirtualBox 4.4.0-31-generic #50~14.04.1-Ubuntu SMP Wed Jul 13 01:07:32 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux
abbott@abbott-VirtualBox:/software/glibc/code$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 14.04.5 LTS
Release: 14.04
Codename: trusty
已经存在的glibc是:2.19。检查类似的版本:
abbott@abbott-VirtualBox:/software/glibc/code$ ldd --version
ldd (Ubuntu EGLIBC 2.19-0ubuntu6.9) 2.19
我准备了一个非常简单的c代码进行测试:
#include <stdio.h>
int main(){
long z; printf("Long int size is %i bytes long!\n", sizeof(z));
return 0;
}
我使用已经存在的gcc编译此代码,
gcc simple.c
我去了“ a.out”,没关系。可以运行,很棒:
abbott@abbott-VirtualBox:/software/glibc/code$ ldd a.out
linux-vdso.so.1 => (0x00007ffceaf0b000)
libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f1a66f64000)
/lib64/ld-linux-x86-64.so.2 (0x000055b9118c7000)
因此,我从here下载,选择了“ glibc-2.19.tar.gz”。
我把来源放在
/software/glibc/glibc-2.19
编译于
/software/glibc/compile-2.19
编译结果正常:
abbott@abbott-VirtualBox:/software/glibc/compile-2.19$ ../glibc-2.19/configure -prefix=/usr
abbott@abbott-VirtualBox:/software/glibc/compile-2.19$ make
在“ compile-2.19”文件夹中,有一个testrun.sh shell代码, 我遵循link中的“正常编译,在新glibc下运行”部分,没关系,它可以正常工作。
abbott@abbott-VirtualBox:/software/glibc/compile-2.19$ ./testrun.sh ../code/a.out
我遵循link中的“针对glibc构建树进行编译”部分,
GLIBC=/software/glibc/compile-2.19
gcc \
-Wl,-rpath=${GLIBC}:\
${GLIBC}/math:\
${GLIBC}/elf:\
${GLIBC}/dlfcn:\
${GLIBC}/nss:\
${GLIBC}/nis:\
${GLIBC}/rt:\
${GLIBC}/resolv:\
${GLIBC}/crypt:\
${GLIBC}/nptl:\
${GLIBC}/dfp \
-Wl,--dynamic-linker=${GLIBC}/elf/ld.so
-o myligcsimple simple.c
输出:
/usr/bin/ld: /usr/lib/debug/usr/lib/x86_64-linux-gnu/crt1.o(.debug_info): relocation 0 has invalid symbol index 11
/usr/bin/ld: /usr/lib/debug/usr/lib/x86_64-linux-gnu/crt1.o(.debug_info): relocation 1 has invalid symbol index 12
/usr/bin/ld: /usr/lib/debug/usr/lib/x86_64-linux-gnu/crt1.o(.debug_info): relocation 2 has invalid symbol index 2
/usr/bin/ld: /usr/lib/debug/usr/lib/x86_64-linux-gnu/crt1.o(.debug_info): relocation 3 has invalid symbol index 2
/usr/bin/ld: /usr/lib/debug/usr/lib/x86_64-linux-gnu/crt1.o(.debug_info): relocation 4 has invalid symbol index 11
/usr/bin/ld: /usr/lib/debug/usr/lib/x86_64-linux-gnu/crt1.o(.debug_info): relocation 5 has invalid symbol index 13
/usr/bin/ld: /usr/lib/debug/usr/lib/x86_64-linux-gnu/crt1.o(.debug_info): relocation 6 has invalid symbol index 13
/usr/bin/ld: /usr/lib/debug/usr/lib/x86_64-linux-gnu/crt1.o(.debug_info): relocation 7 has invalid symbol index 13
/usr/bin/ld: /usr/lib/debug/usr/lib/x86_64-linux-gnu/crt1.o(.debug_info): relocation 8 has invalid symbol index 12
/usr/bin/ld: /usr/lib/debug/usr/lib/x86_64-linux-gnu/crt1.o(.debug_info): relocation 9 has invalid symbol index 13
/usr/bin/ld: /usr/lib/debug/usr/lib/x86_64-linux-gnu/crt1.o(.debug_info): relocation 10 has invalid symbol index 13
/usr/bin/ld: /usr/lib/debug/usr/lib/x86_64-linux-gnu/crt1.o(.debug_info): relocation 11 has invalid symbol index 13
/usr/bin/ld: /usr/lib/debug/usr/lib/x86_64-linux-gnu/crt1.o(.debug_info): relocation 12 has invalid symbol index 13
/usr/bin/ld: /usr/lib/debug/usr/lib/x86_64-linux-gnu/crt1.o(.debug_info): relocation 13 has invalid symbol index 13
/usr/bin/ld: /usr/lib/debug/usr/lib/x86_64-linux-gnu/crt1.o(.debug_info): relocation 14 has invalid symbol index 13
/usr/bin/ld: /usr/lib/debug/usr/lib/x86_64-linux-gnu/crt1.o(.debug_info): relocation 15 has invalid symbol index 13
/usr/bin/ld: /usr/lib/debug/usr/lib/x86_64-linux-gnu/crt1.o(.debug_info): relocation 16 has invalid symbol index 13
/usr/bin/ld: /usr/lib/debug/usr/lib/x86_64-linux-gnu/crt1.o(.debug_info): relocation 17 has invalid symbol index 13
/usr/bin/ld: /usr/lib/debug/usr/lib/x86_64-linux-gnu/crt1.o(.debug_info): relocation 18 has invalid symbol index 13
/usr/bin/ld: /usr/lib/debug/usr/lib/x86_64-linux-gnu/crt1.o(.debug_info): relocation 19 has invalid symbol index 21
/usr/bin/ld: /usr/lib/debug/usr/lib/x86_64-linux-gnu/crt1.o(.debug_line): relocation 0 has invalid symbol index 2
/usr/lib/gcc/x86_64-linux-gnu/4.8/../../../x86_64-linux-gnu/crt1.o: In function `_start':
(.text+0x20): undefined reference to `main'
collect2: error: ld returned 1 exit status
我用Google搜索了几天,找不到答案。有人说缺少主要功能。但是我有主要的func,并且代码可以与已经存在的glibc正常工作。
问题1:
有人会帮忙找出解决问题的方法吗?
/usr/bin/ld: /usr/lib/debug/usr/lib/x86_64-linux-gnu/crt1.o(.debug_info): relocation 0 has invalid symbol index 11
答案 0 :(得分:0)
我遵循链接中的“针对glibc构建树进行编译”部分,...
if car.brand == 'Tesla; price = price * 0.6
在任何情况下,您的链接都应该使用/usr/lib/debug/usr/lib/x86_64-linux-gnu/crt1.o(.debug_info)
中的 any 个对象,并且显示的命令行参数当然不会导致这种情况发生。另请参见this answer。
因此,您可能没有讲完整的故事。也许您已经修改了一些环境变量或GCC驱动程序,或者没有显示实际使用的命令。