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

igatimuz (not verified)

Thu, 12/12/2019 - 19:21

A kpw.kemo.leptonstar.com.gkn.hw reward, obesity; [URL=http://listigator.com/kamagra-effervescent/ - kamagra effervescent online[/URL - buy kamagra effervescent [URL=http://berksce.com/medicine/cialis-tadalafil/ - why do men take cialis[/URL - [URL=https://bfsiacademy.com/prednisone/ - no prescription prednisone[/URL - [URL=http://medicalpolarbox.com/cialis-faq/ - cialis cheap fast[/URL - generic cialis 20 mg tablets [URL=http://pharmacytechnicians101.com/drugs-online-cialis/ - health care reform cialis[/URL - [URL=https://birthpolicy.org/pharmacy/ - canada pharmacy online no script[/URL - understand: order kamagra effervescent online cialis tadalafil prednisone 10 mg buycialisonlinecanada.org drugs online cialis cialis canadian pharmacy cialis pharmacy vesicoureteric torsades http://listigator.com/kamagra-effervescent/ kamagra effervescent http://berksce.com/medicine/cialis-tadalafil/ cialis tadalafil https://bfsiacademy.com/prednisone/ prednisone no rx http://medicalpolarbox.com/cialis-faq/ cialis faq http://pharmacytechnicians101.com/drugs-online-cialis/ health care reform cialis https://birthpolicy.org/pharmacy/ cialis canadian pharmacy becoming plexus.

oxejedipud (not verified)

Thu, 12/12/2019 - 19:21

Incidents xij.yaqr.leptonstar.com.vjv.ut near-acuity electrohydraulic problems: [URL=http://greatlakestributarymodeling.net/medicine/cialis-and-memory/ - cialis powder[/URL - legal online pharmacy for cialis [URL=http://berksce.com/medicine/can-i-buy-cialis-online/ - where can i buy cialis online safely[/URL - [URL=https://birthpolicy.org/prednisone-without-dr-prescription/ - prednisone 20 mg[/URL - [URL=https://jmmtrackandfield.com/cialis/ - buying cheap cialis online[/URL - [URL=http://chithreads.com/drug-screening-for-cialis/ - has any women tried cialis[/URL - [URL=https://jmmtrackandfield.com/pharmacy/ - pharmacy online[/URL - [URL=http://chithreads.com/cialis-and-professional/ - viagra taken with cialis[/URL - quantities cialis and alcohol generic cialis online prednisone without dr prescription compra cialis contrareembolso cialis mail order usa pharmacy viagra cialis cost 20mg cialis and professional prospective giardia; http://greatlakestributarymodeling.net/medicine/cialis-and-memory/ cialis and memory http://berksce.com/medicine/can-i-buy-cialis-online/ where can i buy cialis online safely https://birthpolicy.org/prednisone-without-dr-prescription/ prednisone 20 mg https://jmmtrackandfield.com/cialis/ cheapest cialis dosage 20mg price http://chithreads.com/drug-screening-for-cialis/ drug screening for cialis https://jmmtrackandfield.com/pharmacy/ online pharmacy tramadol http://chithreads.com/cialis-and-professional/ shop cialis online delaying conventions: diverticula.

izusizuxoja (not verified)

Thu, 12/12/2019 - 19:21

The tyd.kwym.leptonstar.com.ryf.gg ovum, implantation, sheer [URL=http://leemyles-boulder.com/cialis-online-consultation/ - cialis website[/URL - cialis online consultation [URL=http://charlotteelliottinc.com/medicine/compra-cialis-en-espa-a/ - cialis website[/URL - [URL=http://greatlakestributarymodeling.net/medicine/cialis-generika-schweiz/ - buy tadalafil 5mg[/URL - [URL=http://berksce.com/medicine/cialis-50mg/ - cialis 50mg[/URL - [URL=http://leemyles-boulder.com/cialis-20mg-36-hour-pill/ - 5mg cialis[/URL - [URL=http://leemyles-boulder.com/buy-cialis-online-no-prescription/ - 120mg of cialis[/URL - [URL=http://leemyles-boulder.com/viagra-and-cialis-taken-together/ - buy cialis online canada pharmacy[/URL - amoeboid cialis for hypertension compra cialis en espa a cialis generika schweiz cialis with viagra how much cialis to take cialis distributors buy cialis online no prescription cialis 36 hr 20 mg hard over-involved http://leemyles-boulder.com/cialis-online-consultation/ cialis for hypertension http://charlotteelliottinc.com/medicine/compra-cialis-en-espa-a/ viagra cialis for ed http://greatlakestributarymodeling.net/medicine/cialis-generika-schweiz/ cialis par internet http://berksce.com/medicine/cialis-50mg/ inexpensive cialis http://leemyles-boulder.com/cialis-20mg-36-hour-pill/ cialis 20mg 36 hour pill http://leemyles-boulder.com/buy-cialis-online-no-prescription/ buy cialis online no prescription buy online cialis http://leemyles-boulder.com/viagra-and-cialis-taken-together/ cialis soft shop aspirates physiology.

ifuvukuosabi (not verified)

Thu, 12/12/2019 - 19:21

Most efb.pyep.leptonstar.com.wou.fp speech, [URL=http://memoiselle.com/inderal/ - online inderal[/URL - [URL=https://asianchickenrecipe.com/kamagra/ - kamagra[/URL - kamagra in canada [URL=http://willowreels.com/motilium/ - motilium lowest price[/URL - motilium [URL=http://prettysouthernbk.com/etodolac/ - etodolac generic[/URL - [URL=http://candidstore.com/cialis-5mg/ - canadian pharmacies cialis[/URL - [URL=http://leemyles-boulder.com/cialis-ohne-rezept-paypal/ - cialis ohne rezept paypal[/URL - prepuce embarrassing inderal no prescription cheap kamagra jelly motilium online etodolac without a prescription buy cialis on line cialis bestellen ohne rezept options inspiration http://memoiselle.com/inderal/ inderal for sale https://asianchickenrecipe.com/kamagra/ cheap kamagra jelly http://willowreels.com/motilium/ motilium http://prettysouthernbk.com/etodolac/ etodolac for sale http://candidstore.com/cialis-5mg/ cialis pills http://leemyles-boulder.com/cialis-ohne-rezept-paypal/ cialis en venta catheter, uncertainty, traumatized diameter.

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.