This patch aims to solve the issue of loading libraries having an .eh_frame with relocations in android mips/mips64 platforms. The problem has been originally seen in the vanilla aosp mips64 emulator, when emitting objects with the section .eh_frame, then the mclinker shipped within the AOSP issues the warning `creating a DT_TEXTREL in a shared object'' when creating a shared library out of the object file, while the dynamic linker fails to load the created library issuing the error: `dlopen failed: text relocations (DT_TEXTREL) found in 64-bit ELF file''. The warning by the linker is issued for both mips32 & mips64, but for mips32 the library is however successfully loaded by the emulator.
Noting that the same problem does not show up when utilising the gnu linker, a bug has been reported to the mclinker community [1]. It turned out that a conceptually similar patch has been merged for the LLVM fork part of the Android NDK [2] and this problem does not occur when using the NDK toolchain, but only with the LLVM libraries inside Android. It has also been pointed out that the GNU linker is able to transform the absolute addresses in the .eh_frame in relative ones, while this functionality is not currently provided by the mclinker [3].
As a way to address the issue, this patch marks the section .eh_frame as writeable in ELF objects for mips/mips64, so that required relocations can be applied by the dynamic linker at runtime. This resembles the behaviour in the patch in the Android NDK, except that in the NDK is the section for the exception handlers the one marked, while in this case the problem is with .eh_frame. I do not know the rationale for this difference.
References:
[1] Bug report for the MClinker: https://groups.google.com/forum/#!topic/mclinker/9eJJGDjIwy4
[2] Andrew Hsieh patch for the NDK: https://android.googlesource.com/toolchain/llvm/+/48604b20a5daaa114c9cad67f1811c321ec0d947%5E!/
[3] Conversion of absolute FDE relocations into relative ones, MClinker mailing list - https://groups.google.com/forum/#!topic/mclinker/mpqg4lFjlfE