Page 1 of 1

How to install newly compiled ld-2.17.so on Centos 7.6.1810

Posted: 2019/09/17 20:12:53
by rhg910
This is a fresh install of Centos 7.6.1810 from one of the Centos mirror sites.

I have a freshly created ld-2.17.so that has not been modified, at least not the source. It is derived from glibc-2.17, the system (ldd --version) tells me the default installed linker version is 2.17. Although I don't have confidence in the ld-2.17.so file I created, I would like to eliminate questions regarding how I can replace the existing ld-2.17.so file, or if it is even possible.

So, I DL'ed glibc-2.17.tar.gz, unpacked it and followed the directions in the INSTALL file. After running configure with a --prefix test directory, make, and make install, I find ld-2.17.so in the test install directory - ~/test/lib.

Although the new file is significantly larger than the existing installed file, I made a backup copy of the existing installed file and copied the new file to /lib64, linking it to -

/lib64/ld-linux-x86-64.so.2 -> ld-2.17.so

Not surprisingly the system crashed when I rebooted. Good news is, I can boot from DVD, mount the appropriate partition and copy the original ld-2.17.so back in place, relink and reboot.

So, the initial question is simply can I do this and if so, how?

A second question might be - This is in order to attempt a hopefully minor change to ~elf/rtld.c. I'm simply trying to query some variable values to get a better understanding of what it is doing, not trying to actually change behaviour. If I were able to do that (modify rtld,c) , would this be as simple as implementing a new ld-2.17.0?

Thanks,
Rog

Re: How to install newly compiled ld-2.17.so on Centos 7.6.1810

Posted: 2019/09/17 20:41:40
by avij
Compiling from source is not going to end well, as you noticed.

The glibc shipped in CentOS contains a metric ton of patches on top of the upstream glibc. If you replace the patched CentOS version with unmodified glibc from upstream some crucial patch will not be included.

If you must make changes to glibc, you should do so by grabbing the current CentOS source rpm of glibc, then modifying it according to your needs and building the new binary rpm.

Re: How to install newly compiled ld-2.17.so on Centos 7.6.1810

Posted: 2019/09/17 20:49:20
by rhg910
Avij, thank you for the prompt replay and info. I will start on this first thing in the (my) morning. I would not have understood this on my own and am sure I will have followup questions.

Re: How to install newly compiled ld-2.17.so on Centos 7.6.1810

Posted: 2019/09/19 21:07:18
by rhg910
I grabbed the current rpm source, downloaded and installed it via rpm -i.

There were some yum installs needed that did not generate errors.

I followed the build instructions, adding a "--prefix" flag to the configure command so as not to overwrite anything, ran make and make install.

The following new directory appeared - ~/rpmbuild/BUILD/glibc-build/test containing the following subs -

drwxrwxr-x. 2 4096 Sep 19 09:49 bin
drwxrwxr-x. 2 4096 Sep 19 09:49 etc
drwxrwxr-x. 22 4096 Sep 19 09:49 include
drwxrwxr-x. 4 4096 Sep 19 12:29 lib
drwxrwxr-x. 3 4096 Sep 19 09:42 libexec
drwxrwxr-x. 2 4096 Sep 19 09:49 sbin
drwxrwxr-x. 5 4096 Sep 19 09:43 share
drwxrwxr-x. 3 4096 Sep 19 09:43 var

And within lib I found a new ld-2.17.so -

-rwxr-xr-x. 1 root root 892712 Sep 19 09:49 ld-2.17.so
lrwxrwxrwx. 1 root root 10 Sep 19 09:49 ld-linux-x86-64.so.2 -> ld-2.17.so

When I first tried to run this uninstalled version of ./ld-linux-x86-64.so.2 /usr/bin/ls it failed with a missing library. I copied the missing file from the real installed directory (/usr/lib64), tried again, found a second missing file. Ultimately there were three that I had to copy into place.

At that point I could run ./ld-linux-x86-64.so.2 /usr/bin/ls.

I did try to copy the new ld-2.17.so into /usr/lib64 and reboot at which point it failed immediately during the reboot. So I guess my main question is, is there more to installing this file than simply copying?

Also I noticed that the new ld-2.17.so file is much larger than the original installed version which was also true on the original attempt mentioned in the first post. In fact, sizewise, the new ld-2.17.so looks a lot like ld.so? Here is an ls of the ld .so files as currently working. I am not currently using the new version of ld-2.17.so which is saved as ld-2.17.so-new -

-rwxr-xr-x. 1 root root 163400 Sep 19 13:29 ld-2.17.so
-rwxr-xr-x. 1 root root 892712 Sep 19 11:10 ld-2.17.so-new
-rwxr-xr-x. 1 root root 163400 Sep 17 08:23 ld-2.17.so.save
lrwxrwxrwx. 1 root root 10 Sep 19 13:29 ld-linux-x86-64.so.2 -> ld-2.17.so
-rwxr-xr-x. 1 root root 850208 Sep 19 13:36 ld.so

Anyway, any advice or information would be much appreciated. And in case it might matter, the real goal is to be able to install a new ld-2.17.so, not necessarily the entire glibc unless it is required.

Thank you for the help.