Merge remote-tracking branch

'origin/GP-6742_dev747368_fix_gccexceptionanalyzer_absptr_calc--SQUASHED'
(Closes #9131)
This commit is contained in:
Ryan Kurtz
2026-04-23 11:25:42 -04:00
2 changed files with 23 additions and 29 deletions
@@ -4,9 +4,9 @@
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
* You may obtain a copy of the License at * You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -263,7 +263,8 @@ abstract class AbstractDwarfEHDecoder implements DwarfEHDecoder {
switch (appMode) { switch (appMode) {
case DW_EH_PE_absptr: case DW_EH_PE_absptr:
// just pass this through // adjust abs ptr for any changes to imagebase during import
val = context.getImageBaseAdjustment() + val;
break; break;
case DW_EH_PE_aligned: case DW_EH_PE_aligned:
@@ -4,9 +4,9 @@
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
* You may obtain a copy of the License at * You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -15,10 +15,10 @@
*/ */
package ghidra.app.plugin.exceptionhandlers.gcc; package ghidra.app.plugin.exceptionhandlers.gcc;
import ghidra.app.util.opinion.ElfLoader;
import ghidra.program.model.address.Address; import ghidra.program.model.address.Address;
import ghidra.program.model.listing.Function; import ghidra.program.model.listing.Function;
import ghidra.program.model.listing.Program; import ghidra.program.model.listing.Program;
import ghidra.program.model.mem.MemBuffer;
import ghidra.program.model.mem.MemoryBlock; import ghidra.program.model.mem.MemoryBlock;
/** /**
@@ -30,10 +30,10 @@ public class DwarfDecodeContext {
private final Address addr; private final Address addr;
private final MemoryBlock ehBlock; private final MemoryBlock ehBlock;
private final Address functionEntryPoint; private final Address functionEntryPoint;
private final long imageBaseAdjustment;
private Object decodedValue; private Object decodedValue;
private int encodedLength; private int encodedLength;
private MemBuffer buffer;
/** /**
* Constructs a Dwarf decode context. * Constructs a Dwarf decode context.
@@ -95,31 +95,16 @@ public class DwarfDecodeContext {
this.addr = readAddr; this.addr = readAddr;
this.ehBlock = ehBlock; this.ehBlock = ehBlock;
this.functionEntryPoint = entryPoint; this.functionEntryPoint = entryPoint;
this.imageBaseAdjustment = getImageBaseAdjustment(program);
} }
/** private static long getImageBaseAdjustment(Program program) {
* Constructs a Dwarf decode context. Long originalImageBase = ElfLoader.getElfOriginalImageBase(program);
* @param buffer the memory buffer which provides the program and address of the encoded data if (originalImageBase != null) {
* @param length the length of the encoded data return program.getImageBase().getOffset() - originalImageBase;
*/ }
public DwarfDecodeContext(MemBuffer buffer, int length) { return 0;
this(buffer, length, null, null);
}
/**
* Constructs a Dwarf decode context.
* @param buf the memory buffer which provides the program and address of the encoded data
* @param length the length of the encoded data
* @param ehBlock the exception handling memory block
* @param entryPoint the function entry point
*/
public DwarfDecodeContext(MemBuffer buf, int length, MemoryBlock ehBlock, Address entryPoint) {
this.buffer = buf;
this.program = buffer.getMemory().getProgram();
this.addr = buffer.getAddress();
this.ehBlock = ehBlock;
this.functionEntryPoint = entryPoint;
} }
/** /**
@@ -180,4 +165,12 @@ public class DwarfDecodeContext {
public Address getFunctionEntryPoint() { public Address getFunctionEntryPoint() {
return functionEntryPoint; return functionEntryPoint;
} }
/**
* {@return any adjustment needed to be applied to absolute addresses (because the program's
* base address was modified during import)}
*/
public long getImageBaseAdjustment() {
return imageBaseAdjustment;
}
} }