This is the mail archive of the binutils@sources.redhat.com mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: How can I change a global symbol to local?


On Wed, Nov 27, 2002 at 05:57:39PM +0800, ShiYi Ma wrote:
> Hi all :
>             Is there any method to change a global symbol to local in an
> static library?
>             My platform is RedHat7.2. Using gcc 3.2 and ld 2.11.90.0.8.
>             Now I should link 2 static libraries to one binary and all
> process should not use shared library. In the 2
> libraries there are few symbols shareing the same name. So ld will show
> warning "multiple definition". It looks
>  like very hard to strip one given name symbol from one static library.
> Also strip symbol will affect the binary's
> debug. So my goal is just changing one symbol from global to local. Is
> there any possibility of implementing it
> without any platform or tools update?
>            Thanks all very much. Any feedback is welcome.
> 

You can do one of those:

1. Use objcopy

  -L --localize-symbol <name>      Force symbol <name> to be marked as a local
     --localize-symbols <file>     -L for all symbols listed in <file>

2. If your ld is newer enough, you can use

  -z muldefs            Allow multiple definitions

In thise case, the first definition will be used.


H.J.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]