mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2026-09-28 17:11:11 -09:00
Merge remote-tracking branch 'origin/GP-7283_ghidra1_ELFPermissions'
into Ghidra_12.2 (Closes #9644)
This commit is contained in:
@@ -3214,8 +3214,6 @@ class ElfProgramBuilder extends MemorySectionResolver implements ElfLoadHelper {
|
|||||||
long loadSizeBytes = elfProgramHeader.getAdjustedLoadSize();
|
long loadSizeBytes = elfProgramHeader.getAdjustedLoadSize();
|
||||||
long fullSizeBytes = elfProgramHeader.getAdjustedMemorySize();
|
long fullSizeBytes = elfProgramHeader.getAdjustedMemorySize();
|
||||||
|
|
||||||
boolean maintainExecuteBit = elf.getSectionHeaderCount() == 0;
|
|
||||||
|
|
||||||
if (fullSizeBytes <= 0) {
|
if (fullSizeBytes <= 0) {
|
||||||
if (!space.isLoadedMemorySpace() && loadSizeBytes > 0) {
|
if (!space.isLoadedMemorySpace() && loadSizeBytes > 0) {
|
||||||
fullSizeBytes = loadSizeBytes;
|
fullSizeBytes = loadSizeBytes;
|
||||||
@@ -3239,16 +3237,12 @@ class ElfProgramBuilder extends MemorySectionResolver implements ElfLoadHelper {
|
|||||||
|
|
||||||
String comment = getSectionComment(addr, fullSizeBytes, space.getAddressableUnitSize(),
|
String comment = getSectionComment(addr, fullSizeBytes, space.getAddressableUnitSize(),
|
||||||
elfProgramHeader.getDescription(), address.isLoadedMemoryAddress());
|
elfProgramHeader.getDescription(), address.isLoadedMemoryAddress());
|
||||||
if (!maintainExecuteBit && elfProgramHeader.isExecute()) {
|
|
||||||
comment += " (disabled execute bit)";
|
|
||||||
}
|
|
||||||
|
|
||||||
String blockName = getSegmentName(elfProgramHeader, segmentNumber);
|
String blockName = getSegmentName(elfProgramHeader, segmentNumber);
|
||||||
if (loadSizeBytes != 0) {
|
if (loadSizeBytes != 0) {
|
||||||
addInitializedMemorySection(elfProgramHeader, elfProgramHeader.getOffset(),
|
addInitializedMemorySection(elfProgramHeader, elfProgramHeader.getOffset(),
|
||||||
loadSizeBytes, address, blockName, elfProgramHeader.isRead(),
|
loadSizeBytes, address, blockName, elfProgramHeader.isRead(),
|
||||||
elfProgramHeader.isWrite(),
|
elfProgramHeader.isWrite(), elfProgramHeader.isExecute(), comment,
|
||||||
maintainExecuteBit ? elfProgramHeader.isExecute() : false, comment,
|
|
||||||
isFragmentationOK,
|
isFragmentationOK,
|
||||||
elfProgramHeader.getType() == ElfProgramHeaderConstants.PT_LOAD);
|
elfProgramHeader.getType() == ElfProgramHeaderConstants.PT_LOAD);
|
||||||
}
|
}
|
||||||
@@ -3435,11 +3429,11 @@ class ElfProgramBuilder extends MemorySectionResolver implements ElfLoadHelper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Address address = null;
|
Address address = null;
|
||||||
|
ElfProgramHeader loadHeader = elf.getProgramLoadHeaderContaining(addr);
|
||||||
|
|
||||||
if (sectionByteLength == 0 &&
|
if (sectionByteLength == 0 &&
|
||||||
elfSectionToLoad.getType() == ElfSectionHeaderConstants.SHT_PROGBITS) {
|
elfSectionToLoad.getType() == ElfSectionHeaderConstants.SHT_PROGBITS) {
|
||||||
// Check for and consume uninitialized portion of PT_LOAD segment if possible
|
// Check for and consume uninitialized portion of PT_LOAD segment if possible
|
||||||
ElfProgramHeader loadHeader = elf.getProgramLoadHeaderContaining(addr);
|
|
||||||
if (loadHeader != null) {
|
if (loadHeader != null) {
|
||||||
// NOTE: should never apply to relocatable ELF
|
// NOTE: should never apply to relocatable ELF
|
||||||
Address segmentStart = getSegmentLoadAddress(loadHeader);
|
Address segmentStart = getSegmentLoadAddress(loadHeader);
|
||||||
@@ -3478,6 +3472,19 @@ class ElfProgramBuilder extends MemorySectionResolver implements ElfLoadHelper {
|
|||||||
|
|
||||||
final String blockName = elfSectionToLoad.getNameAsString();
|
final String blockName = elfSectionToLoad.getNameAsString();
|
||||||
|
|
||||||
|
boolean isExecute = elfSectionToLoad.isExecutable();
|
||||||
|
boolean isWrite = elfSectionToLoad.isWritable();
|
||||||
|
boolean isRead = true;
|
||||||
|
|
||||||
|
if (loadHeader != null) {
|
||||||
|
// If PT_LOAD exists, defer to it for permissions
|
||||||
|
// NOTE: This does not handle a section not fully contained within a program
|
||||||
|
// header loaded region
|
||||||
|
isExecute = loadHeader.isExecute();
|
||||||
|
isWrite = loadHeader.isWrite();
|
||||||
|
isRead = loadHeader.isRead();
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (loadOffset == -1 ||
|
if (loadOffset == -1 ||
|
||||||
elfSectionToLoad.getType() == ElfSectionHeaderConstants.SHT_NOBITS) {
|
elfSectionToLoad.getType() == ElfSectionHeaderConstants.SHT_NOBITS) {
|
||||||
@@ -3489,7 +3496,7 @@ class ElfProgramBuilder extends MemorySectionResolver implements ElfLoadHelper {
|
|||||||
getSectionComment(addr, sectionByteLength, space.getAddressableUnitSize(),
|
getSectionComment(addr, sectionByteLength, space.getAddressableUnitSize(),
|
||||||
elfSectionToLoad.getTypeAsString(), address.isLoadedMemoryAddress());
|
elfSectionToLoad.getTypeAsString(), address.isLoadedMemoryAddress());
|
||||||
addUninitializedMemorySection(elfSectionToLoad, sectionByteLength, address,
|
addUninitializedMemorySection(elfSectionToLoad, sectionByteLength, address,
|
||||||
blockName, true, elfSectionToLoad.isWritable(), elfSectionToLoad.isExecutable(),
|
blockName, isRead, isWrite, isExecute,
|
||||||
comment, false);
|
comment, false);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@@ -3497,8 +3504,8 @@ class ElfProgramBuilder extends MemorySectionResolver implements ElfLoadHelper {
|
|||||||
getSectionComment(addr, sectionByteLength, space.getAddressableUnitSize(),
|
getSectionComment(addr, sectionByteLength, space.getAddressableUnitSize(),
|
||||||
elfSectionToLoad.getTypeAsString(), address.isLoadedMemoryAddress());
|
elfSectionToLoad.getTypeAsString(), address.isLoadedMemoryAddress());
|
||||||
addInitializedMemorySection(elfSectionToLoad, loadOffset, sectionByteLength,
|
addInitializedMemorySection(elfSectionToLoad, loadOffset, sectionByteLength,
|
||||||
address, blockName, elfSectionToLoad.isAlloc(), elfSectionToLoad.isWritable(),
|
address, blockName, isRead, isWrite,
|
||||||
elfSectionToLoad.isExecutable(), comment, false, elfSectionToLoad.isAlloc());
|
isExecute, comment, false, elfSectionToLoad.isAlloc());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (AddressOverflowException e) {
|
catch (AddressOverflowException e) {
|
||||||
|
|||||||
Reference in New Issue
Block a user