[PATCH] D109109: [MC] Recursively calculate symbol offset
Nico Weber via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Oct 20 11:38:00 PDT 2021
This revision was automatically updated to reflect the committed changes.
Closed by commit rG5d57578a4e48: [MC] Recursively calculate symbol offset (authored by lgrey, committed by thakis).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D109109/new/
https://reviews.llvm.org/D109109
Files:
llvm/lib/MC/MCFragment.cpp
llvm/test/MC/MachO/chained-alias-offset.s
Index: llvm/test/MC/MachO/chained-alias-offset.s
===================================================================
--- /dev/null
+++ llvm/test/MC/MachO/chained-alias-offset.s
@@ -0,0 +1,12 @@
+// RUN: llvm-mc -triple x86_64-apple-macos %s -filetype=obj | llvm-readobj --symbols - | FileCheck %s
+l_a:
+l_b = l_a + 1
+l_c = l_b
+ .long l_c
+
+// CHECK: Name: l_a
+// CHECK: Value: 0x0
+// CHECK: Name: l_b
+// CHECK: Value: 0x1
+// CHECK: Name: l_c
+// CHECK: Value: 0x1
Index: llvm/lib/MC/MCFragment.cpp
===================================================================
--- llvm/lib/MC/MCFragment.cpp
+++ llvm/lib/MC/MCFragment.cpp
@@ -128,7 +128,11 @@
const MCSymbolRefExpr *A = Target.getSymA();
if (A) {
uint64_t ValA;
- if (!getLabelOffset(Layout, A->getSymbol(), ReportError, ValA))
+ // FIXME: On most platforms, `Target`'s component symbols are labels from
+ // having been simplified during evaluation, but on Mach-O they can be
+ // variables due to PR19203. This, and the line below for `B` can be
+ // restored to call `getLabelOffset` when PR19203 is fixed.
+ if (!getSymbolOffsetImpl(Layout, A->getSymbol(), ReportError, ValA))
return false;
Offset += ValA;
}
@@ -136,7 +140,7 @@
const MCSymbolRefExpr *B = Target.getSymB();
if (B) {
uint64_t ValB;
- if (!getLabelOffset(Layout, B->getSymbol(), ReportError, ValB))
+ if (!getSymbolOffsetImpl(Layout, B->getSymbol(), ReportError, ValB))
return false;
Offset -= ValB;
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D109109.381042.patch
Type: text/x-patch
Size: 1518 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20211020/69cc1539/attachment.bin>
More information about the llvm-commits
mailing list