aboutsummaryrefslogtreecommitdiff
path: root/lld
diff options
context:
space:
mode:
authorFangrui Song <i@maskray.me>2023-06-20 20:50:06 -0700
committerFangrui Song <i@maskray.me>2023-06-20 20:50:06 -0700
commit8653db9503774c0f70a5ae3858ceaf180815fe3b (patch)
treeb7b446c21338c0e6f6322e077904f4b86bad0071 /lld
parentd5bebb3fb402c4ba7e5838d267fa840eee8ecdce (diff)
downloadllvm-8653db9503774c0f70a5ae3858ceaf180815fe3b.zip
llvm-8653db9503774c0f70a5ae3858ceaf180815fe3b.tar.gz
llvm-8653db9503774c0f70a5ae3858ceaf180815fe3b.tar.bz2
[lld-macho][test] Make reloc-subtractor.s robust
The test requires that LLVM integreated assembler generates SUBTRACTOR/UNSIGNED relocations for `.long _minuend_1 - _subtrahend_1`. This currently works by luck because: * `_minuend_1` and `_subtrahend_1` are in different fragments (separated by a MCFillFragment) * and the result is known to be negative at parsing time. D153096 will change the assembler to fold `.long _minuend_1 - _subtrahend_1` to a constant, giving ld -order_file no chance to change the result. To fix the test, move the referenced labels after the label differences to block constant folding. Note: you may think the model is somewhat broken and it is. The .subsections_via_symbols mechanism does not block such constant folding. In reality SUBTRACTOR/UNSIGNED is for references to another section, which does not have the problem. Reviewed By: #lld-macho, smeenai Differential Revision: https://reviews.llvm.org/D153382
Diffstat (limited to 'lld')
-rw-r--r--lld/test/MachO/reloc-subtractor.s19
1 files changed, 10 insertions, 9 deletions
diff --git a/lld/test/MachO/reloc-subtractor.s b/lld/test/MachO/reloc-subtractor.s
index 550f27d..2470273 100644
--- a/lld/test/MachO/reloc-subtractor.s
+++ b/lld/test/MachO/reloc-subtractor.s
@@ -33,15 +33,6 @@ L_.minuend:
.space 16
.section __DATA,bar
-_minuend_1:
- .space 16
-_minuend_2:
- .space 16
-_subtrahend_1:
- .space 16
-_subtrahend_2:
- .space 16
-
_sub1:
.long _minuend_1 - _subtrahend_1
.space 12
@@ -58,6 +49,16 @@ _sub5:
.quad L_.minuend - _subtrahend_1 + 1
.space 8
+.section __DATA,bar
+_minuend_1:
+ .space 16
+_minuend_2:
+ .space 16
+_subtrahend_1:
+ .space 16
+_subtrahend_2:
+ .space 16
+
.text
.p2align 2
_main: