?????????????
????????????????????????????????????????????????δ?????????
????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??????????????????????????????????????????????????