?????????????
????????????????????????????????????????????????未?????????
????gcc main.c -L./ -lelfhash
????./a.out
????//??锌???谐???
????//????????????
????./a.out: error while loading shared libraries: libelfhash.so: cannot open shared object file: No such file or directory
?????????????????????谐????????????? ???????些?????????????-L???????Linux???????????械??SunOS????校????????????????????????效?? ???????????-l???????-lelfhash?????readelf -d a.out??????????????????????????????
????0x0000000000000001 (NEEDED)  Shared library: [libelfhash.so]
????????????????娌�??邪?????????路???????????????????????????man ld-linux.so?????????????浠�(?械???校??姹�????)
????If a slash is found?? then the dependency string is interpreted as a (relative or absolute) pathname?? and the library is loaded using that pathname
??????位?????????????????????????????????????/????????????????????????路??????????????????????????
????gcc main.c ./libelfhash.so
????./a.out
????23621492 //???????
????????readelf -d a.out???????????????????????路????
????0x0000000000000001 (NEEDED)  Shared library: [./libelfhash.so]
????????????????????????????????械?路????????????????睢� ?????????????尾??????????????????????????????????????械?????????????????????????????
????(??ELF???) ????????????DT_RPATH?????????????????DT_RUNPATH??????????????DT_RPATH???????Linux???????RPATH??RUNPATH????
??????????????LD_LIBRARY_PATH?????????????????set-user-id/set-group-id?? ???????
????(??ELF???) ????????????DT_RUNPATH?????????????
??????/etc/ld.so.cache????????胁???
?????????路??/lib?? /usr/lib??????胁???
???????????????RPATH????RUNPATH????????????
????gcc main.c -Wl??-rpath??/home/xxx??--enable-new-dtags -L./  -lelfhash
?????????-Wl????????????ld?????未???????????????-rpath(???????-R)????ld??????路?????(???-Wl????????????????锌??)????????--enable-new-dtags??????????RPATH???????RPATH??RUNPATH?????????谩????readelf -d a.out?????:
????0x000000000000000f (RPATH)  Library rpath: [/home/xxx]
????0x000000000000001d (RUNPATH)  Library runpath: [/home/xxx]
?????????????????LD_LIBRARY_PATH?????????????? export
????export LD_LIBRARY_PATH=/home/xxx;$LD_LIBRARY_PATH
????RPATH??RUNPATH?????????路????????????????????????????LDLIBRARYPATH??????????????????????????????????校???????????????????????????????????????????????????????????????????? ???蟹???????????????????
??????????????????ldconfig???屑????????????/etc/ld.so.conf.d/???鈥�??????????????????????路??写???????????????????/lib??/lib64(64位)??/usr/lib??/usr/lib64(64位)???????sudo ldconfig???/etc/ld.so.cache?????
?????????姹�
???????????????????????????????????邪姹�???????????????????/usr/lib64???????????????????????????卤????????渭???姹�?????
????gcc -fPIC -shared -Wall -Wl??-soname??libelfhash.so.0  -o libelfhash.so.0.0.0 elfhash.c
?????????????????????????????libelfhash.so.0.0.0????real name????????????????????libxxx.so.MAJOR.MINOR.VERSION(?械????VERSION?????)?????????????????????????????????????????????????MAJOR????????????????????????????bug??????MINOR??VERSION?????????MAJOR???????????????????????????????貌????????????????卤??????谐???
???????????????????ld???????????-soname??????????soname?? ???????libelfhash.so.0 ?????MAJOR??????谐??????屑???????????????????????????
????????????????????link name?????????谐????????????????ld??????????????????邪姹�????.so??尾????????? ??????????soname??????????
??????????????????????????????ldconfig????????libelfhash.so.0.0.0???/usr/lib64??????校???????????
????$sudo ldconfig -v | grep libelfhash.so
????libelfhash.so.0 -> libelfhash.so.0.0.0
???????????ldconfig????libelfhash.so.0.0.0????????????????soname???real name??????????????????(MINOR??VERSION????)??????????????位????????sudo ldconfig?????????????????渭???????????????????
???????
????OK??????Linux?????????????????????些?????????些???????????婕�???????????些?????????????谩?????????????????????????ld??ld-linux.so??????????????????????????????????????????????????