[PATCH] Revise Windows PECOFF weak symbols

Aaron W. LaFramboise aaron98wiridge9@aaronwl.com
Tue Oct 19 11:02:00 GMT 2004


My initial PECOFF weak symbol implementation, submitted here
<http://sources.redhat.com/ml/binutils/2004-07/msg00036.html>, had the
problem that it was unlike weak symbols on other platforms and other
features in gas.  In the non-alias case, it was also not compliant with
regards to the specification, as PECOFF does not natively support
non-alias weak symbols.  I had based it off a description of the Intel
assembler's .weak from their manual.  However, I now do not think this
is the right way to go here.  There were also a few bugs in weak symbol
relocation handling.

With this patch, weak symbols on PE behave as on other platforms, with
the same syntax, in full compliance with the specification.  This is
accomplished by creating an alternate symbol that is given the value of
the weak symbol, if the weak symbol would not refer to another symbol.
These weak symbols have semantics a lot better than Intel's, and make it
much easier for compilers and users alike.

Handling of the alternate symbols forms the majority of this patch.  The
first complication is that they should not be emitted when not needed.
(Despite this, there is still one case where this happens.  If a weak
symbol is equated to a symbol which is defined within the same file, an
alternate symbol will be created with the same value.  This is not
harmful, and seems particularly difficult to fix.)

The second complication is that since alternate names are external, they
must be unique to a file.  Uniqueness is accomplished by creating the
symbol name from the name of the weak symbol and the name of an
arbitrary external symbol.  (Randomness should not be used because it
wouldn't be guaranteed to work, and would cause nondeterminism.)

Besides the modifications to gas, there are small two modifications to
bfd that fix handling of weak symbols on PE.  There are also some minor
documentation updates.

The ld testcase is also altered to let some of the weak symbol test
cases (that previously only ran on ELF) run for PE.

I have a copyright assignment, but no CVS access.

Aaron W. LaFramboise

-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: binutils-head-20041019-weak.patch
URL: <https://sourceware.org/pipermail/binutils/attachments/20041019/b5dbd81e/attachment.ksh>


More information about the Binutils mailing list