Commit graph

14981 commits

Author SHA1 Message Date
Dan
92708efe40 GP-5789: Handle case where module appears to have zero length. 2025-07-23 17:33:48 +00:00
Ryan Kurtz
d11c1c6c17 Merge remote-tracking branch
'origin/GP-5861_ghizard_PDB_and_Demangler_and_DTUtils_fix_truncated_symbol_processing'
into patch (Closes #8358)
2025-07-23 06:08:20 -04:00
ghizard
1684aaf61f GP-5861 - PDB, MDMang, and DTUtils optim - fix for processing of
truncated symbols and optional prefix on MDMang datatype demangling
2025-07-22 16:27:14 -04:00
James
49d848ad5a GP-5361 fix indexoutofboundsexception in decompiler code comparison 2025-07-22 19:48:19 +00:00
Ryan Kurtz
b17d58ce18 Merge remote-tracking branch 'origin/GP-5859_Dan_fixPatchDataAction' into patch 2025-07-22 14:34:43 -04:00
Dan
f79a1a2816 GP-5859: Both enablement and pop-up of Patch Data controlled by unit type 2025-07-22 14:29:50 +00:00
Ryan Kurtz
20643f0c31 Merge remote-tracking branch 'origin/GP-5856_RulePtrsubUndoInfiniteLoop'
into patch (Closes #7997)
2025-07-22 06:09:35 -04:00
Ryan Kurtz
a74ad243da Merge remote-tracking branch
'origin/GP-5852_Dan_fixStackTraceWithTrackWatchOnToolRestore' into patch
(Closes #8333)
2025-07-22 06:07:53 -04:00
caheckman
c4c7aa5dad Fix for infinite loop caused by RulePtrsubUndo 2025-07-21 19:40:05 +00:00
Dan
07105dbc33 GP-5852: Force saved tracking config to be an option. 2025-07-21 19:30:36 +00:00
Ryan Kurtz
3cfa867ac3 Merge remote-tracking branch 'origin/GP-5843_emteere_MIPS64FunctionStarts' into patch 2025-07-21 13:14:06 -04:00
Ryan Kurtz
440867a776 Merge remote-tracking branch 'origin/GP-5833_emteere_MIPSInfiniteLoop' into patch 2025-07-21 13:11:39 -04:00
Ryan Kurtz
db6b52b10f Merge remote-tracking branch 'origin/GP-5832_InlineOpTarget' into patch
(Closes #7383)
2025-07-18 15:19:54 -04:00
Ryan Kurtz
edf42d82d9 Merge remote-tracking branch 'origin/GP-5846_ghidra1_PPC64_ELFRelocations' into patch 2025-07-18 15:17:45 -04:00
ghidra1
006bd8d423 GP-5846 Corrected ELF PowerPC 64-bit relocation processing bugs
affecting ELFv2 use and R_PPC64_JMP_SLOT relocation
2025-07-18 12:00:34 -04:00
Ryan Kurtz
5d66a34a5f GP-5820: Enabling gradle for VSCode projects (Closes #8322) 2025-07-18 08:14:23 -04:00
Ryan Kurtz
374c7e33cd Merge remote-tracking branch 'origin/GP-5752_emteere_InstSeparatorFix--SQUASHED' into patch 2025-07-18 06:16:42 -04:00
Ryan Kurtz
e69ce4104b Merge remote-tracking branch 'origin/GP-5804_emteere_FixDefaultSymbolicPropRecordState' into patch 2025-07-18 06:15:13 -04:00
emteere
3468c4b502 GP-5843 Added MIPS64 function start patterns 2025-07-17 22:42:00 +00:00
emteere
8839bd365e GP-5833 Fixed possible inifinite loop during constant analysis on mips
platforms.
2025-07-17 20:31:08 +00:00
emteere
9979a6f9ec GP-5752 Fixed missing characters at the end of operands, for example closing parenthesis added in the base sleigh instruction constructor. 2025-07-17 15:49:39 -04:00
Ryan Kurtz
48f1bf133f Merge branch 'GP-5836_ryanmkurtz_ghidradev' into patch 2025-07-17 09:24:22 -04:00
Ryan Kurtz
396dd6e1de GP-5836: Fixed GhidraDev bug that prevented Ghidra from discovering the
Ghidra module project when launched with the PyGhidra run config
2025-07-17 08:52:48 -04:00
caheckman
80d66023a9 GP-5832 Update inline target op when inlining a subfunction 2025-07-16 19:12:27 +00:00
ghidra1
0bd8870da3 Merge branch 'GP-5827_ghidra1_ElfMips64RelocationProcessing' into patch 2025-07-15 18:28:19 -04:00
ghidra1
130b365e7c GP-5827 Corrected ELF MIPS 64-bit relocation processing error 2025-07-15 18:27:41 -04:00
Ryan Kurtz
f011cbd324 Merge remote-tracking branch
'origin/GP-5828-dragonmacher-extensions-dialog-action-enablement' into
patch (#8294)
2025-07-15 11:07:00 -04:00
dragonmacher
5b3f4e9e90 Fixed the Install Extensions dialog toolbar action enablement 2025-07-14 19:45:16 -04:00
Ryan Kurtz
9ddc746e6f Merge remote-tracking branch 'origin/GP-5718_LeftShiftSubvar' into patch 2025-07-14 16:09:18 -04:00
Ryan Kurtz
7d76ab5e9b Merge remote-tracking branch
'origin/GP-4989_ghintern_arm_fix_aapcs--SQUASHED' into patch
(Closes #6958)
2025-07-14 16:05:48 -04:00
ghintern
3e11715778 GP-4989: Fix ARM AAPCS cspec, add soft float calling convention 2025-07-14 18:38:17 +00:00
ghidra007
b3f4609330 GP-5718 fix for index issue 2025-07-14 15:17:49 +00:00
Ryan Kurtz
5ae62e2f49 Merge remote-tracking branch 'origin/GP-5822_ghidra1_CommentTypeErrors'
into patch (Closes #8341)
2025-07-11 11:46:15 -04:00
ghidra1
183ecf3acf GP-5822 Corrected errors related to null CommentType returned by
CommentFieldLocation
2025-07-11 09:08:21 -04:00
Ryan Kurtz
3ad921d5c7 Merge remote-tracking branch 'origin/GP-5816_ReturnValueRecovery' into patch 2025-07-10 05:35:35 -04:00
caheckman
de842dbd32 GP-5816 Fix return recovery for AARCH64 and ARM 2025-07-09 21:19:07 +00:00
Ryan Kurtz
bf167a3126 GP-5810: Improving CWD removal from sys.path 2025-07-07 12:23:55 -04:00
Ryan Kurtz
2930b622cc GP-5810: Removing CWD from PyGhidra's sys.path (Closes #8190) 2025-07-07 11:35:57 -04:00
Nicolas Iooss
e2de11d5b2
Fix eBPF zero-extend load instructions
When a loading less than 8 bytes to a register, the value is supposed to
be zero-extended. This is what the eBPF execution engine in the Linux
kernel does, in
https://web.git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/kernel/bpf/core.c?h=v6.14#n2113
This is also what is specified in RFC 9669 which standardised BPF ISA:
https://www.rfc-editor.org/rfc/rfc9669.html#name-regular-load-and-store-oper

Add the missing `zext` calls in the semantic section of instructions
LDXW, LDXH and LDXB. While at it, add them to other load instructions.

For information, the issue can be seen when analyzing this C program:

    unsigned int div_by_1000(unsigned int value) {
        return value / 1000;
    }

Compiling it with clang gives:

    $ clang -O0 -target bpf -c division.c -o division.ebpf
    $ bpf-objdump -rd division.ebpf
    division.ebpf:     file format elf64-bpfle

    Disassembly of section .text:

    0000000000000000 <div_by_1000>:
       0:    63 1a fc ff 00 00 00 00     stxw [%fp+-4],%r1
       8:    61 a0 fc ff 00 00 00 00     ldxw %r0,[%fp+-4]
      10:    37 00 00 00 e8 03 00 00     div %r0,0x3e8
      18:    95 00 00 00 00 00 00 00     exit

Ghidra decompiles this program as:

    ulonglong div_by_1000(uint param_1)
    {
      undefined4 in_stack_00000000;
      return CONCAT44(in_stack_00000000,param_1) / 1000;
    }

This `in_stack_00000000` comes from the way the parameter is loaded from
the stack. The listing shows the following disassembly and p-code
operations:

    ram:00100008 61 a0 fc ff 00       LDXW       R0,[R10 + -0x4=>Stack[-0x4]]
                 00 00 00
                            $U3e00:8 = INT_ADD R10, -4:8
                            R0 = LOAD ram($U3e00:8)

This shows the value is indeed loaded from 8 bytes at `$U3e00:8` instead
of 4.

After adding `zext` calls, Ghidra decodes the same instruction as:

    ram:00100008 61 a0 fc ff 00       LDXW       R0,[R10 + -0x4=>local_4]
                 00 00 00
                            $U4100:8 = INT_ADD R10, -4:8
                            $U4180:4 = LOAD ram($U4100:8)
                            R0 = INT_ZEXT $U4180:4

This only loads 4 bytes from the stack, as expected.
Moreover the decompilation view is now correct:

    ulonglong div_by_1000(uint param_1)
    {
      return (ulonglong)param_1 / 1000;
    }
2025-07-07 16:28:00 +02:00
Nicolas Iooss
c1d96a2140
Fix eBPF CALL operand decoding
The operand of the CALL instruction missed multiplying the immediate
value by 8. Without this, calls are not decoded correctly.

Such a CALL instruction can be emitted when compiling this simple
`single_call.c` program:

    static int one(void) {
        return 1;
    }

    int call_one(void) {
        return one();
    }

with:

    clang -O0 -target bpf -c single_call.c -o single_call.ebpf

Disassembling with LLVM shows:

    $ llvm-objdump -d single_call.ebpf
    single_call.ebpf:	file format elf64-bpf

    Disassembly of section .text:

    0000000000000000 <call_one>:
           0:	85 10 00 00 01 00 00 00	call 1
           1:	95 00 00 00 00 00 00 00	exit

    0000000000000010 <one>:
           2:	b7 00 00 00 01 00 00 00	r0 = 1
           3:	95 00 00 00 00 00 00 00	exit

The first instruction ("call 1") calls the function located at 0x10 (at
index `2:` in the listing). Ghidra considered the call to target
address 9 instead (as `inst_next = 8` and `imm = 1`). Fix this by
multiplying `imm` by 8 when encountering a `disp32` operand (which is
only used by instruction `CALL`).

Adjust ELF Relocation R_BPF_64_32 to take into account for this
multiplication by 8. Actually it is documented to compute (S + A) / 8 - 1
so the division by 8 was missing.
2025-07-07 16:26:31 +02:00
Ryan Kurtz
2aa431a904 GP-5811: PE IMAGE_FUNCTION_RUNTIME_ENTRY's are now all marked as
functions (Closes #8321)
2025-07-07 10:17:49 -04:00
Nicolas Iooss
adb0eac98a
Add support for big endian eBPF programs 2025-07-07 16:13:37 +02:00
Nicolas Iooss
52cb7a36e6
Fix the semantics of eBPF byte swap instructions
eBPF byte swap operations (BE16, BE32, BE64, LE16, LE32, LE64) have
semantics that depend on the endianness of the host processor executing
the eBPF program. For example, on a Little-Endian CPU, BE16 swaps the 2
lowest significant bytes of the given destination register.

The semantic section of LE16 contains:

    { dst=((dst) >> 8) | ((dst) << 8); }

This contains several issues:

- It assumes the instruction always swaps the bytes. This should only
  happen on Big-Endian host CPU.
- If `dst` does not contain a 16-bit value (meaning `dst >> 16 != 0`),
  the computed value is wrong. The value should be properly masked. For
  example the Linux kernel defines in
  https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/include/uapi/linux/swab.h?h=v6.14#L14

    #define ___constant_swab16(x) ((__u16)(             \
            (((__u16)(x) & (__u16)0x00ffU) << 8) |      \
            (((__u16)(x) & (__u16)0xff00U) >> 8)))

As the endianness of the CPU has to be the same as the eBPF program
(defined in the ELF header), introduce a macro `ENDIAN` and use it to
implement the byte swap operations.
2025-07-07 16:13:36 +02:00
emteere
4723729d80 GP-5804 Set SymbolicPropogator to record register begin/end state in
basic constructor. Better document recordBeginEndState flag.
2025-07-03 17:49:53 +00:00
Ryan Kurtz
7e1b6e9cd5 Merge remote-tracking branch 'origin/GP-5799_Dan_FixNPEInExample' into
patch (Closes #8296)
2025-07-03 06:18:13 -04:00
Ryan Kurtz
a41ad68289 Merge remote-tracking branch 'origin/GP-5790_Dan_fixNPEWhenCursorOutsideModule' into patch 2025-07-03 06:17:00 -04:00
Ryan Kurtz
f3a90f7887 Merge remote-tracking branch 'origin/GP-5796_Dan_setEmuEventThread' into
patch (Closes #8293)
2025-07-03 06:15:29 -04:00
Ryan Kurtz
d16bf27873 GP-5802: Fixed a timing issue that prevented
FlatProgramAPI.analyzeAll(Program) from picking up analyzer options set
in the script (Closes #8287)
2025-07-02 09:24:19 -04:00
Ryan Kurtz
90c85a7761 Merge remote-tracking branch 'origin/GP-0-dragonmacher-test-fixes-7-2-25' into patch 2025-07-02 09:16:27 -04:00
dragonmacher
2394103ea5 Test fixes 2025-07-02 09:10:57 -04:00