Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Xamarin.Android.Build.Tasks] Don't skip symbol-less AOT libs (#6630)
Fixes: #6615 Context: db161ae Commit db161ae added a way to analyze and skip native shared libraries produced by the Mono AOT compiler and skip packaging for those which contain no executable code (a common case for Profiled AOT builds). However, it turns out that by adding the following property to the project configuration: <AndroidAotAdditionalArguments>no-write-symbols,nodebug</AndroidAotAdditionalArguments> can make the `ELFHelper` treat the shared library in question as empty, even though it does contain executable, AOT-d, code. The reason for this is the way Mono generates code when the above options are used. It will output a blob of executable code without any labels (which are turned to symbols when compiling and linking) and then add just a single non-function symbol whose name ends with the `_plt` suffix. This symbol is essentially a jump table, a collection of tiny snippets of code which jump into the executable code blob mentioned above. Since the `*_plt` symbol is **not** a function (that is, its symbol type is not `FUNC`), it was skipped by ELFHelper: 27: 0000000000078620 22480 NOTYPE LOCAL DEFAULT 6 mono_aot_Mono_Android_plt Furthermore, since shared libraries built with the above options do not contain any `FUNC` symbols, they were consequently rejected as empty and not packaged, leading to Issue #6615. Fix the problem by looking for non-empty symbols in executable sections of the shared library with symbol names ending in `_plt`.
- Loading branch information