mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2025-10-04 18:29:37 +02:00
GP-3543 corrected ELF Android packed reloc bug and sleb128 datatype
value
This commit is contained in:
parent
d40c5165f5
commit
bcfc7c84d8
2 changed files with 23 additions and 7 deletions
|
@ -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…
Add table
Add a link
Reference in a new issue