summaryrefslogtreecommitdiffstats
path: root/llvm/lib/MC/MCContext.cpp
diff options
context:
space:
mode:
authorEvgeniy Stepanov <eugeni.stepanov@gmail.com>2017-02-24 21:44:58 +0000
committerEvgeniy Stepanov <eugeni.stepanov@gmail.com>2017-02-24 21:44:58 +0000
commit00400d36c9219079223ea9734ffd40abeea0cad0 (patch)
treedae86c1f07ca12cf1d443bc58a5dc39e4f5d010c /llvm/lib/MC/MCContext.cpp
parent0338ce83cd94d74e1d7b0e68e54cc4ceba6dcb1b (diff)
downloadbcm5719-llvm-00400d36c9219079223ea9734ffd40abeea0cad0.tar.gz
bcm5719-llvm-00400d36c9219079223ea9734ffd40abeea0cad0.zip
Disallow redefinition of section symbols.
Differential Revision: https://reviews.llvm.org/D30235 llvm-svn: 296180
Diffstat (limited to 'llvm/lib/MC/MCContext.cpp')
-rw-r--r--llvm/lib/MC/MCContext.cpp6
1 files changed, 5 insertions, 1 deletions
diff --git a/llvm/lib/MC/MCContext.cpp b/llvm/lib/MC/MCContext.cpp
index cc7533f87b7..9d5bd39b56f 100644
--- a/llvm/lib/MC/MCContext.cpp
+++ b/llvm/lib/MC/MCContext.cpp
@@ -320,6 +320,11 @@ MCSectionELF *MCContext::createELFSectionImpl(StringRef Section, unsigned Type,
const MCSectionELF *Associated) {
MCSymbolELF *R;
MCSymbol *&Sym = Symbols[Section];
+ // A section symbol can not redefine regular symbols. There may be multiple
+ // sections with the same name, in which case the first such section wins.
+ if (Sym && Sym->isDefined() &&
+ (!Sym->isInSection() || Sym->getSection().getBeginSymbol() != Sym))
+ reportError(SMLoc(), "invalid symbol redefinition");
if (Sym && Sym->isUndefined()) {
R = cast<MCSymbolELF>(Sym);
} else {
@@ -330,7 +335,6 @@ MCSectionELF *MCContext::createELFSectionImpl(StringRef Section, unsigned Type,
}
R->setBinding(ELF::STB_LOCAL);
R->setType(ELF::STT_SECTION);
- R->setRedefinable(true);
auto *Ret = new (ELFAllocator.Allocate()) MCSectionELF(
Section, Type, Flags, K, EntrySize, Group, UniqueID, R, Associated);
OpenPOWER on IntegriCloud