summaryrefslogtreecommitdiffstats
path: root/llvm/lib/MC/MCValue.cpp
diff options
context:
space:
mode:
authorRafael Espindola <rafael.espindola@gmail.com>2014-05-03 19:57:04 +0000
committerRafael Espindola <rafael.espindola@gmail.com>2014-05-03 19:57:04 +0000
commit3d082fa50704f55a3c6d25c9d6b25d652e7d84ae (patch)
treea3aff89a7742699070c17f25e005b1f04fdeb4a7 /llvm/lib/MC/MCValue.cpp
parent834652ade026fa990a110c8bc572f988d94a18a5 (diff)
downloadbcm5719-llvm-3d082fa50704f55a3c6d25c9d6b25d652e7d84ae.tar.gz
bcm5719-llvm-3d082fa50704f55a3c6d25c9d6b25d652e7d84ae.zip
Fix pr19645.
The fix itself is fairly simple: move getAccessVariant to MCValue so that we replace the old weak expression evaluation with the far more general EvaluateAsRelocatable. This then requires that EvaluateAsRelocatable stop when it finds a non trivial reference kind. And that in turn requires the ELF writer to look harder for weak references. Last but not least, this found a case where we were being bug by bug compatible with gas and accepting an invalid input. I reported pr19647 to track it. llvm-svn: 207920
Diffstat (limited to 'llvm/lib/MC/MCValue.cpp')
-rw-r--r--llvm/lib/MC/MCValue.cpp18
1 files changed, 18 insertions, 0 deletions
diff --git a/llvm/lib/MC/MCValue.cpp b/llvm/lib/MC/MCValue.cpp
index 21d9e2102e2..9dfc56ef23d 100644
--- a/llvm/lib/MC/MCValue.cpp
+++ b/llvm/lib/MC/MCValue.cpp
@@ -10,6 +10,7 @@
#include "llvm/MC/MCValue.h"
#include "llvm/MC/MCExpr.h"
#include "llvm/Support/Debug.h"
+#include "llvm/Support/ErrorHandling.h"
#include "llvm/Support/raw_ostream.h"
using namespace llvm;
@@ -41,3 +42,20 @@ void MCValue::dump() const {
print(dbgs(), nullptr);
}
#endif
+
+MCSymbolRefExpr::VariantKind MCValue::getAccessVariant() const {
+ const MCSymbolRefExpr *B = getSymB();
+ if (B) {
+ if (B->getKind() != MCSymbolRefExpr::VK_None)
+ llvm_unreachable("unsupported");
+ }
+
+ const MCSymbolRefExpr *A = getSymA();
+ if (!A)
+ return MCSymbolRefExpr::VK_None;
+
+ MCSymbolRefExpr::VariantKind Kind = A->getKind();
+ if (Kind == MCSymbolRefExpr::VK_WEAKREF)
+ return MCSymbolRefExpr::VK_None;
+ return Kind;
+}
OpenPOWER on IntegriCloud