使用新的自定义编译,构建版本的glibc / libc.so,在“重定位具有无效符号索引”错误期间会发生什么?

问题描述 投票:0回答:1

来自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搜索了几天,我找不到答案。有人说主要功能缺失了。但我有主要的功能,代码与已经存在的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
c gcc glibc
1个回答
0
投票

我按照链接中的“编译glibc构建树”部分,... /usr/lib/debug/usr/lib/x86_64-linux-gnu/crt1.o(.debug_info)

在任何情况下,您的链接都不应使用来自/usr/lib/debug/的任何对象,并且您显示的命令行参数肯定不会导致这种情况发生。另见this answer

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

© www.soinside.com 2019 - 2024. All rights reserved.