summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorDaniel Dunbar <daniel@zuster.org>2009-08-22 07:22:36 +0000
committerDaniel Dunbar <daniel@zuster.org>2009-08-22 07:22:36 +0000
commit8906ff1b9dfde28f1ff00706643ca10843b26e01 (patch)
tree9cd4a02e407a6ac0751c459bb5327f1f6f3cc07e /lib
parent66aa9b1c2ff5ba278dd35d720e0ed38bccca3a8e (diff)
downloadllvm-8906ff1b9dfde28f1ff00706643ca10843b26e01.tar.gz
llvm-8906ff1b9dfde28f1ff00706643ca10843b26e01.tar.bz2
llvm-8906ff1b9dfde28f1ff00706643ca10843b26e01.tar.xz
llvm-mc: Clean up some handling of symbol/section association to be more correct
(external was really undefined and there wasn't an explicit representation for absolute symbols). - This still needs some cleanup to how the absolute "pseudo" section is dealt with, but I haven't figured out the nicest approach yet. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@79733 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r--lib/MC/MCAsmStreamer.cpp11
-rw-r--r--lib/MC/MCMachOStreamer.cpp11
-rw-r--r--lib/MC/MCSymbol.cpp4
3 files changed, 14 insertions, 12 deletions
diff --git a/lib/MC/MCAsmStreamer.cpp b/lib/MC/MCAsmStreamer.cpp
index 3dfd8e9474..655137d580 100644
--- a/lib/MC/MCAsmStreamer.cpp
+++ b/lib/MC/MCAsmStreamer.cpp
@@ -107,14 +107,11 @@ void MCAsmStreamer::SwitchSection(const MCSection *Section) {
}
void MCAsmStreamer::EmitLabel(MCSymbol *Symbol) {
- assert(Symbol->getSection() == 0 && "Cannot emit a symbol twice!");
+ assert(Symbol->isUndefined() && "Cannot define a symbol twice!");
assert(CurSection && "Cannot emit before setting section!");
- assert(!getContext().GetSymbolValue(Symbol) &&
- "Cannot emit symbol which was directly assigned to!");
OS << Symbol << ":\n";
- Symbol->setSection(CurSection);
- Symbol->setExternal(false);
+ Symbol->setSection(*CurSection);
}
void MCAsmStreamer::EmitAssemblerFlag(AssemblerFlag Flag) {
@@ -127,7 +124,9 @@ void MCAsmStreamer::EmitAssemblerFlag(AssemblerFlag Flag) {
void MCAsmStreamer::EmitAssignment(MCSymbol *Symbol, const MCValue &Value,
bool MakeAbsolute) {
- assert(!Symbol->getSection() && "Cannot assign to a label!");
+ // Only absolute symbols can be redefined.
+ assert((Symbol->isUndefined() || Symbol->isAbsolute()) &&
+ "Cannot define a symbol twice!");
if (MakeAbsolute) {
OS << ".set " << Symbol << ", " << Value << '\n';
diff --git a/lib/MC/MCMachOStreamer.cpp b/lib/MC/MCMachOStreamer.cpp
index 316051ce01..421faef6aa 100644
--- a/lib/MC/MCMachOStreamer.cpp
+++ b/lib/MC/MCMachOStreamer.cpp
@@ -91,15 +91,12 @@ void MCMachOStreamer::SwitchSection(const MCSection *Section) {
}
void MCMachOStreamer::EmitLabel(MCSymbol *Symbol) {
- assert(Symbol->getSection() == 0 && "Cannot emit a symbol twice!");
+ assert(Symbol->isUndefined() && "Cannot define a symbol twice!");
assert(CurSection && "Cannot emit before setting section!");
- assert(!getContext().GetSymbolValue(Symbol) &&
- "Cannot emit symbol which was directly assigned to!");
llvm_unreachable("FIXME: Not yet implemented!");
- Symbol->setSection(CurSection);
- Symbol->setExternal(false);
+ Symbol->setSection(*CurSection);
}
void MCMachOStreamer::EmitAssemblerFlag(AssemblerFlag Flag) {
@@ -109,7 +106,9 @@ void MCMachOStreamer::EmitAssemblerFlag(AssemblerFlag Flag) {
void MCMachOStreamer::EmitAssignment(MCSymbol *Symbol,
const MCValue &Value,
bool MakeAbsolute) {
- assert(!Symbol->getSection() && "Cannot assign to a label!");
+ // Only absolute symbols can be redefined.
+ assert((Symbol->isUndefined() || Symbol->isAbsolute()) &&
+ "Cannot define a symbol twice!");
llvm_unreachable("FIXME: Not yet implemented!");
}
diff --git a/lib/MC/MCSymbol.cpp b/lib/MC/MCSymbol.cpp
index d032017ca4..3c9894b691 100644
--- a/lib/MC/MCSymbol.cpp
+++ b/lib/MC/MCSymbol.cpp
@@ -12,6 +12,10 @@
using namespace llvm;
+// Sentinel value for the absolute pseudo section.
+const MCSection *MCSymbol::AbsolutePseudoSection =
+ reinterpret_cast<const MCSection *>(1);
+
/// NeedsQuoting - Return true if the string \arg Str needs quoting, i.e., it
/// does not match [a-zA-Z_.][a-zA-Z0-9_.]*.
//