From the link, I would like to compile a new glibc by myself. I know that compiling a glic is difficult, so on my first step, I would like to comiple a new glibc that match the exact same version already running on my linux system. I can skip toolchain dependency checking and start to focus on the glic iteself.
从链接,我想自己编译一个新的glibc。我知道编译glic很困难,所以在我的第一步,我想要一个新的glibc,它与我在linux系统上运行的完全相同的版本相匹配。我可以跳过工具链依赖性检查并开始关注glic iteself。
My ubuntu info is like:
我的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
The already existed glibc is: 2.19. check the version like:
已经存在的glibc是:2.19。检查版本如:
abbott@abbott-VirtualBox:/software/glibc/code$ ldd --version
ldd (Ubuntu EGLIBC 2.19-0ubuntu6.9) 2.19
I prepare a very simple c code for testing:
我准备了一个非常简单的c代码进行测试:
#include <stdio.h>
int main(){
long z; printf("Long int size is %i bytes long!\n", sizeof(z));
return 0;
}
I compile this code using the already existed gcc,
我使用已经存在的gcc编译此代码,
gcc simple.c
I goe the "a.out", it's ok. it's runnable it's wonderful:
我去“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)
So, I download from here, I choose the "glibc-2.19.tar.gz".
所以,我从这里下载,我选择“glibc-2.19.tar.gz”。
I put the source at /software/glibc/glibc-2.19
我把源代码放在/software/glibc/glibc-2.19
compile at /software/glibc/compile-2.19
在/software/glibc/compile-2.19编译
compile result is OK:
编译结果没问题:
abbott@abbott-VirtualBox:/software/glibc/compile-2.19$ ../glibc-2.19/configure -prefix=/usr
abbott@abbott-VirtualBox:/software/glibc/compile-2.19$ make
In the "compile-2.19" folder, there is a testrun.sh shell code, I follow the "Compile normally, run under new glibc" section in the link, it's ok, it works.
在“compile-2.19”文件夹中,有一个testrun.sh shell代码,我按照“正常编译,在新glibc下运行”一节中的链接,没关系,它的工作原理。
abbott@abbott-VirtualBox:/software/glibc/compile-2.19$ ./testrun.sh ../code/a.out
I follow the "Compile against glibc build tree" section in the 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
It output:
它输出:
/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
I googled for several days, I cound not find the answers. some says that the main func is missing. but I have the main func, and the code works fine with the already existed glibc.
我用谷歌搜索了几天,我找不到答案。有人说主要功能缺失。但我有主要的功能,并且代码与已经存在的glibc一起工作正常。
Question 1:
问题1:
Would anybody help to find out how to fix the problem?
有人会帮忙找出解决问题的方法吗?
/usr/bin/ld: /usr/lib/debug/usr/lib/x86_64-linux-gnu/crt1.o(.debug_info): relocation 0 has invalid symbol index 11
Question 2:
问题2:
From the link here, it's another sample of how to compile glibc, it use “glibc-2.0.6.tar.gz”, I check this version from the ftpSite
从这里的链接,这是如何编译glibc的另一个示例,它使用“glibc-2.0.6.tar.gz”,我从ftpSite检查这个版本
tar xzf glibc-2.0.6.tar.gz
cd glibc-2.0.6
tar xzf ../glibc-linuxthreads-2.0.6.tar.gz
tar xzf ../glibc-crypt-2.0.6.tar.gz
tar xzf ../glibc-localedata-2.0.6.tar.gz
../configure --enable-add-ons=linuxthreads,crypt,localedata --prefix=/usr
the version of 2.0.6 is pitty old. 2.0.6 was released almost 20 years ago. So, I will not follow the content on the page.
2.0.6的版本很糟糕。 2.0.6在大约20年前发布。所以,我不会按照页面上的内容。
But I have some doubts,I can't find the "glibc-crypt-2.0.6.tar.gz" package, where is it now?
但我有些疑惑,我找不到“glibc-crypt-2.0.6.tar.gz”包,它现在在哪里?
Now, I use the 2.19 version of glibc, Would I still need to use localedata, crypt as add-ons ?
现在,我使用glibc的2.19版本,我还需要使用localedata,crypt作为附加组件吗?
I know that linuxthreads is still independent, but which version is ok to match the glibc-2.19?
我知道linuxthreads仍然是独立的,但哪个版本可以匹配glibc-2.19?
I can't find the glibc-linuxthreads-2.19.tar.gz.
我找不到glibc-linuxthreads-2.19.tar.gz。
Can I use the lastest glibc-linuxthreads-2.3.tar.gz?
我可以使用最新的glibc-linuxthreads-2.3.tar.gz吗?
Are there any guidline about how to choose the matched version?
有关于如何选择匹配版本的指导方针吗?
1 个解决方案
#1
0
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)
我按照链接中的“编译glibc构建树”部分进行操作,... /usr/lib/debug/usr/lib/x86_64-linux-gnu/crt1.o(.debug_info)
Under no circumstances should your link use any objects from /usr/lib/debug/
, and the command line arguments you show will certainly not cause that to happen. See also this answer.
在任何情况下,您的链接都不应使用/ usr / lib / debug /中的任何对象,并且您显示的命令行参数肯定不会导致这种情况发生。另见这个答案。
Therefore, it is likely that you are not telling the whole story. Perhaps you've modified some environment variables, or the GCC driver, or you are not showing the actual command you used.
因此,很可能你并没有讲完整个故事。也许您已经修改了一些环境变量或GCC驱动程序,或者您没有显示您使用的实际命令。
#1
0
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)
我按照链接中的“编译glibc构建树”部分进行操作,... /usr/lib/debug/usr/lib/x86_64-linux-gnu/crt1.o(.debug_info)
Under no circumstances should your link use any objects from /usr/lib/debug/
, and the command line arguments you show will certainly not cause that to happen. See also this answer.
在任何情况下,您的链接都不应使用/ usr / lib / debug /中的任何对象,并且您显示的命令行参数肯定不会导致这种情况发生。另见这个答案。
Therefore, it is likely that you are not telling the whole story. Perhaps you've modified some environment variables, or the GCC driver, or you are not showing the actual command you used.
因此,很可能你并没有讲完整个故事。也许您已经修改了一些环境变量或GCC驱动程序,或者您没有显示您使用的实际命令。