diff options
author | Daniel Dunbar <daniel@zuster.org> | 2009-08-14 19:10:46 +0000 |
---|---|---|
committer | Daniel Dunbar <daniel@zuster.org> | 2009-08-14 19:10:46 +0000 |
commit | b2d0b6b8c70dadd4c7628d814c5caf7088defad3 (patch) | |
tree | 1ec5c2d0e22e5287fc1233275bb406d0c6a7045d | |
parent | 9b9014f2a088356e4ba814d7f0fd422af721f32d (diff) | |
download | llvm-b2d0b6b8c70dadd4c7628d814c5caf7088defad3.tar.gz llvm-b2d0b6b8c70dadd4c7628d814c5caf7088defad3.tar.bz2 llvm-b2d0b6b8c70dadd4c7628d814c5caf7088defad3.tar.xz |
llvm-mc: When handling a .set, make sure to print subsequent references to the
symbol as the symbol name itself, not the expression it was defined to. These
have different semantics due to the quirky .set behavior (which absolutizes an
expression that would otherwise be treated as a relocation).
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@79025 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | lib/MC/MCAsmStreamer.cpp | 11 | ||||
-rw-r--r-- | test/MC/AsmParser/labels.s | 10 |
2 files changed, 17 insertions, 4 deletions
diff --git a/lib/MC/MCAsmStreamer.cpp b/lib/MC/MCAsmStreamer.cpp index 43ce04ffdf..41f88334e2 100644 --- a/lib/MC/MCAsmStreamer.cpp +++ b/lib/MC/MCAsmStreamer.cpp @@ -136,11 +136,18 @@ void MCAsmStreamer::EmitAssignment(MCSymbol *Symbol, const MCValue &Value, if (MakeAbsolute) { OS << ".set " << Symbol << ", " << Value << '\n'; + + // HACK: If the value isn't already absolute, set the symbol value to + // itself, we want to use the .set absolute value, not the actual + // expression. + if (!Value.isAbsolute()) + getContext().SetSymbolValue(Symbol, MCValue::get(Symbol)); + else + getContext().SetSymbolValue(Symbol, Value); } else { OS << Symbol << " = " << Value << '\n'; + getContext().SetSymbolValue(Symbol, Value); } - - getContext().SetSymbolValue(Symbol, Value); } void MCAsmStreamer::EmitSymbolAttribute(MCSymbol *Symbol, diff --git a/test/MC/AsmParser/labels.s b/test/MC/AsmParser/labels.s index c9cb44eaf0..f306685256 100644 --- a/test/MC/AsmParser/labels.s +++ b/test/MC/AsmParser/labels.s @@ -23,9 +23,9 @@ foo: // CHECK: addl $10, %eax addl "b$c", %eax - // CHECK: set "a 0", 11 -.set "a 0", 11 + .set "a 0", 11 + // CHECK: .long 11 .long "a 0" @@ -49,3 +49,9 @@ foo: // CHECK: .lsym "a 8",1 .lsym "a 8", 1 + +// CHECK: set "a 9", a - b + .set "a 9", a - b + +// CHECK: .long "a 9" + .long "a 9" |