mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2024-11-24 13:19:49 +00:00
Merge branch 'GP-3543_ghidra1_ElfAndroidRelocFix' into patch
This commit is contained in:
commit
476d98bd9f
@ -53,6 +53,7 @@
|
||||
<li><I>GUI</I>. Fixed issue with menu bar colors on Mac system when using <span class="gtitle">Mac Aqua Look and Feel</span> while in dark mode. (GP-3528, Issue #4454)</li>
|
||||
<li><I>Importer</I>. Fixed an exception that occurred when the <span class="gcode">MzLoader</span> tried to split the <span class="gcode">HEADER</span> overlay block. (GP-3447, Issue #5320)</li>
|
||||
<li><I>Importer:ELF</I>. Corrected potential exception when processing invalid <span class="gcode">ELF PT_NOTE</span> program header. (GP-3493, Issue #5384)</li>
|
||||
<li><I>Importer:ELF</I>. Corrected bugs in ELF Android packed relocation processing and rendering of <span class="gcode">sleb128</span> data type. (GP-3543)</li>
|
||||
<li><I>Importer:Mach-O</I>. Fixed a regression in the Mach-O Loader that was causing incorrect <span class="gcode">DYLD_CHAINED_PTR_X86_64_KERNEL_CACHE</span> fixups. (GP-3474)</li>
|
||||
<li><I>Importer:Mach-O</I>. Fixed an <span class="gcode">AddressOutOfBoundsException</span> that could sometimes occur when importing the exports section of <span class="gcode">dyld_shared_cache</span> files. (GP-3505, Issue #5392)</li>
|
||||
<li><I>Importer:PE</I>. Fixed an <span class="gcode">IllegalStateException</span> that could occur if both <span class="gtitle">Load Local Libraries From Disk</span> and <span class="gtitle">Load System Libraries From Disk</span> options are used during import and the same library is found in both local and system directories. (GP-3445)</li>
|
||||
|
@ -197,11 +197,11 @@ public class ElfRelocationTable implements ElfFileSection {
|
||||
int relocationIndex = 0;
|
||||
long remainingRelocations = reader.readNext(LEB128::signed); // reloc_count
|
||||
long offset = reader.readNext(LEB128::signed); // reloc_baseOffset
|
||||
long addend = 0;
|
||||
|
||||
while (remainingRelocations > 0) {
|
||||
|
||||
// start new group
|
||||
long addend = 0;
|
||||
// start new group - read group header (size and flags)
|
||||
|
||||
// group_size
|
||||
long groupSize = reader.readNext(LEB128::signed);
|
||||
@ -228,10 +228,13 @@ public class ElfRelocationTable implements ElfFileSection {
|
||||
// group_info (optional)
|
||||
long groupRInfo = groupedByInfo ? reader.readNext(LEB128::signed) : 0;
|
||||
|
||||
if (groupedByAddend && groupHasAddend) {
|
||||
if (groupHasAddend && groupedByAddend) {
|
||||
// group_addend (optional)
|
||||
addend += reader.readNext(LEB128::signed);
|
||||
}
|
||||
else if (!groupHasAddend) {
|
||||
addend = 0;
|
||||
}
|
||||
|
||||
for (int i = 0; i < groupSize; i++) {
|
||||
// reloc_offset (optional)
|
||||
|
@ -21,7 +21,6 @@ import java.io.InputStream;
|
||||
import ghidra.docking.settings.*;
|
||||
import ghidra.program.model.mem.MemBuffer;
|
||||
import ghidra.program.model.scalar.Scalar;
|
||||
import ghidra.util.classfinder.ClassTranslator;
|
||||
|
||||
/**
|
||||
* An abstract base class for a LEB128 variable length integer data type.
|
||||
@ -82,13 +81,27 @@ public abstract class AbstractLeb128DataType extends BuiltIn implements Dynamic
|
||||
maxLength = LEB128.MAX_SUPPORTED_LENGTH;
|
||||
}
|
||||
|
||||
int len = getLength(buf, maxLength);
|
||||
if (len < 1) {
|
||||
return null; // error, or more than 10 bytes long
|
||||
}
|
||||
|
||||
long val;
|
||||
try (InputStream is = buf.getInputStream(0, maxLength)) {
|
||||
long val = LEB128.read(is, signed);
|
||||
return new Scalar(64 - Long.numberOfLeadingZeros(val), val, signed);
|
||||
val = LEB128.read(is, signed);
|
||||
}
|
||||
catch (IOException e) {
|
||||
return null; // memory error, or more than 10 bytes long
|
||||
return null; // error, or more than 10 bytes long
|
||||
}
|
||||
|
||||
// approximate bitLength from storage byte length
|
||||
int bitLength = Math.max(64, len * 7);
|
||||
int mod = bitLength % 8;
|
||||
if (mod != 0) {
|
||||
bitLength += (8 - mod);
|
||||
}
|
||||
|
||||
return new Scalar(bitLength, val, signed);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
Loading…
Reference in New Issue
Block a user