- Timestamp:
- 01/26/2006 02:45:36 PM (19 years ago)
- Branches:
- 10.0, 10.0-rc1, 10.1, 10.1-rc1, 11.0, 11.0-rc1, 11.0-rc2, 11.0-rc3, 11.1, 11.1-rc1, 11.2, 11.2-rc1, 11.3, 11.3-rc1, 12.0, 12.0-rc1, 12.1, 12.1-rc1, 12.2, 12.2-rc1, 6.3, 6.4, 6.5, 6.6, 6.7, 6.8, 7.0, 7.1, 7.2, 7.3, 7.4, 7.5, 7.5-systemd, 7.6, 7.6-systemd, 7.7, 7.7-systemd, 7.8, 7.8-systemd, 7.9, 7.9-systemd, 8.0, 8.1, 8.2, 8.3, 8.4, 9.0, 9.1, arm, bdubbs/gcc13, ml-11.0, multilib, renodr/libudev-from-systemd, s6-init, trunk, xry111/arm64, xry111/arm64-12.0, xry111/clfs-ng, xry111/lfs-next, xry111/loongarch, xry111/loongarch-12.0, xry111/loongarch-12.1, xry111/loongarch-12.2, xry111/mips64el, xry111/multilib, xry111/pip3, xry111/rust-wip-20221008, xry111/update-glibc
- Children:
- 942465e
- Parents:
- 40abfd5
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
chapter06/readjusting.xml
r40abfd5 r2914987b 20 20 directories.</para> 21 21 22 <para>First, amend the GCC specs file so that it points to the new 22 <para>First, create a symlink to the adjusted linker we created in chapter 5.</para> 23 24 <screen><userinput>ln -sv /tools/bin/ld-new /usr/bin/ld</userinput></screen> 25 26 <para>Next, amend the GCC specs file so that it points to the new 23 27 dynamic linker. A <command>sed</command> command accomplishes this:</para> 24 28 25 29 <screen><userinput>SPECFILE=`dirname $(gcc -print-libgcc-file-name)`/specs && 26 30 gcc -dumpspecs > $SPECFILE && 27 sed -i 's@^/tools/lib/ld-linux.so.2@/lib/ld-linux.so.2@g' $SPECFILE && 31 sed -i -e '/^\*link:$/{n;s,$, -L/usr/lib,}' \ 32 -e 's@^/tools/lib/ld-linux.so.2@/lib/ld-linux.so.2@g' $SPECFILE && 28 33 unset SPECFILE</userinput></screen> 29 34 … … 39 44 necessary.</para></important> 40 45 41 <para>Now create temporary wrapper scripts for <filename>gcc</filename> and42 <filename>ld</filename>. These scripts will point to their real counterparts 46 <para>Now create a temporary wrapper script for <filename>gcc</filename>. 47 This script will point to the real <filename>gcc</filename> 43 48 in <filename class="directory">/tools</filename> but with adjusted parameters 44 49 to ensure that GCC in the next section links to our newly installed Glibc.</para> … … 46 51 <screen><userinput>cat > /usr/bin/gcc << "EOF" 47 52 #!/bin/bash 48 /tools/bin/gcc -B/usr/lib $@53 /tools/bin/gcc -B/usr/lib/ -B/usr/bin/ $@ 49 54 EOF 50 cat > /usr/bin/ld << "EOF" 51 #!/bin/bash 52 /tools/bin/ld -nostdlib -L/usr/lib -L/lib $@ 53 EOF 54 chmod 755 /usr/bin/{ld,gcc} 55 chmod 755 /usr/bin/gcc 55 56 ln -s gcc /usr/bin/cc</userinput></screen> 56 57 … … 61 62 62 63 <screen><userinput>echo 'main(){}' > dummy.c 63 cc dummy.c 64 cc dummy.c -Wl,--verbose &> dummy.log 64 65 readelf -l a.out | grep ': /lib'</userinput></screen> 65 66 … … 73 74 the prefix of our dynamic linker.</para> 74 75 76 <para>Now make sure that we're setup to use the correct start files:</para> 77 78 <screen><userinput>grep "/usr/lib/crt.* " dummy.log</userinput></screen> 79 80 <para>If everything is working correctly, there should be no errors, 81 and the output of the last command will be:</para> 82 83 <screen><computeroutput>attempt to open /usr/lib/crt1.o succeeded 84 attempt to open /usr/lib/crti.o succeeded 85 attempt to open /usr/lib/crtn.o succeeded</computeroutput></screen> 86 87 <para>Next make sure that we're using the correct libc:</para> 88 89 <screen><userinput>grep "/lib/libc.so.6 " dummy.log</userinput></screen> 90 91 <para>If everything is working correctly, there should be no errors, 92 and the output of the last command will be:</para> 93 94 <screen><computeroutput>attempt to open /lib/libc.so.6 succeeded</computeroutput></screen> 95 96 <para>Lastly, make sure GCC is using the correct dynamic linker:</para> 97 98 <screen><userinput>grep found dummy.log</userinput></screen> 99 100 <para>If everything is working correctly, there should be no errors, 101 and the output of the last command will be (allowing for 102 platform-specific differences in dynamic linker name):</para> 103 104 <screen><computeroutput>found ld-linux.so.2 at /lib/ld-linux.so.2</computeroutput></screen> 105 75 106 <para>If the output does not appear as shown above or is not received 76 107 at all, then something is seriously wrong. Investigate and retrace the … … 83 114 files:</para> 84 115 85 <screen><userinput>rm -v dummy.c a.out </userinput></screen></caution>116 <screen><userinput>rm -v dummy.c a.out dummy.log</userinput></screen></caution> 86 117 87 118 </sect1>
Note:
See TracChangeset
for help on using the changeset viewer.