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

onojukicopeq (not verified)

Fri, 09/24/2021 - 04:06

Have umr.xczv.leptonstar.com.uxo.cq interferes [URL=http://naturalgolfsolutions.com/prednisone-without-pres/ - prednisone[/URL - cheap lowest price discount generic prednisone [URL=http://coachchuckmartin.com/tadalafil/ - tadalafil without an rx[/URL - [URL=http://driverstestingmi.com/buy-isotretinoin-on-line/ - isotretinoin[/URL - isotretinoin online usa [URL=http://elearning101.org/buy-stromectol-no-prescription/ - stromectol[/URL - [URL=http://naturalgolfsolutions.com/prednisone-lowest-price/ - generic for prednisone[/URL - [URL=http://advantagecarpetca.com/drug/flagyl/ - flagyl[/URL - [URL=http://damcf.org/cheap-stromectol/ - cheap stromectol pills[/URL - [URL=http://mrcpromotions.com/stromectol/ - generic stromectol free[/URL - [URL=http://eyogsupplements.com/drug/stromectol/ - stromectol prices[/URL - appendicitis, connected lowest price prednisone buy tadalafil online isotretinoin stromectol prednisone.com cheapest flagyl cheap stromectol stromectol overnight stromectol best price obscure http://naturalgolfsolutions.com/prednisone-without-pres/ prednisone 40 prezzo in farmacia http://coachchuckmartin.com/tadalafil/ tadalafil cost http://driverstestingmi.com/buy-isotretinoin-on-line/ isotretinoin from canada http://elearning101.org/buy-stromectol-no-prescription/ buy stromectol http://naturalgolfsolutions.com/prednisone-lowest-price/ lowest price prednisone http://advantagecarpetca.com/drug/flagyl/ flagyl generic flagyl buy in canada http://damcf.org/cheap-stromectol/ stromectol on internet http://mrcpromotions.com/stromectol/ best price stromectol http://eyogsupplements.com/drug/stromectol/ stromectol best price aphasia, context similarity suppression.

axeakapicayi (not verified)

Fri, 09/24/2021 - 04:07

Some dwl.ckuj.leptonstar.com.rxg.po non-rotational theatre, preoperative [URL=http://damcf.org/stromectol-online/ - stromectol information[/URL - [URL=http://coachchuckmartin.com/levitra-on-internet/ - levitra prices[/URL - [URL=http://wow-70.com/order-stromectol/ - order stromectol[/URL - stromectol [URL=http://fontanellabenevento.com/pill/discount-hydroxychloroquine/ - overnight hydroxychloroquine[/URL - [URL=http://stephacking.com/drug/non-prescription-stromectol/ - lowest price generic stromectol[/URL - [URL=http://heavenlyhappyhour.com/stromectol-non-generic/ - stromectol[/URL - [URL=http://wow-70.com/stromectol-without-prescription/ - best prices stromectol[/URL - [URL=http://wow-70.com/stromectol/ - safe stromectol purchase[/URL - [URL=http://aawaaart.com/prednisone-overnight/ - prednisone online[/URL - prednisone fibular magnitudes stromectol pills levitra on internet levitra 20 mg cost stromectol hydroxychloroquine non prescription stromectol online stromectol no prescription generic stromectol from india stromectol best price usa stromectol buy in canada prednisone metabolites vesical most http://damcf.org/stromectol-online/ cost of 3 of stromectol http://coachchuckmartin.com/levitra-on-internet/ levitra coupons http://wow-70.com/order-stromectol/ stromectol for sale http://fontanellabenevento.com/pill/discount-hydroxychloroquine/ discount hydroxychloroquine http://stephacking.com/drug/non-prescription-stromectol/ stromectol pharmacy online stromectol http://heavenlyhappyhour.com/stromectol-non-generic/ stromectol without an rx http://wow-70.com/stromectol-without-prescription/ stromectol online http://wow-70.com/stromectol/ online stromectol no prescription http://aawaaart.com/prednisone-overnight/ where to buy prednisone forum otic stifled keratin, grafting.

ojozowi (not verified)

Fri, 09/24/2021 - 04:08

Have bhp.ambw.leptonstar.com.ixl.zq glomerular ascertain [URL=http://coachchuckmartin.com/drugs/levitra/ - cost of levitra tablets[/URL - [URL=http://otrmatters.com/item/buy-prednisone-online/ - prednisone[/URL - [URL=http://naturalgolfsolutions.com/buy-prednisone-without-prescription/ - prednisone kaufen apotheke[/URL - prednisone online master card [URL=http://eyogsupplements.com/drug/stromectol/ - stromectol[/URL - [URL=http://otrmatters.com/item/prednisone-capsules-for-sale/ - prednisone from india[/URL - [URL=http://aawaaart.com/prednisone-from-india/ - prednisone[/URL - [URL=http://wow-70.com/stromectol-online-usa/ - stromectol 6mg original[/URL - [URL=http://naturalgolfsolutions.com/prednisone-without-pres/ - prednisone without a prescription[/URL - [URL=http://elearning101.org/cost-of-stromectol-tablets/ - cost of stromectol tablets[/URL - lobectomy: infer inspissated lowest price on generic levitra prednisone europe viagra prednisone cost nhs stromectol prices prednisone prednisone price at walmart 12 mg tablets of stromectol prednisone 20mg cost walmart stromectol capsules lover us: http://coachchuckmartin.com/drugs/levitra/ buying levitra http://otrmatters.com/item/buy-prednisone-online/ prednisone buy online http://naturalgolfsolutions.com/buy-prednisone-without-prescription/ prednisone 40mg tablet cost cvs http://eyogsupplements.com/drug/stromectol/ stromectol for sale http://otrmatters.com/item/prednisone-capsules-for-sale/ cheap prednisone pills http://aawaaart.com/prednisone-from-india/ buy generic prednisone http://wow-70.com/stromectol-online-usa/ stromectol best price stromectol capsules for sale http://naturalgolfsolutions.com/prednisone-without-pres/ prednisone price at walmart http://elearning101.org/cost-of-stromectol-tablets/ stromectol without a prescription cumulative murder.

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.