-
Notifications
You must be signed in to change notification settings - Fork 3.8k
[aot] move method_addresses to data.rel.so section to avoid text relocations #16729
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
This reverts commit b6ca76c.
…xt relocations
`.text` relocations aren't allowed in Android 10 (and it doesn't hurt on Linux).
AOT compilation:
```console
$ MONO_PATH=/Users/lewurm/Downloads/xamarin.android-oss-v10.0.99.136_Darwin-x86_64_pr_766265b9-Debug/bin/Debug/lib/xamarin.android/xbuild-frameworks/MonoAndroid/v1.0/ \
MONO_ENV_OPTIONS="" \
./sdks/out/android-cross-arm-release/bin/armv7-linux-android-mono-sgen \
--aot=keep-temps,outfile=here.dll.so,asmwriter,mtriple=armv7-linux-gnueabi,tool-prefix=/Users/lewurm/android-toolchain/ndk/toolchains/arm-linux-androideabi-4.9/prebuilt/darwin-x86_64/bin/arm-linux-androideabi-,ld-flags= \
~/Downloads/xamarin.android-oss-v10.0.99.136_Darwin-x86_64_pr_766265b9-Debug/bin/Debug/lib/xamarin.android/xbuild-frameworks/MonoAndroid/v10.0/Mono.Android.dll
Mono Ahead of Time compiler - compiling assembly /Users/lewurm/Downloads/xamarin.android-oss-v10.0.99.136_Darwin-x86_64_pr_766265b9-Debug/bin/Debug/lib/xamarin.android/xbuild-frameworks/MonoAndroid/v10.0/Mono.Android.dll
AOTID 7DDD05DA-37E0-813A-8C27-3E1634391BB3
Compiled: 144382/144382
Executing the native assembler: "/Users/lewurm/android-toolchain/ndk/toolchains/arm-linux-androideabi-4.9/prebuilt/darwin-x86_64/bin/arm-linux-androideabi-as" -mfpu=vfp3 -o /var/folders/p3/5279mmgn1p575bz28j0ngfqw0000gn/T/mono_aot_550yHJ.o /var/folders/p3/5279mmgn1p575bz28j0ngfqw0000gn/T/mono_aot_550yHJ
Executing the native linker: "/Users/lewurm/android-toolchain/ndk/toolchains/arm-linux-androideabi-4.9/prebuilt/darwin-x86_64/bin/arm-linux-androideabi-ld" -shared -o here.dll.so.tmp /var/folders/p3/5279mmgn1p575bz28j0ngfqw0000gn/T/mono_aot_550yHJ.o
Stripping the binary: "/Users/lewurm/android-toolchain/ndk/toolchains/arm-linux-androideabi-4.9/prebuilt/darwin-x86_64/bin/arm-linux-androideabi-strip" --strip-symbol=\$a --strip-symbol=\$d here.dll.so.tmp
Retained input file.
JIT time: 15031 ms, Generation time: 7374 ms, Assembly+Link time: 75130 ms.
```
Before:
```console
$ grep -C 6 'method_addresses:' /var/folders/p3/5279mmgn1p575bz28j0ngfqw0000gn/T/mono_aot_550yHJ
.align 3
jit_code_end:
.byte 0,0,0,0
.text 1
.align 3
method_addresses:
.local method_addresses
.type method_addresses,#function
ldr pc,=.Lm_0
.ltorg
ldr pc,=.Lm_1
.ltorg
$ arm-linux-androideabi-readelf -a here.dll.so | grep -i textrel
0x00000016 (TEXTREL) 0x0
0x0000001e (FLAGS) TEXTREL
```
After switching to `.data.rel.so`:
```console
$ grep -C 6 'method_addresses:' /var/folders/p3/5279mmgn1p575bz28j0ngfqw0000gn/T/mono_aot_1YhAgn # assembly file produced by AOT compiler
jit_code_end:
.byte 0,0,0,0
.section ".data.rel.ro"
.subsection 0
.align 3
method_addresses:
.local method_addresses
.type method_addresses,#object
ldr pc,=.Lm_0
.ltorg
ldr pc,=.Lm_1
.ltorg
$ arm-linux-androideabi-readelf -a here.dll.so | grep -i textrel
$ echo $?
1
```
|
@radekdoulik @grendello @jonpryor is there anyone in your team with an Android 10 device who could verify this change? |
|
On Windows you just say |
|
@monojenkins backport 2019-08 |
|
@monojenkins build failed |
| #define RODATA_REL_SECT ".data.rel.ro" | ||
| #else | ||
| #define RODATA_REL_SECT ".text" | ||
| #endif |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why limit this change only to Android or Linux? Wouldn't other target systems benefit from the lack of relocations in the code segment?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On macOS the assembler bails out with unknown directive on .data.rel.ro. Maybe there is something similar available but I didn't investigate. Likewise for Windows.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Limiting it to android limits the amount of regressions which can be caused by this change.
|
@monojenkins squash |
|
@monojenkins backport 2019-06 |
|
It also limits the improvements. |
|
Cannot squash because the following required status checks are not successful:
|
|
Cannot squash because the following required status checks are not successful:
|
|
@monojenkins build Linux AArch64 |
|
@monojenkins backport 2019-08 |
… text relocations (#16751) [2019-08] [aot] move method_addresses to data.rel.so section to avoid text relocations Another revert of a revert! 🎉 After some discussions with @grendello and @radekdoulik, we came up with this solution. It's a better attempt to fix #16369 as it (1) works within the restrictions of Android 10 and (2) still works for armv7 AOT. `.text` relocations aren't allowed in Android 10 (and this change shouldn't hurt on Linux). AOT compilation: ```console $ MONO_PATH=/Users/lewurm/Downloads/xamarin.android-oss-v10.0.99.136_Darwin-x86_64_pr_766265b9-Debug/bin/Debug/lib/xamarin.android/xbuild-frameworks/MonoAndroid/v1.0/ \ MONO_ENV_OPTIONS="" \ ./sdks/out/android-cross-arm-release/bin/armv7-linux-android-mono-sgen \ --aot=keep-temps,outfile=here.dll.so,asmwriter,mtriple=armv7-linux-gnueabi,tool-prefix=/Users/lewurm/android-toolchain/ndk/toolchains/arm-linux-androideabi-4.9/prebuilt/darwin-x86_64/bin/arm-linux-androideabi-,ld-flags= \ ~/Downloads/xamarin.android-oss-v10.0.99.136_Darwin-x86_64_pr_766265b9-Debug/bin/Debug/lib/xamarin.android/xbuild-frameworks/MonoAndroid/v10.0/Mono.Android.dll Mono Ahead of Time compiler - compiling assembly /Users/lewurm/Downloads/xamarin.android-oss-v10.0.99.136_Darwin-x86_64_pr_766265b9-Debug/bin/Debug/lib/xamarin.android/xbuild-frameworks/MonoAndroid/v10.0/Mono.Android.dll AOTID 7DDD05DA-37E0-813A-8C27-3E1634391BB3 Compiled: 144382/144382 Executing the native assembler: "/Users/lewurm/android-toolchain/ndk/toolchains/arm-linux-androideabi-4.9/prebuilt/darwin-x86_64/bin/arm-linux-androideabi-as" -mfpu=vfp3 -o /var/folders/p3/5279mmgn1p575bz28j0ngfqw0000gn/T/mono_aot_550yHJ.o /var/folders/p3/5279mmgn1p575bz28j0ngfqw0000gn/T/mono_aot_550yHJ Executing the native linker: "/Users/lewurm/android-toolchain/ndk/toolchains/arm-linux-androideabi-4.9/prebuilt/darwin-x86_64/bin/arm-linux-androideabi-ld" -shared -o here.dll.so.tmp /var/folders/p3/5279mmgn1p575bz28j0ngfqw0000gn/T/mono_aot_550yHJ.o Stripping the binary: "/Users/lewurm/android-toolchain/ndk/toolchains/arm-linux-androideabi-4.9/prebuilt/darwin-x86_64/bin/arm-linux-androideabi-strip" --strip-symbol=\$a --strip-symbol=\$d here.dll.so.tmp Retained input file. JIT time: 15031 ms, Generation time: 7374 ms, Assembly+Link time: 75130 ms. ``` Before: ```console $ grep -C 6 'method_addresses:' /var/folders/p3/5279mmgn1p575bz28j0ngfqw0000gn/T/mono_aot_550yHJ .align 3 jit_code_end: .byte 0,0,0,0 .text 1 .align 3 method_addresses: .local method_addresses .type method_addresses,#function ldr pc,=.Lm_0 .ltorg ldr pc,=.Lm_1 .ltorg $ arm-linux-androideabi-readelf -a here.dll.so | grep -i textrel 0x00000016 (TEXTREL) 0x0 0x0000001e (FLAGS) TEXTREL ``` After switching to `.data.rel.so`: ```console $ grep -C 6 'method_addresses:' /var/folders/p3/5279mmgn1p575bz28j0ngfqw0000gn/T/mono_aot_1YhAgn # assembly file produced by AOT compiler jit_code_end: .byte 0,0,0,0 .section ".data.rel.ro" .subsection 0 .align 3 method_addresses: .local method_addresses .type method_addresses,#object ldr pc,=.Lm_0 .ltorg ldr pc,=.Lm_1 .ltorg $ arm-linux-androideabi-readelf -a here.dll.so | grep -i textrel $ echo $? 1 ``` Backport of #16729. /cc @lewurm
…cations (mono/mono#16729) [aot] move method_addresses to data.rel.so section to avoid text relocations Another revert of a revert! 🎉 After some discussions with @grendello and @radekdoulik, we came up with this solution. It's a better attempt to fix mono/mono#16369 as it (1) works within the restrictions of Android 10 and (2) still works for armv7 AOT. `.text` relocations aren't allowed in Android 10 (and this change shouldn't hurt on Linux). AOT compilation: ```console $ MONO_PATH=/Users/lewurm/Downloads/xamarin.android-oss-v10.0.99.136_Darwin-x86_64_pr_766265b9-Debug/bin/Debug/lib/xamarin.android/xbuild-frameworks/MonoAndroid/v1.0/ \ MONO_ENV_OPTIONS="" \ ./sdks/out/android-cross-arm-release/bin/armv7-linux-android-mono-sgen \ --aot=keep-temps,outfile=here.dll.so,asmwriter,mtriple=armv7-linux-gnueabi,tool-prefix=/Users/lewurm/android-toolchain/ndk/toolchains/arm-linux-androideabi-4.9/prebuilt/darwin-x86_64/bin/arm-linux-androideabi-,ld-flags= \ ~/Downloads/xamarin.android-oss-v10.0.99.136_Darwin-x86_64_pr_766265b9-Debug/bin/Debug/lib/xamarin.android/xbuild-frameworks/MonoAndroid/v10.0/Mono.Android.dll Mono Ahead of Time compiler - compiling assembly /Users/lewurm/Downloads/xamarin.android-oss-v10.0.99.136_Darwin-x86_64_pr_766265b9-Debug/bin/Debug/lib/xamarin.android/xbuild-frameworks/MonoAndroid/v10.0/Mono.Android.dll AOTID 7DDD05DA-37E0-813A-8C27-3E1634391BB3 Compiled: 144382/144382 Executing the native assembler: "/Users/lewurm/android-toolchain/ndk/toolchains/arm-linux-androideabi-4.9/prebuilt/darwin-x86_64/bin/arm-linux-androideabi-as" -mfpu=vfp3 -o /var/folders/p3/5279mmgn1p575bz28j0ngfqw0000gn/T/mono_aot_550yHJ.o /var/folders/p3/5279mmgn1p575bz28j0ngfqw0000gn/T/mono_aot_550yHJ Executing the native linker: "/Users/lewurm/android-toolchain/ndk/toolchains/arm-linux-androideabi-4.9/prebuilt/darwin-x86_64/bin/arm-linux-androideabi-ld" -shared -o here.dll.so.tmp /var/folders/p3/5279mmgn1p575bz28j0ngfqw0000gn/T/mono_aot_550yHJ.o Stripping the binary: "/Users/lewurm/android-toolchain/ndk/toolchains/arm-linux-androideabi-4.9/prebuilt/darwin-x86_64/bin/arm-linux-androideabi-strip" --strip-symbol=\$a --strip-symbol=\$d here.dll.so.tmp Retained input file. JIT time: 15031 ms, Generation time: 7374 ms, Assembly+Link time: 75130 ms. ``` Before: ```console $ grep -C 6 'method_addresses:' /var/folders/p3/5279mmgn1p575bz28j0ngfqw0000gn/T/mono_aot_550yHJ .align 3 jit_code_end: .byte 0,0,0,0 .text 1 .align 3 method_addresses: .local method_addresses .type method_addresses,#function ldr pc,=.Lm_0 .ltorg ldr pc,=.Lm_1 .ltorg $ arm-linux-androideabi-readelf -a here.dll.so | grep -i textrel 0x00000016 (TEXTREL) 0x0 0x0000001e (FLAGS) TEXTREL ``` After switching to `.data.rel.so`: ```console $ grep -C 6 'method_addresses:' /var/folders/p3/5279mmgn1p575bz28j0ngfqw0000gn/T/mono_aot_1YhAgn # assembly file produced by AOT compiler jit_code_end: .byte 0,0,0,0 .section ".data.rel.ro" .subsection 0 .align 3 method_addresses: .local method_addresses .type method_addresses,#object ldr pc,=.Lm_0 .ltorg ldr pc,=.Lm_1 .ltorg $ arm-linux-androideabi-readelf -a here.dll.so | grep -i textrel $ echo $? 1 ``` Commit migrated from mono/mono@e40e24b
Another revert of a revert! 🎉
After some discussions with @grendello and @radekdoulik, we came up with this solution. It's a better attempt to fix #16369 as it (1) works within the restrictions of Android 10 and (2) still works for armv7 AOT.
.textrelocations aren't allowed in Android 10 (and this change shouldn't hurt on Linux).AOT compilation:
Before:
After switching to
.data.rel.so: