PATCH: objcopy.c: redefine-sym-specific for archive files
Daniel Marques
marques@cs.cornell.edu
Mon Apr 25 23:31:00 GMT 2005
If an archive file (e.g. libc.a) consists of more than one object file
(e.g, a.o & b.o) each containing a definition for a symbol named 'foo',
objcopy --redefine-sym foo=bar libc.a will redefine both symbols.
Example 1:
[marques@c3linux objectdumps]$ nm libc.a
a.o:
00000000 b foo
b.o:
00000000 b foo
[marques@c3linux objectdumps]$ objcopy --redefine-sym foo=bar libc.a
[marques@c3linux objectdumps]$ nm libc.a
a.o:
00000000 b bar
b.o:
00000000 b bar
This might not always be the desired behavior. The attached patch adds
the --redefine-sym-specific option to object copy. Its usage is
--redefine-sym-specific <objectfile>:<old>=<new>
Redefine symbol name <old> to <new>, only for
specific <objectfile> component of input archive file
This flag allows the user to specify that the redefinition should only
affect the symbol in the specified 'component' (object file) of the archive.
Example 2:
[marques@c3linux objectdumps]$ nm libc.a
a.o:
00000000 b foo
b.o:
00000000 b foo
[marques@c3linux objectdumps]$ objcopy --redefine-sym-specific
a.o:foo=bar libc.a
[marques@c3linux objectdumps]$ nm libc.a
a.o:
00000000 b bar
b.o:
00000000 b foo
Notice that a specify redefine will always override a general override
for the same symbol name
Example 3:
[marques@c3linux objectdumps]$ nm libc.a
a.o:
00000000 b foo
b.o:
00000000 b foo
[marques@c3linux objectdumps]$ objcopy --redefine-sym foo=gnu
--redefine-sym-specific a.o:foo=bar libc.a
[marques@c3linux objectdumps]$ nm libc.a
a.o:
00000000 b bar
b.o:
00000000 b gnu
I did not include a version for reading these from a file, as that would
require either 'generalizing' add_redefine_syms_file() or 'cloning' that
function, and I though such a decision should be left to the maintainers.
Thanks.
Dan
P.S. Please cc me on reply, as I am not a subscriber to this list.
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: newest_patch
URL: <https://sourceware.org/pipermail/binutils/attachments/20050425/9a43d699/attachment.ksh>
More information about the Binutils
mailing list