summaryrefslogtreecommitdiff
path: root/runtime/class_linker.cc
diff options
context:
space:
mode:
Diffstat (limited to 'runtime/class_linker.cc')
-rw-r--r--runtime/class_linker.cc11
1 files changed, 11 insertions, 0 deletions
diff --git a/runtime/class_linker.cc b/runtime/class_linker.cc
index 4712c936c8..77ce39cf86 100644
--- a/runtime/class_linker.cc
+++ b/runtime/class_linker.cc
@@ -1760,6 +1760,17 @@ bool ClassLinker::AddImageSpace(
header.VisitPackedArtMethods(&visitor, space->Begin(), image_pointer_size_);
}
+ if (!app_image) {
+ // Make the string intern table and class table immutable for boot image.
+ // PIC app oat files may mmap a read-only copy into their own .bss section,
+ // so enforce that the data in the boot image tables remains unchanged.
+ //
+ // We cannot do that for app image even after the fixup as some interned
+ // String references may actually end up pointing to moveable Strings.
+ uint8_t* const_section_begin = space->Begin() + header.GetBootImageConstantTablesOffset();
+ mprotect(const_section_begin, header.GetBootImageConstantTablesSize(), PROT_READ);
+ }
+
ClassTable* class_table = nullptr;
{
WriterMutexLock mu(self, *Locks::classlinker_classes_lock_);