Now we amend the GCC specs file so that it points to the new dynamic linker. A perl command accomplishes this:
gcc -dumpspecs | \ perl -p -e 's@/tools/lib/ld@/lib/ld@g;' \ -e 's@\*startfile_prefix_spec:\n@$_/usr/lib/ @g;' > \ $(dirname $(gcc --print-libgcc-file-name))/specs
It is a good idea to visually inspect the specs file to verify the intended change was actually made.
Note that /lib
is now the prefix of our
dynamic linker.
It is imperative at this point to stop and ensure that the basic functions (compiling and linking) of the adjusted toolchain are working as expected. To do this, perform a sanity check:
echo 'main(){}' > dummy.c gcc dummy.c readelf -l a.out | grep ': /lib'
If everything is working correctly, there should be no errors, and the output of the last command will be:
[Requesting program interpreter: /lib/ld.so.1]
Note that /lib
is now the prefix of
our dynamic linker.
If the output does not appear as shown above or is not received at all, then something is seriously wrong. Investigate and retrace the steps to find out where the problem is and correct it. The most likely reason is that something went wrong with the specs file amendment above. Any issues will need to be resolved before continuing on with the process.
Once everything is working correctly, clean up the test files:
rm -v dummy.c a.out