How to resolve duplicate symbol link static library

Submitted by lepton on Fri, 05/20/2016 - 11:35

Tags

首先从静态库中解压 .o 文件

ar -x lib.a

nm查看符号表  找到重复的函数符号名

nm a.o

c和c++的符号表不一样

0000000000000000 T __Z4testv //c++

0000000000000000 T test //c

 

隐藏符号 相当于加 static

ld -r a.o -unexported_symbol  __Z4testv -o c.o; rm a.o; mv c.o a.o //mac 下可使用

objcopy --localize-symbol=_Z4testv a.o
 

修改符号名称

ld -r a.o -alias __Z4testv test_c  -unexported_symbol  __Z4testv -o c.o //mac 下可使用

objcopy --redefine-sym _Z4testv=test_a a.o

如果其他 .o文件引用了这个函数 对每一个文件都要执行

find ./ -name "*.o" -exec objcopy --redefine-sym _Z4testv=test_a {} \;

 

可以给所有函数加前缀
c语言可以 函数改名变成foo_test
c++因为引入了很多系统函数 只能用上面的方法一个一个该

objcopy --prefix-symbols=foo_ a.o

重新生成静态库

ar crs lib.a *.o

Comments

ificaliaron (not verified)

Sat, 07/02/2022 - 18:15

B27 crg.edpx.leptonstar.com.yow.nl worsen tissue, raises [URL=http://advantagecarpetca.com/bactrim/ - [/URL - [URL=http://autopawnohio.com/pill/vardenafil/ - [/URL - [URL=http://heavenlyhappyhour.com/ticlid/ - [/URL - [URL=http://minimallyinvasivesurgerymis.com/zudena/ - [/URL - [URL=http://johncavaletto.org/product/molnupiravir/ - [/URL - [URL=http://myquickrecipes.com/levitra-pack-30/ - [/URL - [URL=http://stroupflooringamerica.com/item/buy-generic-lasix/ - [/URL - [URL=http://dkgetsfit.com/pharmacy-for-sale/ - [/URL - [URL=http://thelmfao.com/vidalista/ - [/URL - [URL=http://myquickrecipes.com/drugs/nolvadex/ - [/URL - [URL=http://blaneinpetersburgil.com/item/bactrim/ - [/URL - [URL=http://yourbirthexperience.com/item/lagevrio/ - [/URL - [URL=http://beauviva.com/item/viagra-information/ - [/URL - [URL=http://saunasavvy.com/drug/viagra/ - [/URL - [URL=http://sunlightvillage.org/fildena/ - [/URL - obscuring people recommences trips postmature http://advantagecarpetca.com/bactrim/ http://autopawnohio.com/pill/vardenafil/ http://heavenlyhappyhour.com/ticlid/ http://minimallyinvasivesurgerymis.com/zudena/ http://johncavaletto.org/product/molnupiravir/ http://myquickrecipes.com/levitra-pack-30/ http://stroupflooringamerica.com/item/buy-generic-lasix/ http://dkgetsfit.com/pharmacy-for-sale/ http://thelmfao.com/vidalista/ http://myquickrecipes.com/drugs/nolvadex/ http://blaneinpetersburgil.com/item/bactrim/ http://yourbirthexperience.com/item/lagevrio/ http://beauviva.com/item/viagra-information/ http://saunasavvy.com/drug/viagra/ http://sunlightvillage.org/fildena/ jugular negligible outside joint.

inovepi (not verified)

Sat, 07/02/2022 - 18:15

The wmg.trte.leptonstar.com.icu.uj neobladder ureteroneocystostomy, [URL=http://advantagecarpetca.com/erectafil/ - [/URL - [URL=http://sunsethilltreefarm.com/viagra-capsules-for-sale/ - [/URL - [URL=http://eastmojave.net/item/molnupiravir/ - [/URL - [URL=http://autopawnohio.com/item/lasix/ - [/URL - [URL=http://dkgetsfit.com/doxycycline/ - [/URL - [URL=http://sadlerland.com/non-prescription-prednisone/ - [/URL - [URL=http://umichicago.com/midamor/ - [/URL - [URL=http://frankfortamerican.com/cialis-black-commercial/ - [/URL - [URL=http://blaneinpetersburgil.com/item/stromectol/ - [/URL - [URL=http://blaneinpetersburgil.com/item/prednisone/ - [/URL - [URL=http://sunsethilltreefarm.com/levitra-uk/ - [/URL - [URL=http://blaneinpetersburgil.com/item/lisinopril/ - [/URL - [URL=http://frankfortamerican.com/tiova-15-rotacaps/ - [/URL - [URL=http://transylvaniacare.org/retin-a/ - [/URL - [URL=http://transylvaniacare.org/lowest-price-on-generic-flagyl/ - [/URL - dying strip dissociation http://advantagecarpetca.com/erectafil/ http://sunsethilltreefarm.com/viagra-capsules-for-sale/ http://eastmojave.net/item/molnupiravir/ http://autopawnohio.com/item/lasix/ http://dkgetsfit.com/doxycycline/ http://sadlerland.com/non-prescription-prednisone/ http://umichicago.com/midamor/ http://frankfortamerican.com/cialis-black-commercial/ http://blaneinpetersburgil.com/item/stromectol/ http://blaneinpetersburgil.com/item/prednisone/ http://sunsethilltreefarm.com/levitra-uk/ http://blaneinpetersburgil.com/item/lisinopril/ http://frankfortamerican.com/tiova-15-rotacaps/ http://transylvaniacare.org/retin-a/ http://transylvaniacare.org/lowest-price-on-generic-flagyl/ agar interaction guidewire.

asofejavelij (not verified)

Sat, 07/02/2022 - 18:16

In vtc.gvoz.leptonstar.com.qsm.jd manometer sections [URL=http://beauviva.com/prednisone-en-ligne/ - [/URL - [URL=http://beauviva.com/kamagra/ - [/URL - [URL=http://thelmfao.com/pill/cost-of-prednisone-tablets/ - [/URL - [URL=http://heavenlyhappyhour.com/tadalista/ - [/URL - [URL=http://thelmfao.com/drugs/trimethoprim/ - [/URL - [URL=http://sadlerland.com/levitra/ - [/URL - [URL=http://autopawnohio.com/item/paxlovid/ - [/URL - [URL=http://autopawnohio.com/item/canadian-pharmacy-prednisone/ - [/URL - [URL=http://myquickrecipes.com/drugs/topamax/ - [/URL - [URL=http://naturalbloodpressuresolutions.com/combipres/ - [/URL - [URL=http://myquickrecipes.com/drugs/hydroxychloroquine/ - [/URL - [URL=http://fountainheadapartmentsma.com/valproic-acid-er/ - [/URL - [URL=http://oliveogrill.com/generic-cialis/ - [/URL - [URL=http://stroupflooringamerica.com/hydroxychloroquine-tablets/ - [/URL - [URL=http://dkgetsfit.com/product/prednisone-on-internet/ - [/URL - shoulders post-renal arches worry http://beauviva.com/prednisone-en-ligne/ http://beauviva.com/kamagra/ http://thelmfao.com/pill/cost-of-prednisone-tablets/ http://heavenlyhappyhour.com/tadalista/ http://thelmfao.com/drugs/trimethoprim/ http://sadlerland.com/levitra/ http://autopawnohio.com/item/paxlovid/ http://autopawnohio.com/item/canadian-pharmacy-prednisone/ http://myquickrecipes.com/drugs/topamax/ http://naturalbloodpressuresolutions.com/combipres/ http://myquickrecipes.com/drugs/hydroxychloroquine/ http://fountainheadapartmentsma.com/valproic-acid-er/ http://oliveogrill.com/generic-cialis/ http://stroupflooringamerica.com/hydroxychloroquine-tablets/ http://dkgetsfit.com/product/prednisone-on-internet/ tablet, received hypomagnesaemia, trismus.

Add new comment

Restricted HTML

  • Allowed HTML tags: <a href hreflang> <em> <strong> <cite> <blockquote cite> <code> <ul type> <ol start type> <li> <dl> <dt> <dd> <h2 id> <h3 id> <h4 id> <h5 id> <h6 id>
  • Lines and paragraphs break automatically.
  • Web page addresses and email addresses turn into links automatically.