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

eibefel (not verified)

Mon, 12/06/2021 - 15:26

Hard lsa.oejq.leptonstar.com.dkl.ze polycythaemia [URL=http://mrcpromotions.com/drug/ventolin/ - buy ventolin uk[/URL - [URL=http://anguillacayseniorliving.com/pill/prednisone-information/ - prednisone without dr prescription usa[/URL - [URL=http://washingtonsharedparenting.com/nizagara/ - 50 mg nizagara canadian[/URL - [URL=http://columbiainnastoria.com/drug/hydroxychloroquine/ - hydroxychloroquine prices at walmart[/URL - [URL=http://damcf.org/item/buy-prednisone-online-canada/ - buy prednisone online canada[/URL - [URL=http://buckeyejeeps.com/finasteride/ - canada finasteride[/URL - finasteride post [URL=http://webodtechnologies.com/item/furosemide/ - furosemide[/URL - [URL=http://columbiainnastoria.com/hydroxychloroquine-uk/ - hydroxychloroquine uk[/URL - [URL=http://mynarch.net/zetia/ - generic zetia from canada[/URL - [URL=http://thegrizzlygrowler.com/hydrochlorothiazide/ - hydrochlorothiazide generico in italia[/URL - [URL=http://wow-70.com/item/hydroxychloroquine/ - hydroxychloroquine[/URL - [URL=http://scoverage.org/priligy-without-a-doctors-prescription/ - canadian 90 priligy[/URL - [URL=http://davincipictures.com/nolvadex/ - nolvadex[/URL - interfere decussating predicament, buy ventolin uk prednisone.com 50 mg nizagara canadian sale of hydroxychloroquine buying prednisone online cheap generic finasteride online india furosemide online to buy hydroxychloroquine uk zetia without an rx generic zetia from canada hydrochlorothiazide generico in italia hydrochlorothiazide hydroxychloroquine miami priligy 30 30 generique buy nolvadex online faced complication http://mrcpromotions.com/drug/ventolin/ ventolin prescription online http://anguillacayseniorliving.com/pill/prednisone-information/ prednisone.com http://washingtonsharedparenting.com/nizagara/ order nizagara online http://columbiainnastoria.com/drug/hydroxychloroquine/ hydroxychloroquine ou en acheter http://damcf.org/item/buy-prednisone-online-canada/ canadian prednisone http://buckeyejeeps.com/finasteride/ irish finasteride http://webodtechnologies.com/item/furosemide/ furosemide http://columbiainnastoria.com/hydroxychloroquine-uk/ hydroxychloroquine uk http://mynarch.net/zetia/ zetia tablets http://thegrizzlygrowler.com/hydrochlorothiazide/ hydrochlorothiazide http://wow-70.com/item/hydroxychloroquine/ prices hydroxychloroquine http://scoverage.org/priligy-without-a-doctors-prescription/ priligy apotheken http://davincipictures.com/nolvadex/ nolvadex for men oocysts 107.

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.