This is the mail archive of the binutils@sourceware.org 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]

Change global symbol to local in ELF?


Hi all,

There's probably an easy answer for this, but I'm not really sure what
to search for.

I have a partially linked object lib.o:

  ld -r -static file1.o file2.o ... -lc -o lib.o

It defines a global function symbol, foo, that conflicts with a
different function of the same name in another object, main.o

  gcc main.o lib.o -o program

  lib.o: In function `foo':
  example/file1.c:3: multiple definition of `foo'
  example/main.c:4: first defined here

Both lib.o and main.o should use their own respective versions of
foo(), so I don't think telling ld to ignore multiply defined symbols
will work, since my understanding is that this would cause the first
definition to be used everywhere.

foo in lib.o is not needed by any external objects.  Ideally it would
be local, not global.  So I guess I'm looking for a way to change a
symbol from global to local, either during the partial linking step or
before the final linking.  I've looked through the ld manual, and it
seems a linker script could do this using symbol versions, but only
with dynamically linking?  These are statically linked out of
necessity (the target system doesn't do dynamic linking)

Any suggestions greatly appreciated.

(assume for now I that I can't rename the symbols in the source code)


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