riscv64 nterp: Fix "oat" code size calculation.
Test: Manual - build libart.so and look at disassembly.
Bug: 283082047
Change-Id: Ic13232b47e161af37b6f2e36f220c21e09d641c9
diff --git a/runtime/interpreter/mterp/riscv64/main.S b/runtime/interpreter/mterp/riscv64/main.S
index 15033bf..c20c291 100644
--- a/runtime/interpreter/mterp/riscv64/main.S
+++ b/runtime/interpreter/mterp/riscv64/main.S
@@ -70,7 +70,11 @@
// Padding of 3 * 4 bytes to get 16 bytes alignment of code entry.
.4byte 0, 0, 0
// OatQuickMethodHeader `data_` field. Note that the top two bits must be clear.
- .4byte (\end - \name)
+ // The calculation must be based on the current address to emit relocation data,
+ // otherwise the size calculated by the assembler could be wrong after linking.
+ // (Alternatively, we could use `.option norelax` to suppress linker optimizations.)
+1:
+ .4byte (\end - /* \name */ (1b + 4))
\name:
.endm