Using gold instead of ld as a system linker on Fedora

I want to use gold as a system linker instead of ld, since ld does not support -fPIC and -shared. I followed this specific url to do this, golden plugin According to the documentation, I ran gcc -v filename.c to find out which gcc command is running. Then he tells me to check the line that runs collect2 and replace it with -plugin / path / to / LLVMgold.so. But gcc and collect2 are binaries. I studied a little ... and realized that gcc calls collect2, in turn collect2 calls the ld system linker, looking for ld-linux.so.2. I have gcc4.4.4 rpm package installed on my federation ... how can I change my configuration.

How to make gcc call ld-new / gold instead of collect2?

+4
source share
2 answers

I'm a little late, but I realized that Fedora comes out with gold distributed with binutils. ld.gold command. You can select it as the default linker using alternatives :

 # alternatives --config ld There is 2 program that provides 'ld'. Selection Command ----------------------------------------------- *+ 1 /usr/bin/ld.bfd 2 /usr/bin/ld.gold Enter to keep the current selection[+], or type selection number: 2 
+7
source

Since I am reading standard tools like ld or ar, you cannot rename or have an extension like ld_1.6 or anything else. perhaps you can change the name ld_new to ld and put its address before PATH in the .login.user file or temporarily add it on the command line. Then, when ever any program calls ld, you can be sure that your ld will be called first, this is the way I use ld-gold without changing bin / ld.

0
source

Source: https://habr.com/ru/post/1445206/


All Articles