diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/compositeeditor/CompositeEditorPanel.java b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/compositeeditor/CompositeEditorPanel.java index e9288a844f..58c81ee818 100644 --- a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/compositeeditor/CompositeEditorPanel.java +++ b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/compositeeditor/CompositeEditorPanel.java @@ -1093,7 +1093,7 @@ public abstract class CompositeEditorPanel extends JPanel private Integer findBackward(String text) { String searchText = text.toLowerCase(); - int colCount = model.getColumnCount(); + int colCount = table.getColumnCount(); int currentRow = Math.max(0, model.getRow()); // search previous lines @@ -1117,16 +1117,20 @@ public abstract class CompositeEditorPanel extends JPanel return null; } - private boolean matchesSearch(String searchText, int row, int col) { - int modelCol = table.convertColumnIndexToModel(col); - Object valueAt = model.getValueAt(row, modelCol); + private boolean matchesSearch(String searchText, int viewRow, int viewCol) { + + // Note: row is the same in view and model space; col is in view space and can differ from + // the model, since columns can be hidden in the view, but remain in the model. + int modelRow = viewRow; + int modelCol = table.convertColumnIndexToModel(viewCol); + Object valueAt = model.getValueAt(modelRow, modelCol); if (valueAt == null) { return false; } String value = getString(valueAt).toLowerCase(); - if (modelCol == model.getNameColumn()) { - return nameMatchesSearch(searchText, row, value); + if (viewCol == model.getNameColumn()) { + return nameMatchesSearch(searchText, modelRow, value); } return value.contains(searchText); diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/coff/CoffMachineType.java b/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/coff/CoffMachineType.java index a1e43ece36..b2b7b83288 100644 --- a/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/coff/CoffMachineType.java +++ b/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/coff/CoffMachineType.java @@ -203,6 +203,11 @@ public class CoffMachineType { * Hitachi SH5 */ public final static short IMAGE_FILE_MACHINE_SH5 = 0x01a8; + + /** + * Texas Instruments TMS320C3x/4x + */ + public final static short IMAGE_FILE_MACHINE_TI_TMS320C3x4x = 0x0093; /** * Texas Instruments TMS470 diff --git a/Ghidra/Processors/PowerPC/src/main/java/ghidra/app/util/bin/format/elf/relocation/PowerPC_ElfRelocationHandler.java b/Ghidra/Processors/PowerPC/src/main/java/ghidra/app/util/bin/format/elf/relocation/PowerPC_ElfRelocationHandler.java index 3680866b10..e630d73484 100644 --- a/Ghidra/Processors/PowerPC/src/main/java/ghidra/app/util/bin/format/elf/relocation/PowerPC_ElfRelocationHandler.java +++ b/Ghidra/Processors/PowerPC/src/main/java/ghidra/app/util/bin/format/elf/relocation/PowerPC_ElfRelocationHandler.java @@ -78,6 +78,8 @@ public class PowerPC_ElfRelocationHandler extends // symbolValue = elfRelocationContext.getImageBaseWordAdjustmentOffset(); // } + long relocbase = elfRelocationContext.getImageBaseWordAdjustmentOffset(); + int offset = (int) relocationAddress.getOffset(); int oldValue = memory.getInt(relocationAddress); int newValue = 0; @@ -106,47 +108,39 @@ public class PowerPC_ElfRelocationHandler extends break; case R_PPC_ADDR16: case R_PPC_UADDR16: - case R_PPC_ADDR16_LO: newValue = (int) symbolValue + addend; memory.setShort(relocationAddress, (short) newValue); byteLength = 2; break; + case R_PPC_ADDR16_LO: + if (Long.compareUnsigned(symbolValue, relocbase) > 0 && + Long.compareUnsigned(symbolValue, relocbase + addend) <= 0) { + /** + * (freebsd) Addend values are sometimes relative to sections in rela, + * where in reality they are relative to relocbase. Detect this condition. + */ + symbolValue = (int) relocbase; + } + newValue = (int) (symbolValue + addend); + memory.setShort(relocationAddress, (short) newValue); + byteLength = 2; + break; case R_PPC_ADDR16_HI: newValue = ((int) symbolValue + addend) >> 16; memory.setShort(relocationAddress, (short) newValue); byteLength = 2; break; - /** - * - R_POWERPC_ADDR16_HA: ((Symbol + Addend + 0x8000) >> 16) & 0xffff - static inline void addr16_ha(unsigned char* view, Address value) - { This::addr16_hi(view, value + 0x8000); } - - static inline void - addr16_hi(unsigned char* view, Address value) - { This::template rela<16,16>(view, 16, 0xffff, value + 0x8000, CHECK_NONE); } - - rela(unsigned char* view, - unsigned int right_shift, - typename elfcpp::Valtype_base::Valtype dst_mask, - Address value, - Overflow_check overflow) - { - typedef typename elfcpp::Swap::Valtype Valtype; - Valtype* wv = reinterpret_cast(view); - Valtype val = elfcpp::Swap::readval(wv); // original bytes - - Valtype reloc = value >> 16; - val &= ~0xffff; - reloc &= dst_mask; - elfcpp::Swap::writeval(wv, val | reloc); // write instr btes - return overflowed(value >> 16, overflow); - } - - - */ case R_PPC_ADDR16_HA: - newValue = ((int) symbolValue + addend + 0x8000) >> 16; + if (Long.compareUnsigned(symbolValue, relocbase) > 0 && + Long.compareUnsigned(symbolValue, relocbase + addend) <= 0) { + /** + * (freebsd) Addend values are sometimes relative to sections in rela, + * where in reality they are relative to relocbase. Detect this condition. + */ + symbolValue = (int) relocbase; + } + newValue = (int) (symbolValue + addend); + newValue = (newValue >> 16) + ((newValue & 0x8000) != 0 ? 1 : 0); memory.setShort(relocationAddress, (short) newValue); byteLength = 2; break; @@ -264,4 +258,4 @@ public class PowerPC_ElfRelocationHandler extends return new RelocationResult(Status.APPLIED, byteLength); } -} +} \ No newline at end of file