Commit graph

13450 commits

Author SHA1 Message Date
ghidra1
130b365e7c GP-5827 Corrected ELF MIPS 64-bit relocation processing error 2025-07-15 18:27:41 -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
ghidra1
183ecf3acf GP-5822 Corrected errors related to null CommentType returned by
CommentFieldLocation
2025-07-11 09:08:21 -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
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
dragonmacher
2394103ea5 Test fixes 2025-07-02 09:10:57 -04:00
Dan
f74b783b3e GP-5796: Write event thread down in emulated snapshots. 2025-07-01 18:15:47 +00:00
Dan
044bd03ccb GP-5790: Fix NPE on "Select Current Module" when cursor is not in a module. 2025-07-01 17:57:15 +00:00
ghidra1
2727715539 GP-5797 Corrected CommentsDialog regression. Default to previously used
tab
2025-06-30 14:36:16 -04:00
ghidra1
4629af7235 Merge remote-tracking branch 'origin/GP-5738_Dan_gdbArmv5te' into patch 2025-06-30 08:29:30 -04:00
ghidra1
0a07e885db Merge remote-tracking branch 'origin/GP-5767_ryanmkurtz_dyld' into patch 2025-06-30 08:24:44 -04:00
ghidra1
a613bd4972 Merge remote-tracking branch
'origin/GP-5777-dragonmacher-dialog-context-fix--SQUASHED' into patch
(Closes #8294)
2025-06-30 08:23:02 -04:00
ghidra1
39770ddee0 Merge remote-tracking branch 'origin/GP-1-dragonmacher-tool-restore-state-fix' into patch 2025-06-30 08:19:52 -04:00
Dan
cbf8579c9d GP-5738: Add armv5te to gdb connector's arch.py 2025-06-27 13:06:54 +00:00
dragonmacher
64ee7bd5a1 Fixed an exception in the enabledWhen() method of the ClearSelection
action
2025-06-26 18:33:15 -04:00
dragonmacher
6b7064b1f4 GP-5777 - Fix for dialog action context 2025-06-26 13:54:21 -04:00
dragonmacher
d88f464a32 Fixed potential NPE when restoring tool state 2025-06-24 13:16:33 -04:00
Ryan Kurtz
a7e64844fb GP-0: Fixing ChangeHistory typo 2025-06-24 12:30:42 -04:00
Ryan Kurtz
2d34b3afc7 GP-0: Upping patch to 11.4.1 2025-06-24 12:28:38 -04:00
Ryan Kurtz
9e4e43d9f8 GP-5767: Support for iOS 26 BETA dyld_shared_cache 2025-06-20 17:05:31 -04:00
ghidra2
aed1cf1c4e GP-0 - ChangeHistory.md for 11.4 2025-06-18 19:22:22 +00:00
emteere
c87e45857c GP-0 11.4 WhatsNew 2025-06-17 17:48:34 -04:00
Ryan Kurtz
560497c5ff Merge remote-tracking branch 'origin/GP-5762_ghidra007_autoVT_increase_dupe_correlator_min' into Ghidra_11.4 2025-06-16 14:37:41 -04:00
ghidra007
160dfd1e36 GP-5762 increased AutoVT duplicate inst match correlator min function
size
2025-06-16 15:49:44 +00:00
James
79d87eb63d GP-0 fixed postgres version in make-postgres.sh comments 2025-06-16 14:08:52 +00:00
emteere
2971656579 GP-5695 fixing null exception 2025-06-13 19:30:34 +00:00
ghidraffe
4436bbd564 GP-0 fix incorrect version specified for postgres. 2025-06-13 14:43:14 +00:00
Ryan Kurtz
ee0815cbd3 GP-0: Fixing javadoc warning 2025-06-13 07:06:13 -04:00
ghidra1
ea414bd23e Merge branch 'GP-5680_ghidra1_Postgres15.13' into Ghidra_11.4
(Closes #8122)
2025-06-11 13:42:39 -04:00
ghidra1
5c8da44a33 GP-5680 Postgres upgrade to 15.13 and JDBC driver 42.7.6 2025-06-11 13:10:36 -04:00
Ryan Kurtz
e08d05a376 Merge remote-tracking branch 'origin/GP-5622_ghidorahrex_aarch64_neon_impl--SQUASHED' into Ghidra_11.4 2025-06-11 11:51:05 -04:00
vporok01
3d54c90cd6 Fix RISC-V minu and max instructions' definitions (Closes #8215) 2025-06-11 11:47:49 -04:00
ghidorahrex
fe4244cbc9 GP-5622: Implemented pcode for several AARCH64 Neon instructions 2025-06-11 07:56:09 -04:00
dev747368
e2fa4aaa7b GP-5755 Fix Apple KDK DWARF section name lookup, atomic type and source
file npe

Apple Macho binaries truncate section names to 16 chars, DWARF 5
introduced a section (debug_str_offsets) that has a name longer than 16
(along with the macho "__" prefix).

Add support for ignoring atomic_type, and some checking for missing
source file names.
2025-06-10 21:04:56 +00:00
ghidra1
f9a7a3d6ce GP-0 Fill out a few StubListing methods to avoid VT test stack traces 2025-06-10 13:52:10 -04:00
ghidorahrex
b0750c2783 GP-5725: Corrected operands for several AVX512 instructions 2025-06-10 09:21:39 -04:00