gpt4 book ai didi

c - 使用新的自定义编译构建版本的 glibc/libc.so,在出现 “relocation has invalid symbol index” 错误期间会发生什么?

转载 作者:行者123 更新时间:2023-11-30 16:28:44 25 4
gpt4 key购买 nike

来自the link ,我想自己编译一个新的glibc。我知道编译 glic 很困难,所以第一步,我想编译一个新的 glibc,它与我的 Linux 系统上已经运行的完全相同的版本相匹配。我可以跳过工具链依赖项检查并开始专注于 glic 本身。

我的 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

谷歌搜索了好几天了,没有找到答案。有人说缺少主要功能。但我有主要功能,并且代码可以与已经存在的 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

最佳答案

I follow the "Compile against glibc build tree" section in the link, ... /usr/lib/debug/usr/lib/x86_64-linux-gnu/crt1.o(.debug_info)

在任何情况下,您的链接都不应使用 /usr/lib/debug/ 中的任何对象,并且您显示的命令行参数将当然不会导致这种情况发生。另请参阅this answer .

因此,您很可能没有讲述整个故事。也许您修改了一些环境变量或 GCC 驱动程序,或者您没有显示您使用的实际命令。

关于c - 使用新的自定义编译构建版本的 glibc/libc.so,在出现 “relocation has invalid symbol index” 错误期间会发生什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52242912/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com