增加ld链接器的搜索路径

查看搜索路径

 ld --verbose | grep SEARCH

SEARCH_DIR("/tools/i686-pc-linux-gnu/lib"); SEARCH_DIR("/tools/lib");

 

1 修改binutils-build/ld Makefile。

#LIB_PATH = /tools/lib

LIB_PATH = /tools/i686-pc-linux-gnu/lib:/tools/lib:/usr/lib:/lib

2 重新编译,生成可执行文件ld-new。查看新的SEARCH_DIR,符合要求。

/media/lfs/sources/binutils-build/ld# ./ld-new -verbose | grep SEARCH

SEARCH_DIR("/tools/i686-pc-linux-gnu/lib"); SEARCH_DIR("/tools/lib"); SEARCH_DIR("/usr/lib"); SEARCH_DIR("/lib"); 

3 查找所有的ld文件。

root:/# find . -name 'ld' -print

/tools/i686-pc-linux-gnu/bin/ld    //a symbol link

/tools/bin/ld

4 替换

mv ld ld-bkp

cp /sources/binutils-build/ld/ld-new ld

以下两步可能不必要

rm /tools/i686-pc-linux-gnu/bin/ld

ln -sv /tools/bin/ld /tools/i686-pc-linux-gnu/bin/ld   目录一定要写完整

5 重新测试

root:/sources/glibc-build# cc dummy.c -v -Wl,--verbose &> dummy.log
root:/sources/glibc-build# grep 'SEARCH.*/usr/lib' dummy.log |sed 's|; |"n|g'
SEARCH_DIR("/tools/i686-pc-linux-gnu/lib")
SEARCH_DIR("/tools/lib")
SEARCH_DIR("/usr/lib")
SEARCH_DIR("/lib");


 


 




 


 

 

posted @ 2008-12-16 22:06  雨纷飞  阅读(1431)  评论(0)    收藏  举报