From 088a2ca0ed7f0d96eefab54fe0904d04a49072c4 Mon Sep 17 00:00:00 2001 From: James Benton Date: Wed, 2 Oct 2019 20:44:39 +0100 Subject: [PATCH] Force .rodata section to be read only. --- src/main/java/cafeloader/Cafe_ElfExtension.java | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/main/java/cafeloader/Cafe_ElfExtension.java b/src/main/java/cafeloader/Cafe_ElfExtension.java index 175cab5..2893342 100644 --- a/src/main/java/cafeloader/Cafe_ElfExtension.java +++ b/src/main/java/cafeloader/Cafe_ElfExtension.java @@ -104,6 +104,18 @@ public class Cafe_ElfExtension extends ElfExtension { return address; } + @Override + public Boolean isSectionWritable(ElfSectionHeader section) { + // For some reason .rpl files have .rodata marked with W flag, + // forcing it to read only will help improve decompiler output. + String name = section.getNameAsString(); + if (name != null && name.contentEquals(".rodata")) { + return false; + } + + return (section.getFlags() & ElfSectionHeaderConstants.SHF_WRITE) != 0; + } + @Override public void processElf(ElfLoadHelper elfLoadHelper, TaskMonitor monitor) throws CancelledException {