07-22-04 11:01 PM
"Chris Slominski" <cjs@jlab.org> writes:
> "Måns Rullgård" <mru@kth.se> writes:
>
> I have no control over the locally defined library, so removing
> that definition of the symbol is not an option. I understand
> that the linkrer searches the libraries in the order that they
> appear on the command line, but since the default system
> library is not explicitly mentioned, I can't control the
> order. Should/can I explicitly list the default library? What
> is its name? Is it /usr/lib/libC.a ?
>
> Chris
It would be helpful to let us know the name of the function, and
the flavor of Unix you're on, and whether you're doing this in C
or C++. I'm assuming C because it's very hard for C++ names to
clash at the object file level, but you write libC.a, which is a
C++ library. The C library is brought in with -lc (note lower
case).
It's too bad you have no control over the naming of the local
function, because that indeed is the best solution.
You can try explicity putting -lc in front of your local library,
and that may work depending on whether you're linking statically
or dynamically. Depending how you invoke your compiler, you can
see the complete link line (with all system libraries). With
gcc, for example, add the -v option to the link invocation.
Lastly, if you can get your hands on GNU binutils, you can use
the objcopy command to rename the clashing function in your local
library, thusly:
objcopy --redefine-sym origsym=newsym origlib newlib
To do this right, you'll need to know the exact name of the
original symbol in origlib, (which you can find out using nm).
Depending on the flavor of Unix, there may be a leading
underscore (or other decorations) in front of the original symbol
name. When you rename origsym, you should keep all those
decorations in your newsym,
e.g. --redefine-sym __malloc=__mymalloc
After the renaming, just make sure to use newsym in your source
code and link against newlib instead of origlib.
-jc
--
(apply 'concat (reverse (list "com"
(char-to-string 46) "yahoo"
(char-to-string 64) "joechung")))
[ Post a follow-up to this message ]
|