Compute A-B when A or B is weak.
authorRafael Espindola <rafael.espindola@gmail.com>
Fri, 17 Apr 2015 21:15:17 +0000 (21:15 +0000)
committerRafael Espindola <rafael.espindola@gmail.com>
Fri, 17 Apr 2015 21:15:17 +0000 (21:15 +0000)
commitfb118bd226d62e6854a628a8b3274c6058496438
treed29e6717dc4ced833652ddecfc2f6e1f8d529739
parentb24498671a832be625d7e1c507ad80beb18009ac
Compute A-B when A or B is weak.

Similar to r235222, but for the weak symbol case.

In an "ideal" assembler/object format an expression would always refer to the
final value and A-B would only be computed from a section in the same
comdat as A and B with A and B strong.

Unfortunately that is not the case with debug info on ELF, so we need an
heuristic.  Since we need an heuristic, we may as well use the same one as
gas:

* call weak_sym : produces a relocation, even if in the same section.
* A - weak_sym and weak_sym -A: don't produce a relocation if we can
  compute it.

This fixes pr23272 and changes the fix of pr22815 to match what gas does.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@235227 91177308-0d34-0410-b5e6-96231b3b80d8
include/llvm/MC/MCMachObjectWriter.h
include/llvm/MC/MCObjectWriter.h
lib/MC/ELFObjectWriter.cpp
lib/MC/MCAssembler.cpp
lib/MC/MCObjectWriter.cpp
lib/MC/MachObjectWriter.cpp
lib/MC/WinCOFFObjectWriter.cpp
test/MC/ELF/weak-diff.s
test/MC/ELF/weak-diff2.s [deleted file]