aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/MC/MCSymbolELF.cpp
diff options
context:
space:
mode:
authorRafael Espindola <rafael.espindola@gmail.com>2015-06-03 21:41:59 +0000
committerRafael Espindola <rafael.espindola@gmail.com>2015-06-03 21:41:59 +0000
commit8c52a9b0f611e4daa09c00e0da15b44b9528dbe5 (patch)
tree16ff48c06dd0096cf227efddbb8ca1c2f2c3f167 /llvm/lib/MC/MCSymbolELF.cpp
parentada43f6337e430a38f007778a5ebb7e022bb9c2d (diff)
downloadllvm-8c52a9b0f611e4daa09c00e0da15b44b9528dbe5.zip
llvm-8c52a9b0f611e4daa09c00e0da15b44b9528dbe5.tar.gz
llvm-8c52a9b0f611e4daa09c00e0da15b44b9528dbe5.tar.bz2
Store whether a symbol is a comdat signature in MCSymbolELF.
With this getBinging can now return the correct answer for all cases not involving a .symver and the elf writer doesn't need to patch it last minute. llvm-svn: 238980
Diffstat (limited to 'llvm/lib/MC/MCSymbolELF.cpp')
-rw-r--r--llvm/lib/MC/MCSymbolELF.cpp21
1 files changed, 17 insertions, 4 deletions
diff --git a/llvm/lib/MC/MCSymbolELF.cpp b/llvm/lib/MC/MCSymbolELF.cpp
index f8a90b9..4e6def0 100644
--- a/llvm/lib/MC/MCSymbolELF.cpp
+++ b/llvm/lib/MC/MCSymbolELF.cpp
@@ -24,10 +24,20 @@ void MCSymbolELF::setBinding(unsigned Binding) const {
}
unsigned MCSymbolELF::getBinding() const {
- uint32_t Binding = (getFlags() & (0xf << ELF_STB_Shift)) >> ELF_STB_Shift;
- assert(Binding == ELF::STB_LOCAL || Binding == ELF::STB_GLOBAL ||
- Binding == ELF::STB_WEAK || Binding == ELF::STB_GNU_UNIQUE);
- return Binding;
+ if (isBindingSet()) {
+ uint32_t Binding = (getFlags() & (0xf << ELF_STB_Shift)) >> ELF_STB_Shift;
+ assert(Binding == ELF::STB_LOCAL || Binding == ELF::STB_GLOBAL ||
+ Binding == ELF::STB_WEAK || Binding == ELF::STB_GNU_UNIQUE);
+ return Binding;
+ }
+
+ if (isDefined())
+ return ELF::STB_LOCAL;
+ if (isUsedInReloc())
+ return ELF::STB_GLOBAL;
+ if (isSignature())
+ return ELF::STB_LOCAL;
+ return ELF::STB_GLOBAL;
}
void MCSymbolELF::setType(unsigned Type) const {
@@ -86,4 +96,7 @@ bool MCSymbolELF::isUsedInReloc() const {
return UsedInReloc;
}
+void MCSymbolELF::setIsSignature() const { IsSignature = true; }
+
+bool MCSymbolELF::isSignature() const { return IsSignature; }
}