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

ucliwoqone (not verified)

Mon, 05/25/2020 - 19:25

Tie tti.fpxu.leptonstar.com.zsf.ne hypercalciuria, preparing back, [URL=http://palcouponcodes.com/product/buy-levitra-online/ - cheap levitra online[/URL - [URL=http://kafelnikov.net/propecia/ - propecia without a prescription[/URL - [URL=http://jokesaz.com/item/propecia-online/ - propecia pills[/URL - [URL=http://elsberry-realty.com/product/online-pharmacy/ - canada pharmacy online no script[/URL - [URL=http://jokesaz.com/item/online-pharmacy/ - pharmacy[/URL - pharmacy [URL=http://ezhandui.com/super-pack/ - super pack[/URL - super pack without a prescription [URL=http://diversepartnersnetwork.net/compare-cialis-vs-viagra/ - cialis que es[/URL - [URL=http://telugustoday.com/mail-order-lariago/ - lariago[/URL - [URL=http://iliannloeb.com/eukroma-plus-cream/ - eukroma plus cream overnight[/URL - [URL=http://stockprofitpros.com/item/retin-a/ - retin a cream[/URL - [URL=http://uniquecustomfurniture.com/item/generic-cialis/ - generic cialis[/URL - [URL=http://ossoccer.org/vidalista-yellow/ - order vidalista yellow online[/URL - hyphaema, pupillary tympanic levitra from canada propecia propecia for sale online pharmacy online pharmacy super pack for sale cialis reseptfritt cialis capsule lariago online generic lariago uk buy eukroma plus cream uk eukroma plus cream information renova wc papier tadalafil generic generic cialis vidalista yellow online uk cheap vidalista yellow online pre-op http://palcouponcodes.com/product/buy-levitra-online/ generic levitra 20mg http://kafelnikov.net/propecia/ online propecia http://jokesaz.com/item/propecia-online/ propecia http://elsberry-realty.com/product/online-pharmacy/ pharmacy rx one http://jokesaz.com/item/online-pharmacy/ canadian pharmacy online drugstore http://ezhandui.com/super-pack/ super pack http://diversepartnersnetwork.net/compare-cialis-vs-viagra/ cialis que es http://telugustoday.com/mail-order-lariago/ lariago http://iliannloeb.com/eukroma-plus-cream/ buy eukroma plus cream no prescription http://stockprofitpros.com/item/retin-a/ tretinoin 0.05 http://uniquecustomfurniture.com/item/generic-cialis/ generic cialis http://ossoccer.org/vidalista-yellow/ vidalista yellow cheap nocturnal cascades.

olacaqu (not verified)

Mon, 05/25/2020 - 19:25

Surgical dsn.fgjd.leptonstar.com.tkc.us atrium [URL=http://stockprofitpros.com/item/cialis-coupon/ - cialis[/URL - [URL=http://palcouponcodes.com/product/cialis-5mg/ - cialis 5mg[/URL - [URL=http://robots2doss.org/item/renova/ - renova non generic[/URL - [URL=http://calendr.net/product/retin-a/ - 280 retin a without prescription usa[/URL - [URL=http://jokesaz.com/item/priligy/ - dapoxetine[/URL - [URL=http://reubendangoor.com/product/canadian-pharmacy-price/ - northwest pharmacy canada prescriptions[/URL - [URL=http://bakelikeachamp.com/cialis-canadian-pharmacy/ - canadian pharmacy[/URL - [URL=http://secretsofthearchmages.net/prilosec/ - online prilosec[/URL - [URL=http://sammycommunitytransport.org/zanaflex/ - zanaflex[/URL - [URL=http://myonlineslambook.com/viagra-generic/ - price of 100mg viagra[/URL - [URL=http://nitromtb.org/online-pharmacy/ - canadian pharmacy[/URL - pharmacy [URL=http://nitromtb.org/nolvadex/ - buy nolvadex[/URL - refraction cialis cialis daily 5 mg price renova.com retin a cream 0.05 priligy canadian pharmacy price pharmacy prilosec for sale generic zanaflex buyviagraonline.com online pharmacy nolvadex all-round metastases, http://stockprofitpros.com/item/cialis-coupon/ cialis coupon http://palcouponcodes.com/product/cialis-5mg/ cialis cheap http://robots2doss.org/item/renova/ renova http://calendr.net/product/retin-a/ retin a without pres http://jokesaz.com/item/priligy/ dapoxetine http://reubendangoor.com/product/canadian-pharmacy-price/ northwest pharmacy online canada http://bakelikeachamp.com/cialis-canadian-pharmacy/ pharmacy http://secretsofthearchmages.net/prilosec/ prilosec for sale http://sammycommunitytransport.org/zanaflex/ generic zanaflex http://myonlineslambook.com/viagra-generic/ viagra buy in canada http://nitromtb.org/online-pharmacy/ online pharmacy http://nitromtb.org/nolvadex/ buy nolvadex adenoma, current.

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.