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

ucweroux (not verified)

Sun, 05/16/2021 - 04:55

Can ivq.oovr.leptonstar.com.ecx.my redislocates beer eyedrops [URL=http://gaiaenergysystems.com/lasix/ - potassium furosemide[/URL - [URL=http://cgodirek.com/item/priligy/ - get priligy in canada[/URL - [URL=http://stephacking.com/levitra/ - levitra[/URL - [URL=http://memoiselle.com/prednisolone/ - no prescription prednisolone[/URL - [URL=http://pronavid.com/buy-online-prednisone/ - prednisone internet[/URL - [URL=http://kelipaan.com/item/priligy/ - generic priligy shipped with in canada[/URL - [URL=http://umichicago.com/prazosin/ - prazosin[/URL - [URL=http://a1sewcraft.com/amoxicillin-500-mg/ - amoxicillin buy[/URL - amoxicillin online [URL=http://thegrizzlygrowler.com/viagra-super-active/ - viagra super active no prescription[/URL - [URL=http://nwdieselandauto.com/drugs/amoxil/ - amoxil online pharmacy cheapest[/URL - [URL=http://comwallpapers.com/overnight-levitra-canada/ - overnight levitra canada[/URL - [URL=http://kelipaan.com/item/amoxicillin/ - amoxicillin australia[/URL - [URL=http://stroupflooringamerica.com/item/isotretinoin/ - buy isotretinoin without perscription[/URL - [URL=http://pukaschoolinc.com/product/viagra/ - viagra with no perscriptiom[/URL - [URL=http://mrcpromotions.com/nolvadex/ - nolvadex tablet generic[/URL - ovaries purchase lasix online priligy in south africa priligy levitra 20mg best price deltasone prednisolone 40mg buy online prednisone cheap 60mg priligy cheapest prazosin amoxicillin 500 mg viagra super active 100 mg amoxil dozirovka mg deutsch levitra 20 mg on line free amoxicillin with perscription order generic amoxicillin online buy isotretinoin without perscription viagra with no perscriptiom nolvadex loosened http://gaiaenergysystems.com/lasix/ lasix to buy online no prescription http://cgodirek.com/item/priligy/ dosage for priligy http://stephacking.com/levitra/ generic levitra http://memoiselle.com/prednisolone/ prednisolone without a prescription http://pronavid.com/buy-online-prednisone/ prednisone where to buy http://kelipaan.com/item/priligy/ 60 generic priligy pills http://umichicago.com/prazosin/ prazosin without a prescription http://a1sewcraft.com/amoxicillin-500-mg/ amoxicillin mg http://thegrizzlygrowler.com/viagra-super-active/ viagra super active no prescription http://nwdieselandauto.com/drugs/amoxil/ amoxil http://comwallpapers.com/overnight-levitra-canada/ new levitra http://kelipaan.com/item/amoxicillin/ no prescription needed amoxicillin http://stroupflooringamerica.com/item/isotretinoin/ non generic isotretinoin http://pukaschoolinc.com/product/viagra/ viagra with no perscriptiom http://mrcpromotions.com/nolvadex/ canadian legal nolvadex boyfriend surgeons biochemistry.

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.