diff --git a/GPL/nativeBuildProperties.gradle b/GPL/nativeBuildProperties.gradle index 23eb20a824..f2505898f3 100644 --- a/GPL/nativeBuildProperties.gradle +++ b/GPL/nativeBuildProperties.gradle @@ -107,6 +107,9 @@ def isNativeBinaryMakeTask(Task task, String platform) { * ******************************************************************************************/ def shouldSkipNative(task) { + if (rootProject.hasProperty("skipAllNatives")) { + return true; + } return task.ext.has("skipNative") && task.ext.get("skipNative") } diff --git a/Ghidra/Configurations/Public_Release/src/global/docs/ChangeHistory.md b/Ghidra/Configurations/Public_Release/src/global/docs/ChangeHistory.md index 5e9b6fd46a..5f626445e9 100644 --- a/Ghidra/Configurations/Public_Release/src/global/docs/ChangeHistory.md +++ b/Ghidra/Configurations/Public_Release/src/global/docs/ChangeHistory.md @@ -1,3 +1,21 @@ +# Ghidra 11.4.2 Change History (August 2025) + +### Improvements +* _Build_. Ghidra now supports Gradle 9. (GP-5901) +* _Decompiler_. Improved Decompiler's analysis of switches where the guard condition has been duplicated across multiple basic blocks that all feed into the same switch calculation. (GP-5889) +* _Processors_. Added the SuperH GBR register to the unaffected list in the `.cspec` so that the Decompiler sees the value as preserved across subroutine calls. (GP-5912, Issue #4387) + +### Bugs +* _Analysis_. Fixed switch recovery analysis speed degredation on functions with multiple potential switches. (GP-5917) +* _Decompiler_. Fixed a bug in the Decompiler's analysis of duplicated boolean expressions that could reverse the meaning of an expression. (GP-5915, Issue #8310) +* _Decompiler_. Fixed an uncaught exception in the Decompiler that resulted when `highSymbol` was null. (GP-5919, Issue #8413) +* _Exporter_. The `IntelHexExpoter` no longer fails due to falsely identifying a 32-bit program as 64-bit. Additionally, the address space option is no longer hidden. (GP-5910, Issue #8409) +* _Importer:ELF_. Corrected ELF MIPS-64 packed REL relocation processing issue seen when the relocation type R_MIPS_REL32 is included (e.g., packed type 0x1203). When 64-bit pointers are used, this relocation must read 8 bytes from memory instead of 4 bytes to produce the correct addend value. (GP-5918) +* _Importer:PE_. Fixed a regression that caused bad functions to be created in the middle of good functions in PE files with chained `IMAGE_FUNCTION_RUNTIME_ENTRY`s, and prevented some PE binaries from importing. (GP-5916, Issue #8414) +* _Importer:PE_. The `IMAGE_RESOURCE_DIRECTORY_ENTRY` data type is now correctly defined as a structure instead of a union. (GP-5935, Issue #8446) +* _PDB_. Fixed structure member issue, broken with 11.4 release, that could cause improper structure layout and Decompiler low-level errors. (GP-5928) +* _Processors_. Added additional SPE and APU instructions to e500 PowerPC variant. (GP-5945) + # Ghidra 11.4.1 Change History (July 2025) ### Improvements diff --git a/Ghidra/Debug/Debugger-agent-dbgeng/certification.manifest b/Ghidra/Debug/Debugger-agent-dbgeng/certification.manifest index 25f327909f..1634305df4 100644 --- a/Ghidra/Debug/Debugger-agent-dbgeng/certification.manifest +++ b/Ghidra/Debug/Debugger-agent-dbgeng/certification.manifest @@ -3,13 +3,6 @@ ##MODULE IP: MIT Module.manifest||GHIDRA||||END| README.md||GHIDRA||||END| -data/debugger-launchers/kernel-dbgeng.bat||GHIDRA||||END| -data/debugger-launchers/local-dbgeng-attach.bat||GHIDRA||||END| -data/debugger-launchers/local-dbgeng-ext.bat||GHIDRA||||END| -data/debugger-launchers/local-dbgeng-trace.bat||GHIDRA||||END| -data/debugger-launchers/local-dbgeng.bat||GHIDRA||||END| -data/debugger-launchers/remote-dbgeng.bat||GHIDRA||||END| -data/debugger-launchers/svrcx-dbgeng.bat||GHIDRA||||END| src/main/help/help/TOC_Source.xml||GHIDRA||||END| src/main/help/help/topics/dbgeng/dbgeng.html||GHIDRA||||END| src/main/py/LICENSE||GHIDRA||||END| diff --git a/Ghidra/Debug/Debugger-agent-dbgeng/data/debugger-launchers/kernel-dbgeng.bat b/Ghidra/Debug/Debugger-agent-dbgeng/data/debugger-launchers/kernel-dbgeng.bat index f454e638b0..f7a2ac34ca 100644 --- a/Ghidra/Debug/Debugger-agent-dbgeng/data/debugger-launchers/kernel-dbgeng.bat +++ b/Ghidra/Debug/Debugger-agent-dbgeng/data/debugger-launchers/kernel-dbgeng.bat @@ -1,3 +1,18 @@ +:: ### +:: IP: GHIDRA +:: +:: Licensed under the Apache License, Version 2.0 (the "License"); +:: you may not use this file except in compliance with the License. +:: You may obtain a copy of the License at +:: +:: http://www.apache.org/licenses/LICENSE-2.0 +:: +:: Unless required by applicable law or agreed to in writing, software +:: distributed under the License is distributed on an "AS IS" BASIS, +:: WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +:: See the License for the specific language governing permissions and +:: limitations under the License. +:: ## ::@title dbgeng kernel ::@desc ::@desc

Kernel debugging using dbgeng (in a Python interpreter)

diff --git a/Ghidra/Debug/Debugger-agent-dbgeng/data/debugger-launchers/local-dbgeng-attach.bat b/Ghidra/Debug/Debugger-agent-dbgeng/data/debugger-launchers/local-dbgeng-attach.bat index fa79e59322..4683d2efc8 100644 --- a/Ghidra/Debug/Debugger-agent-dbgeng/data/debugger-launchers/local-dbgeng-attach.bat +++ b/Ghidra/Debug/Debugger-agent-dbgeng/data/debugger-launchers/local-dbgeng-attach.bat @@ -1,3 +1,18 @@ +:: ### +:: IP: GHIDRA +:: +:: Licensed under the Apache License, Version 2.0 (the "License"); +:: you may not use this file except in compliance with the License. +:: You may obtain a copy of the License at +:: +:: http://www.apache.org/licenses/LICENSE-2.0 +:: +:: Unless required by applicable law or agreed to in writing, software +:: distributed under the License is distributed on an "AS IS" BASIS, +:: WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +:: See the License for the specific language governing permissions and +:: limitations under the License. +:: ## ::@title dbgeng attach ::@desc ::@desc

Attach with dbgeng (in a Python interpreter)

diff --git a/Ghidra/Debug/Debugger-agent-dbgeng/data/debugger-launchers/local-dbgeng-ext.bat b/Ghidra/Debug/Debugger-agent-dbgeng/data/debugger-launchers/local-dbgeng-ext.bat index 9f4330ad91..30e4433a37 100644 --- a/Ghidra/Debug/Debugger-agent-dbgeng/data/debugger-launchers/local-dbgeng-ext.bat +++ b/Ghidra/Debug/Debugger-agent-dbgeng/data/debugger-launchers/local-dbgeng-ext.bat @@ -1,3 +1,18 @@ +:: ### +:: IP: GHIDRA +:: +:: Licensed under the Apache License, Version 2.0 (the "License"); +:: you may not use this file except in compliance with the License. +:: You may obtain a copy of the License at +:: +:: http://www.apache.org/licenses/LICENSE-2.0 +:: +:: Unless required by applicable law or agreed to in writing, software +:: distributed under the License is distributed on an "AS IS" BASIS, +:: WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +:: See the License for the specific language governing permissions and +:: limitations under the License. +:: ## ::@title dbgeng extra options ::@image-opt env:OPT_TARGET_IMG ::@desc diff --git a/Ghidra/Debug/Debugger-agent-dbgeng/data/debugger-launchers/local-dbgeng-trace.bat b/Ghidra/Debug/Debugger-agent-dbgeng/data/debugger-launchers/local-dbgeng-trace.bat index fa1e4708d9..50c3634cd4 100644 --- a/Ghidra/Debug/Debugger-agent-dbgeng/data/debugger-launchers/local-dbgeng-trace.bat +++ b/Ghidra/Debug/Debugger-agent-dbgeng/data/debugger-launchers/local-dbgeng-trace.bat @@ -1,3 +1,18 @@ +:: ### +:: IP: GHIDRA +:: +:: Licensed under the Apache License, Version 2.0 (the "License"); +:: you may not use this file except in compliance with the License. +:: You may obtain a copy of the License at +:: +:: http://www.apache.org/licenses/LICENSE-2.0 +:: +:: Unless required by applicable law or agreed to in writing, software +:: distributed under the License is distributed on an "AS IS" BASIS, +:: WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +:: See the License for the specific language governing permissions and +:: limitations under the License. +:: ## ::@title dbgeng TTD ::@desc ::@desc

Open trace with dbgeng (in a Python interpreter)

diff --git a/Ghidra/Debug/Debugger-agent-dbgeng/data/debugger-launchers/local-dbgeng.bat b/Ghidra/Debug/Debugger-agent-dbgeng/data/debugger-launchers/local-dbgeng.bat index f2a17af3e9..3f30bb48cd 100644 --- a/Ghidra/Debug/Debugger-agent-dbgeng/data/debugger-launchers/local-dbgeng.bat +++ b/Ghidra/Debug/Debugger-agent-dbgeng/data/debugger-launchers/local-dbgeng.bat @@ -1,3 +1,18 @@ +:: ### +:: IP: GHIDRA +:: +:: Licensed under the Apache License, Version 2.0 (the "License"); +:: you may not use this file except in compliance with the License. +:: You may obtain a copy of the License at +:: +:: http://www.apache.org/licenses/LICENSE-2.0 +:: +:: Unless required by applicable law or agreed to in writing, software +:: distributed under the License is distributed on an "AS IS" BASIS, +:: WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +:: See the License for the specific language governing permissions and +:: limitations under the License. +:: ## ::@title dbgeng ::@image-opt env:OPT_TARGET_IMG ::@desc diff --git a/Ghidra/Debug/Debugger-agent-dbgeng/data/debugger-launchers/remote-dbgeng.bat b/Ghidra/Debug/Debugger-agent-dbgeng/data/debugger-launchers/remote-dbgeng.bat index d54cd208d3..48e543b597 100644 --- a/Ghidra/Debug/Debugger-agent-dbgeng/data/debugger-launchers/remote-dbgeng.bat +++ b/Ghidra/Debug/Debugger-agent-dbgeng/data/debugger-launchers/remote-dbgeng.bat @@ -1,3 +1,18 @@ +:: ### +:: IP: GHIDRA +:: +:: Licensed under the Apache License, Version 2.0 (the "License"); +:: you may not use this file except in compliance with the License. +:: You may obtain a copy of the License at +:: +:: http://www.apache.org/licenses/LICENSE-2.0 +:: +:: Unless required by applicable law or agreed to in writing, software +:: distributed under the License is distributed on an "AS IS" BASIS, +:: WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +:: See the License for the specific language governing permissions and +:: limitations under the License. +:: ## ::@title dbgeng remote ::@desc ::@desc

Connect to a remote debugger (via the .server interface)

diff --git a/Ghidra/Debug/Debugger-agent-dbgeng/data/debugger-launchers/svrcx-dbgeng.bat b/Ghidra/Debug/Debugger-agent-dbgeng/data/debugger-launchers/svrcx-dbgeng.bat index f87bae0516..e1d6834150 100644 --- a/Ghidra/Debug/Debugger-agent-dbgeng/data/debugger-launchers/svrcx-dbgeng.bat +++ b/Ghidra/Debug/Debugger-agent-dbgeng/data/debugger-launchers/svrcx-dbgeng.bat @@ -1,3 +1,18 @@ +:: ### +:: IP: GHIDRA +:: +:: Licensed under the Apache License, Version 2.0 (the "License"); +:: you may not use this file except in compliance with the License. +:: You may obtain a copy of the License at +:: +:: http://www.apache.org/licenses/LICENSE-2.0 +:: +:: Unless required by applicable law or agreed to in writing, software +:: distributed under the License is distributed on an "AS IS" BASIS, +:: WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +:: See the License for the specific language governing permissions and +:: limitations under the License. +:: ## ::@title dbgeng svrcx ::@image-opt env:OPT_TARGET_IMG ::@desc diff --git a/Ghidra/Debug/Debugger-agent-gdb/certification.manifest b/Ghidra/Debug/Debugger-agent-gdb/certification.manifest index 97d4475c6b..c6aac33ff6 100644 --- a/Ghidra/Debug/Debugger-agent-gdb/certification.manifest +++ b/Ghidra/Debug/Debugger-agent-gdb/certification.manifest @@ -2,16 +2,10 @@ ##MODULE IP: JSch License Module.manifest||GHIDRA||||END| README.md||GHIDRA||||END| -data/debugger-launchers/local-gdb.ps1||GHIDRA||||END| -data/debugger-launchers/qemu-sys-gdb.ps1||GHIDRA||||END| -data/debugger-launchers/remote-gdb.ps1||GHIDRA||||END| -data/debugger-launchers/ssh-gdb.ps1||GHIDRA||||END| -data/debugger-launchers/ssh-gdbserver.ps1||GHIDRA||||END| data/scripts/fallback_info_proc_mappings.gdb||GHIDRA||||END| data/scripts/fallback_maintenance_info_sections.gdb||GHIDRA||||END| data/scripts/getpid-linux-i386.gdb||GHIDRA||||END| data/scripts/wine32_info_proc_mappings.gdb||GHIDRA||||END| -data/support/gdbsetuputils.ps1||GHIDRA||||END| src/main/help/help/TOC_Source.xml||GHIDRA||||END| src/main/help/help/topics/gdb/gdb.html||GHIDRA||||END| src/main/help/help/topics/gdb/images/GdbLauncher.png||GHIDRA||||END| diff --git a/Ghidra/Debug/Debugger-agent-gdb/data/debugger-launchers/local-gdb.ps1 b/Ghidra/Debug/Debugger-agent-gdb/data/debugger-launchers/local-gdb.ps1 index 3b43315a3c..4b44c1632a 100644 --- a/Ghidra/Debug/Debugger-agent-gdb/data/debugger-launchers/local-gdb.ps1 +++ b/Ghidra/Debug/Debugger-agent-gdb/data/debugger-launchers/local-gdb.ps1 @@ -1,3 +1,18 @@ +## ### +# IP: GHIDRA +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +## #@title gdb #@image-opt arg:1 #@desc diff --git a/Ghidra/Debug/Debugger-agent-gdb/data/debugger-launchers/qemu-sys-gdb.ps1 b/Ghidra/Debug/Debugger-agent-gdb/data/debugger-launchers/qemu-sys-gdb.ps1 index 299d93a1a3..249bc91518 100644 --- a/Ghidra/Debug/Debugger-agent-gdb/data/debugger-launchers/qemu-sys-gdb.ps1 +++ b/Ghidra/Debug/Debugger-agent-gdb/data/debugger-launchers/qemu-sys-gdb.ps1 @@ -1,3 +1,18 @@ +## ### +# IP: GHIDRA +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +## #@title gdb + qemu-system #@image-opt env:OPT_TARGET_IMG #@desc diff --git a/Ghidra/Debug/Debugger-agent-gdb/data/debugger-launchers/remote-gdb.ps1 b/Ghidra/Debug/Debugger-agent-gdb/data/debugger-launchers/remote-gdb.ps1 index fab6f3cc16..1d6ec9585a 100644 --- a/Ghidra/Debug/Debugger-agent-gdb/data/debugger-launchers/remote-gdb.ps1 +++ b/Ghidra/Debug/Debugger-agent-gdb/data/debugger-launchers/remote-gdb.ps1 @@ -1,3 +1,18 @@ +## ### +# IP: GHIDRA +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +## #@title gdb remote #@image-opt arg:1 #@desc diff --git a/Ghidra/Debug/Debugger-agent-gdb/data/debugger-launchers/ssh-gdb.ps1 b/Ghidra/Debug/Debugger-agent-gdb/data/debugger-launchers/ssh-gdb.ps1 index cc6474cde5..52c1f30c42 100644 --- a/Ghidra/Debug/Debugger-agent-gdb/data/debugger-launchers/ssh-gdb.ps1 +++ b/Ghidra/Debug/Debugger-agent-gdb/data/debugger-launchers/ssh-gdb.ps1 @@ -1,3 +1,18 @@ +## ### +# IP: GHIDRA +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +## #@timeout 60000 #@title gdb via ssh #@image-opt arg:1 diff --git a/Ghidra/Debug/Debugger-agent-gdb/data/debugger-launchers/ssh-gdbserver.ps1 b/Ghidra/Debug/Debugger-agent-gdb/data/debugger-launchers/ssh-gdbserver.ps1 index 12c5b08060..1e7b598f60 100644 --- a/Ghidra/Debug/Debugger-agent-gdb/data/debugger-launchers/ssh-gdbserver.ps1 +++ b/Ghidra/Debug/Debugger-agent-gdb/data/debugger-launchers/ssh-gdbserver.ps1 @@ -1,3 +1,18 @@ +## ### +# IP: GHIDRA +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +## #@timeout 60000 #@title gdb + gdbserver via ssh #@image-opt arg:1 diff --git a/Ghidra/Debug/Debugger-agent-gdb/data/support/gdbsetuputils.ps1 b/Ghidra/Debug/Debugger-agent-gdb/data/support/gdbsetuputils.ps1 index 32f8962900..e39e313e87 100644 --- a/Ghidra/Debug/Debugger-agent-gdb/data/support/gdbsetuputils.ps1 +++ b/Ghidra/Debug/Debugger-agent-gdb/data/support/gdbsetuputils.ps1 @@ -1,4 +1,18 @@ - +## ### +# IP: GHIDRA +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +## . ..\..\..\Debugger-rmi-trace\data\support\setuputils.ps1 function Add-Gdb-Init-Args { diff --git a/Ghidra/Debug/Debugger-agent-lldb/certification.manifest b/Ghidra/Debug/Debugger-agent-lldb/certification.manifest index 9178e37035..4491d87e61 100644 --- a/Ghidra/Debug/Debugger-agent-lldb/certification.manifest +++ b/Ghidra/Debug/Debugger-agent-lldb/certification.manifest @@ -4,12 +4,6 @@ Module.manifest||GHIDRA||||END| README.md||GHIDRA||||END| build.gradle||GHIDRA||||END| -data/debugger-launchers/android-lldb.ps1||GHIDRA||||END| -data/debugger-launchers/kernel-lldb.ps1||GHIDRA||||END| -data/debugger-launchers/local-lldb.ps1||GHIDRA||||END| -data/debugger-launchers/remote-lldb.ps1||GHIDRA||||END| -data/debugger-launchers/ssh-lldb.ps1||GHIDRA||||END| -data/support/lldbsetuputils.ps1||GHIDRA||||END| src/main/help/help/TOC_Source.xml||GHIDRA||||END| src/main/help/help/topics/lldb/lldb.html||GHIDRA||||END| src/main/py/LICENSE||GHIDRA||||END| diff --git a/Ghidra/Debug/Debugger-agent-lldb/data/debugger-launchers/android-lldb.ps1 b/Ghidra/Debug/Debugger-agent-lldb/data/debugger-launchers/android-lldb.ps1 index 4cb31d104b..6943baf2a3 100644 --- a/Ghidra/Debug/Debugger-agent-lldb/data/debugger-launchers/android-lldb.ps1 +++ b/Ghidra/Debug/Debugger-agent-lldb/data/debugger-launchers/android-lldb.ps1 @@ -1,3 +1,18 @@ +## ### +# IP: GHIDRA +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +## #@title lldb Android #@image-opt arg:1 #@desc diff --git a/Ghidra/Debug/Debugger-agent-lldb/data/debugger-launchers/kernel-lldb.ps1 b/Ghidra/Debug/Debugger-agent-lldb/data/debugger-launchers/kernel-lldb.ps1 index faf22b61eb..3bc3f402a4 100644 --- a/Ghidra/Debug/Debugger-agent-lldb/data/debugger-launchers/kernel-lldb.ps1 +++ b/Ghidra/Debug/Debugger-agent-lldb/data/debugger-launchers/kernel-lldb.ps1 @@ -1,3 +1,18 @@ +## ### +# IP: GHIDRA +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +## #@title lldb kernel (kdp) #@desc #@desc

Launch with local lldb and connect to a remote kernel

diff --git a/Ghidra/Debug/Debugger-agent-lldb/data/debugger-launchers/local-lldb.ps1 b/Ghidra/Debug/Debugger-agent-lldb/data/debugger-launchers/local-lldb.ps1 index 51ce6b9bd7..3a250451b0 100644 --- a/Ghidra/Debug/Debugger-agent-lldb/data/debugger-launchers/local-lldb.ps1 +++ b/Ghidra/Debug/Debugger-agent-lldb/data/debugger-launchers/local-lldb.ps1 @@ -1,3 +1,18 @@ +## ### +# IP: GHIDRA +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +## #@title lldb #@image-opt arg:1 #@desc diff --git a/Ghidra/Debug/Debugger-agent-lldb/data/debugger-launchers/remote-lldb.ps1 b/Ghidra/Debug/Debugger-agent-lldb/data/debugger-launchers/remote-lldb.ps1 index a4fd41666d..e94cb07381 100644 --- a/Ghidra/Debug/Debugger-agent-lldb/data/debugger-launchers/remote-lldb.ps1 +++ b/Ghidra/Debug/Debugger-agent-lldb/data/debugger-launchers/remote-lldb.ps1 @@ -1,3 +1,18 @@ +## ### +# IP: GHIDRA +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +## #@title lldb remote (gdb) #@image-opt arg:1 #@desc diff --git a/Ghidra/Debug/Debugger-agent-lldb/data/debugger-launchers/ssh-lldb.ps1 b/Ghidra/Debug/Debugger-agent-lldb/data/debugger-launchers/ssh-lldb.ps1 index 4ddc7bf771..194ad80e2a 100644 --- a/Ghidra/Debug/Debugger-agent-lldb/data/debugger-launchers/ssh-lldb.ps1 +++ b/Ghidra/Debug/Debugger-agent-lldb/data/debugger-launchers/ssh-lldb.ps1 @@ -1,3 +1,18 @@ +## ### +# IP: GHIDRA +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +## #@timeout 60000 #@title lldb via ssh #@image-opt arg:1 diff --git a/Ghidra/Debug/Debugger-agent-lldb/data/support/lldbsetuputils.ps1 b/Ghidra/Debug/Debugger-agent-lldb/data/support/lldbsetuputils.ps1 index f83e8d42e4..3af4bfbaee 100644 --- a/Ghidra/Debug/Debugger-agent-lldb/data/support/lldbsetuputils.ps1 +++ b/Ghidra/Debug/Debugger-agent-lldb/data/support/lldbsetuputils.ps1 @@ -1,4 +1,18 @@ - +## ### +# IP: GHIDRA +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +## . ..\..\..\Debugger-rmi-trace\data\support\setuputils.ps1 function Add-Lldb-Init-Args { diff --git a/Ghidra/Debug/Debugger-rmi-trace/certification.manifest b/Ghidra/Debug/Debugger-rmi-trace/certification.manifest index 3d590fe366..596d5a3829 100644 --- a/Ghidra/Debug/Debugger-rmi-trace/certification.manifest +++ b/Ghidra/Debug/Debugger-rmi-trace/certification.manifest @@ -5,7 +5,6 @@ DEVNOTES.txt||GHIDRA||||END| Module.manifest||GHIDRA||||END| README.md||GHIDRA||||END| data/ExtensionPoint.manifest||GHIDRA||||END| -data/support/setuputils.ps1||GHIDRA||||END| src/main/help/help/TOC_Source.xml||GHIDRA||||END| src/main/help/help/topics/TraceRmiConnectionManagerPlugin/TraceRmiConnectionManagerPlugin.html||GHIDRA||||END| src/main/help/help/topics/TraceRmiConnectionManagerPlugin/images/ConnectDialog.png||GHIDRA||||END| diff --git a/Ghidra/Debug/Debugger-rmi-trace/data/support/setuputils.ps1 b/Ghidra/Debug/Debugger-rmi-trace/data/support/setuputils.ps1 index b4e050f88d..e8dfad0ab6 100644 --- a/Ghidra/Debug/Debugger-rmi-trace/data/support/setuputils.ps1 +++ b/Ghidra/Debug/Debugger-rmi-trace/data/support/setuputils.ps1 @@ -1,3 +1,18 @@ +## ### +# IP: GHIDRA +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +## function Find-App-Properties { [IO.FileInfo] $simple = "$Env:GHIDRA_HOME\Ghidra\applications.properties" if ($simple.Exists) { diff --git a/Ghidra/Features/BSim/build.gradle b/Ghidra/Features/BSim/build.gradle index 0c88c9a329..47600e5a07 100755 --- a/Ghidra/Features/BSim/build.gradle +++ b/Ghidra/Features/BSim/build.gradle @@ -24,7 +24,6 @@ apply plugin: 'eclipse' eclipse.project.name = 'Features BSim' import java.nio.file.Files -import org.gradle.util.GUtil // NOTE: fetchDependencies.gradle must be updated if postgresql version changes def postgresql_distro = "postgresql-15.13.tar.gz" diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/exporter/ExporterDialog.java b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/exporter/ExporterDialog.java index 5b6e09a72a..1a1e29b67f 100644 --- a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/exporter/ExporterDialog.java +++ b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/exporter/ExporterDialog.java @@ -4,9 +4,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -184,7 +184,7 @@ public class ExporterDialog extends DialogComponentProvider implements AddressFa return "Unexpected exception validating options: " + e.getMessage(); } }; - AddressFactoryService svc = (domainObject instanceof Program) ? null : this; + AddressFactoryService svc = (domainObject instanceof Program) ? this : null; OptionsDialog optionsDialog = new OptionsDialog(options, validator, svc); optionsDialog .setHelpLocation(new HelpLocation("ExporterPlugin", getAnchorForSelectedFormat())); diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/pe/ImageRuntimeFunctionEntries_X86.java b/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/pe/ImageRuntimeFunctionEntries_X86.java index 02bbb115b2..6206d64c48 100644 --- a/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/pe/ImageRuntimeFunctionEntries_X86.java +++ b/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/pe/ImageRuntimeFunctionEntries_X86.java @@ -144,8 +144,10 @@ public class ImageRuntimeFunctionEntries_X86 implements ImageRuntimeFunctionEntr */ public void markup(Program program) throws DuplicateNameException, IOException { - AbstractProgramLoader.markAsFunction(program, null, - program.getImageBase().add(beginAddress)); + if (beginAddress != 0 && !unwindInfo.hasChainedUnwindInfo()) { + AbstractProgramLoader.markAsFunction(program, null, + program.getImageBase().add(beginAddress)); + } if (unwindInfoAddressOrData > 0) { DataType dt = unwindInfo.toDataType(); diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/pe/resource/ResourceDirectoryEntry.java b/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/pe/resource/ResourceDirectoryEntry.java index 44bf48a9c4..ae726876ad 100644 --- a/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/pe/resource/ResourceDirectoryEntry.java +++ b/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/pe/resource/ResourceDirectoryEntry.java @@ -4,9 +4,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -161,8 +161,7 @@ public class ResourceDirectoryEntry implements StructConverter { } /** - * Returns true if the parent resource directory is named, - * false indicates an ID. + * {@return true if the parent resource directory is named; false indicates an ID} */ public boolean isNameEntry() { return isNameEntry; @@ -254,8 +253,14 @@ public class ResourceDirectoryEntry implements StructConverter { @Override public DataType toDataType() throws DuplicateNameException, IOException { StructureDataType nameStruct = new StructureDataType(NAME + "_" + "NameStruct", 0); - nameStruct.add(DWORD, "NameOffset", null); - nameStruct.add(DWORD, "NameIsString", null); + nameStruct.setPackingEnabled(true); + try { + nameStruct.addBitField(DWORD, 31, "NameOffset", null); + nameStruct.addBitField(DWORD, 1, "NameIsString", null); + } + catch (InvalidDataTypeException e) { + throw new IOException(e); + } nameStruct.setCategoryPath(new CategoryPath("/PE")); UnionDataType union1 = new UnionDataType(NAME + "_" + "NameUnion"); @@ -265,19 +270,25 @@ public class ResourceDirectoryEntry implements StructConverter { union1.setCategoryPath(new CategoryPath("/PE")); StructureDataType offsetStruct = new StructureDataType(NAME + "_" + "DirectoryStruct", 0); - offsetStruct.add(DWORD, "OffsetToDirectory", null); - offsetStruct.add(DWORD, "DataIsDirectory", null); + offsetStruct.setPackingEnabled(true); + try { + offsetStruct.addBitField(DWORD, 31, "OffsetToDirectory", null); + offsetStruct.addBitField(DWORD, 1, "DataIsDirectory", null); + } + catch (InvalidDataTypeException e) { + throw new IOException(e); + } UnionDataType union2 = new UnionDataType(NAME + "_" + "DirectoryUnion"); union2.add(DWORD, "OffsetToData", null); union2.add(offsetStruct, offsetStruct.getName(), null); - UnionDataType union3 = new UnionDataType(NAME); - union3.add(union1, "NameUnion", null); - union3.add(union2, "DirectoryUnion", null); + StructureDataType struct = new StructureDataType(NAME, 0); + struct.add(union1, "NameUnion", null); + struct.add(union2, "DirectoryUnion", null); - union3.setCategoryPath(new CategoryPath("/PE")); - return union3; + struct.setCategoryPath(new CategoryPath("/PE")); + return struct; } public boolean isValid() { diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/swift/types/AssociatedTypeDescriptor.java b/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/swift/types/AssociatedTypeDescriptor.java index 9e58826b14..d427895608 100644 --- a/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/swift/types/AssociatedTypeDescriptor.java +++ b/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/swift/types/AssociatedTypeDescriptor.java @@ -4,9 +4,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -28,7 +28,7 @@ import ghidra.util.exception.DuplicateNameException; /** * Represents a Swift AssociatedTypeDescriptor structure * - * @see swift/RemoteInspection/Records.h + * @see swift/RemoteInspection/Records.h */ public final class AssociatedTypeDescriptor extends SwiftTypeMetadataStructure { diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/swift/types/AssociatedTypeRecord.java b/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/swift/types/AssociatedTypeRecord.java index 83884ac47c..6caf9dcd45 100644 --- a/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/swift/types/AssociatedTypeRecord.java +++ b/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/swift/types/AssociatedTypeRecord.java @@ -4,9 +4,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -26,7 +26,7 @@ import ghidra.util.exception.DuplicateNameException; /** * Represents a Swift AssociatedTypeRecord structure * - * @see swift/RemoteInspection/Records.h + * @see swift/RemoteInspection/Records.h */ public final class AssociatedTypeRecord extends SwiftTypeMetadataStructure { diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/swift/types/BuiltinTypeDescriptor.java b/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/swift/types/BuiltinTypeDescriptor.java index 39e54f4711..22be07c157 100644 --- a/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/swift/types/BuiltinTypeDescriptor.java +++ b/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/swift/types/BuiltinTypeDescriptor.java @@ -4,9 +4,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -26,7 +26,7 @@ import ghidra.util.exception.DuplicateNameException; /** * Represents a Swift BuiltinTypeDescriptor structure * - * @see swift/RemoteInspection/Records.h + * @see swift/RemoteInspection/Records.h */ public final class BuiltinTypeDescriptor extends SwiftTypeMetadataStructure { diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/swift/types/CaptureDescriptor.java b/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/swift/types/CaptureDescriptor.java index 48aa442b2d..94f26ed6a5 100644 --- a/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/swift/types/CaptureDescriptor.java +++ b/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/swift/types/CaptureDescriptor.java @@ -4,9 +4,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -27,7 +27,7 @@ import ghidra.util.exception.DuplicateNameException; /** * Represents a Swift CaptureDescriptor structure * - * @see swift/RemoteInspection/Records.h + * @see swift/RemoteInspection/Records.h */ public final class CaptureDescriptor extends SwiftTypeMetadataStructure { diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/swift/types/CaptureTypeRecord.java b/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/swift/types/CaptureTypeRecord.java index 8b27f0b27b..691c6087d3 100644 --- a/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/swift/types/CaptureTypeRecord.java +++ b/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/swift/types/CaptureTypeRecord.java @@ -4,9 +4,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -26,7 +26,7 @@ import ghidra.util.exception.DuplicateNameException; /** * Represents a Swift CaptureTypeRecord structure * - * @see swift/RemoteInspection/Records.h + * @see swift/RemoteInspection/Records.h */ public final class CaptureTypeRecord extends SwiftTypeMetadataStructure { diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/swift/types/ContextDescriptorKind.java b/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/swift/types/ContextDescriptorKind.java index 48faf502c2..fb1d6a6f1c 100644 --- a/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/swift/types/ContextDescriptorKind.java +++ b/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/swift/types/ContextDescriptorKind.java @@ -4,9 +4,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -18,7 +18,7 @@ package ghidra.app.util.bin.format.swift.types; /** * Swift ContextDescriptorKind values * - * @see swift/ABI/MetadataValues.h + * @see swift/ABI/MetadataValues.h */ public class ContextDescriptorKind { diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/swift/types/FieldDescriptor.java b/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/swift/types/FieldDescriptor.java index 07d0726ec4..4bcc322a4f 100644 --- a/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/swift/types/FieldDescriptor.java +++ b/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/swift/types/FieldDescriptor.java @@ -4,9 +4,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -28,7 +28,7 @@ import ghidra.util.exception.DuplicateNameException; /** * Represents a Swift FieldDescriptor structure * - * @see swift/RemoteInspection/Records.h + * @see swift/RemoteInspection/Records.h */ public final class FieldDescriptor extends SwiftTypeMetadataStructure { diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/swift/types/FieldRecord.java b/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/swift/types/FieldRecord.java index 087f82448d..1ede69ed6d 100644 --- a/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/swift/types/FieldRecord.java +++ b/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/swift/types/FieldRecord.java @@ -4,9 +4,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -26,7 +26,7 @@ import ghidra.util.exception.DuplicateNameException; /** * Represents a Swift FieldRecord structure * - * @see swift/RemoteInspection/Records.h + * @see swift/RemoteInspection/Records.h */ public final class FieldRecord extends SwiftTypeMetadataStructure { diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/swift/types/MetadataSourceRecord.java b/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/swift/types/MetadataSourceRecord.java index 5f5f995b74..ca9e40840d 100644 --- a/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/swift/types/MetadataSourceRecord.java +++ b/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/swift/types/MetadataSourceRecord.java @@ -4,9 +4,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -26,7 +26,7 @@ import ghidra.util.exception.DuplicateNameException; /** * Represents a Swift MetadataSourceRecord structure * - * @see swift/RemoteInspection/Records.h + * @see swift/RemoteInspection/Records.h */ public final class MetadataSourceRecord extends SwiftTypeMetadataStructure { diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/swift/types/MultiPayloadEnumDescriptor.java b/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/swift/types/MultiPayloadEnumDescriptor.java index ddf68f32f7..b2ce21a104 100644 --- a/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/swift/types/MultiPayloadEnumDescriptor.java +++ b/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/swift/types/MultiPayloadEnumDescriptor.java @@ -4,9 +4,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -26,7 +26,7 @@ import ghidra.util.exception.DuplicateNameException; /** * Represents a Swift MultiPayloadEnumDescriptor structure * - * @see swift/RemoteInspection/Records.h + * @see swift/RemoteInspection/Records.h */ public final class MultiPayloadEnumDescriptor extends SwiftTypeMetadataStructure { diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/swift/types/TargetClassDescriptor.java b/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/swift/types/TargetClassDescriptor.java index 0c69fd2b6d..ab18678c00 100644 --- a/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/swift/types/TargetClassDescriptor.java +++ b/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/swift/types/TargetClassDescriptor.java @@ -4,9 +4,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -25,7 +25,7 @@ import ghidra.util.exception.DuplicateNameException; /** * Represents a Swift TargetClassDescriptor structure * - * @see swift/ABI/Metadata.h + * @see swift/ABI/Metadata.h */ public final class TargetClassDescriptor extends TargetTypeContextDescriptor { diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/swift/types/TargetContextDescriptor.java b/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/swift/types/TargetContextDescriptor.java index 7cd26a242b..8379642bc6 100644 --- a/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/swift/types/TargetContextDescriptor.java +++ b/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/swift/types/TargetContextDescriptor.java @@ -4,9 +4,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -26,7 +26,7 @@ import ghidra.util.exception.DuplicateNameException; /** * Represents a Swift TargetContextDescriptor structure * - * @see swift/ABI/Metadata.h + * @see swift/ABI/Metadata.h */ public class TargetContextDescriptor extends SwiftTypeMetadataStructure { diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/swift/types/TargetEnumDescriptor.java b/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/swift/types/TargetEnumDescriptor.java index 3b3b3f71ec..4301205ab6 100644 --- a/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/swift/types/TargetEnumDescriptor.java +++ b/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/swift/types/TargetEnumDescriptor.java @@ -4,9 +4,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -26,7 +26,7 @@ import ghidra.util.exception.DuplicateNameException; /** * Represents a Swift TargetEnumDescriptor structure * - * @see swift/ABI/Metadata.h + * @see swift/ABI/Metadata.h */ public final class TargetEnumDescriptor extends TargetTypeContextDescriptor { diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/swift/types/TargetProtocolConformanceDescriptor.java b/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/swift/types/TargetProtocolConformanceDescriptor.java index f4d183a539..95edd606f9 100644 --- a/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/swift/types/TargetProtocolConformanceDescriptor.java +++ b/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/swift/types/TargetProtocolConformanceDescriptor.java @@ -4,9 +4,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -26,7 +26,7 @@ import ghidra.util.exception.DuplicateNameException; /** * Represents a Swift TargetProtocolConformanceDescriptor structure * - * @see swift/ABI/Metadata.h + * @see swift/ABI/Metadata.h */ public final class TargetProtocolConformanceDescriptor extends SwiftTypeMetadataStructure { diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/swift/types/TargetProtocolDescriptor.java b/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/swift/types/TargetProtocolDescriptor.java index 3aa6ce1c07..eac949ff82 100644 --- a/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/swift/types/TargetProtocolDescriptor.java +++ b/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/swift/types/TargetProtocolDescriptor.java @@ -4,9 +4,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -27,7 +27,7 @@ import ghidra.util.exception.DuplicateNameException; /** * Represents a Swift TargetProtocolDescriptor structure * - * @see swift/ABI/Metadata.h + * @see swift/ABI/Metadata.h */ public final class TargetProtocolDescriptor extends TargetContextDescriptor { diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/swift/types/TargetStructDescriptor.java b/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/swift/types/TargetStructDescriptor.java index 092bd49739..80ed197d5a 100644 --- a/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/swift/types/TargetStructDescriptor.java +++ b/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/swift/types/TargetStructDescriptor.java @@ -4,9 +4,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -26,7 +26,7 @@ import ghidra.util.exception.DuplicateNameException; /** * Represents a Swift TargetStructDescriptor structure * - * @see swift/ABI/Metadata.h + * @see swift/ABI/Metadata.h */ public final class TargetStructDescriptor extends TargetTypeContextDescriptor { diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/swift/types/TargetTypeContextDescriptor.java b/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/swift/types/TargetTypeContextDescriptor.java index d0640f974d..bfd551c5be 100644 --- a/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/swift/types/TargetTypeContextDescriptor.java +++ b/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/swift/types/TargetTypeContextDescriptor.java @@ -4,9 +4,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -26,7 +26,7 @@ import ghidra.util.exception.DuplicateNameException; /** * Represents a Swift TargetTypeContextDescriptor structure * - * @see swift/ABI/Metadata.h + * @see swift/ABI/Metadata.h */ public class TargetTypeContextDescriptor extends TargetContextDescriptor { diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/util/exporter/IntelHexExporter.java b/Ghidra/Features/Base/src/main/java/ghidra/app/util/exporter/IntelHexExporter.java index 9db2f3fc2d..1076f4f7df 100644 --- a/Ghidra/Features/Base/src/main/java/ghidra/app/util/exporter/IntelHexExporter.java +++ b/Ghidra/Features/Base/src/main/java/ghidra/app/util/exporter/IntelHexExporter.java @@ -4,9 +4,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -150,15 +150,10 @@ public class IntelHexExporter extends Exporter { log.clear(); - if (!(domainObj instanceof Program)) { + if (!(domainObj instanceof Program program)) { log.appendMsg("Unsupported type: " + domainObj.getClass().getName()); return false; } - Program program = (Program) domainObj; - if (program.getMaxAddress().getSize() > 32) { - log.appendMsg("Cannot be used for programs larger than 32 bits"); - return false; - } if (addressSpaceOption == null || recordSizeOption == null) { getOptions(() -> program); @@ -168,12 +163,23 @@ public class IntelHexExporter extends Exporter { Memory memory = program.getMemory(); - if (addrSet == null) { - addrSet = memory; + AddressSet set = new AddressSet(addrSet != null ? addrSet : memory); + + for (MemoryBlock block : memory.getBlocks()) { + if (!block.isInitialized() || + block.getStart().getAddressSpace() != addressSpaceOption.getValue()) { + set.delete(new AddressRangeImpl(block.getStart(), block.getEnd())); + } + } + + Address maxAddr = set.getMaxAddress(); + if (maxAddr != null && maxAddr.getSize() > 32) { + log.appendMsg("Cannot be used for address spaces larger than 32 bits"); + return false; } try { - List records = dumpMemory(program, memory, addrSet, monitor); + List records = dumpMemory(program, memory, set, monitor); for (IntelHexRecord record : records) { writer.println(record.format()); } @@ -198,17 +204,7 @@ public class IntelHexExporter extends Exporter { IntelHexRecordWriter writer = new IntelHexRecordWriter(size, dropBytes); - AddressSet set = new AddressSet(addrSetView); - - MemoryBlock[] blocks = memory.getBlocks(); - for (MemoryBlock block : blocks) { - if (!block.isInitialized() || - block.getStart().getAddressSpace() != addressSpaceOption.getValue()) { - set.delete(new AddressRangeImpl(block.getStart(), block.getEnd())); - } - } - - AddressIterator addresses = set.getAddresses(true); + AddressIterator addresses = addrSetView.getAddresses(true); while (addresses.hasNext()) { Address address = addresses.next(); byte b = memory.getByte(address); @@ -220,7 +216,7 @@ public class IntelHexExporter extends Exporter { program.getSymbolTable().getExternalEntryPointIterator(); while (entryPoint == null && entryPointIterator.hasNext()) { Address address = entryPointIterator.next(); - if (set.contains(address)) { + if (addrSetView.contains(address)) { entryPoint = address; } } diff --git a/Ghidra/Features/Decompiler/src/decompile/cpp/block.cc b/Ghidra/Features/Decompiler/src/decompile/cpp/block.cc index a4b2029d3c..bf7103d916 100644 --- a/Ghidra/Features/Decompiler/src/decompile/cpp/block.cc +++ b/Ghidra/Features/Decompiler/src/decompile/cpp/block.cc @@ -638,6 +638,17 @@ JumpTable *FlowBlock::getJumptable(void) const return jt; } +/// Print a single unique identifier for \b this block +/// \param s is the output stream +void FlowBlock::printShortHeader(ostream &s) const + +{ + s << "Block_" << dec << index; + if (!getStart().isInvalid()) { + s << ':' << getStart(); + } +} + /// Given a string describing a FlowBlock type, return the block_type. /// This is currently only used by the decode() process. /// TODO: Fill in the remaining names and types @@ -1293,8 +1304,24 @@ void BlockGraph::printRaw(ostream &s) const printHeader(s); s << endl; - for(iter=list.begin();iter!=list.end();++iter) - (*iter)->printRaw(s); + if (list.empty()) return; + iter = list.begin(); + FlowBlock *lastBl = *iter; + ++iter; + lastBl->printRaw(s); + for(;iter!=list.end();++iter) { + FlowBlock *curBl = *iter; + lastBl->printRawImpliedGoto(s, curBl); + curBl->printRaw(s); + lastBl = curBl; + } +} + +void BlockGraph::printRawImpliedGoto(ostream &s,const FlowBlock *nextBlock) const + +{ + if (list.empty()) return; + list.back()->printRawImpliedGoto(s, nextBlock); } PcodeOp *BlockGraph::firstOp(void) const @@ -2658,6 +2685,24 @@ void BlockBasic::printRaw(ostream &s) const } } +void BlockBasic::printRawImpliedGoto(ostream &s,const FlowBlock *nextBlock) const + +{ + if (sizeOut() != 1) return; + const FlowBlock *outBlock = getOut(0); + if (nextBlock->getType() != t_basic) { + nextBlock = nextBlock->getFrontLeaf(); + if (nextBlock == (const FlowBlock *)0) return; + nextBlock = nextBlock->subBlock(0); + } + if (getOut(0) == nextBlock) return; + if (!op.empty() && op.back()->isBranch()) return; + getStop().printRaw(s); + s << ": \t[ goto "; + outBlock->printShortHeader(s); + s << " ]" << endl; +} + /// \brief Check for values created in \b this block that flow outside the block. /// /// The block can calculate a value for a BRANCHIND or CBRANCH and can copy values and this method will still diff --git a/Ghidra/Features/Decompiler/src/decompile/cpp/block.hh b/Ghidra/Features/Decompiler/src/decompile/cpp/block.hh index 1b3146ed2b..8319d83b9a 100644 --- a/Ghidra/Features/Decompiler/src/decompile/cpp/block.hh +++ b/Ghidra/Features/Decompiler/src/decompile/cpp/block.hh @@ -210,6 +210,14 @@ public: /// \param s is the given stream to write to virtual void printRaw(ostream &s) const {} + /// \brief If the \e out block of \b this is not the given next block, print an implied \b goto to the out block + /// + /// In order to see where \b this block is flowing to, if there is no explicit branch op, and if the next block + /// being printed is \e not the fallthru branch, print the destination block as an implied \b goto op. + /// \param s is the output stream + /// \param nextBlock is the given nextBlock being printed + virtual void printRawImpliedGoto(ostream &s,const FlowBlock *nextBlock) const {} + virtual void emit(PrintLanguage *lng) const; ///emitBlockGraph(this); } virtual PcodeOp *firstOp(void) const; virtual FlowBlock *nextFlowAfter(const FlowBlock *bl) const; @@ -473,6 +483,7 @@ public: virtual void decodeBody(Decoder &decoder); virtual void printHeader(ostream &s) const; virtual void printRaw(ostream &s) const; + virtual void printRawImpliedGoto(ostream &s,const FlowBlock *nextBlock) const; virtual void emit(PrintLanguage *lng) const { lng->emitBlockBasic(this); } virtual const FlowBlock *getExitLeaf(void) const { return this; } virtual PcodeOp *firstOp(void) const; @@ -515,6 +526,7 @@ public: virtual void printHeader(ostream &s) const; virtual void printTree(ostream &s,int4 level) const; virtual void printRaw(ostream &s) const { copy->printRaw(s); } + virtual void printRawImpliedGoto(ostream &s,const FlowBlock *nextBlock) const { copy->printRawImpliedGoto(s, nextBlock); } virtual void emit(PrintLanguage *lng) const { lng->emitBlockCopy(this); } virtual const FlowBlock *getExitLeaf(void) const { return this; } virtual PcodeOp *firstOp(void) const { return copy->firstOp(); } diff --git a/Ghidra/Features/Decompiler/src/decompile/cpp/blockaction.cc b/Ghidra/Features/Decompiler/src/decompile/cpp/blockaction.cc index 56fcd00b48..c8acd865d3 100644 --- a/Ghidra/Features/Decompiler/src/decompile/cpp/blockaction.cc +++ b/Ghidra/Features/Decompiler/src/decompile/cpp/blockaction.cc @@ -2074,18 +2074,10 @@ bool ConditionalJoin::match(BlockBasic *b1,BlockBasic *b2) exita = (BlockBasic *)block1->getOut(0); exitb = (BlockBasic *)block1->getOut(1); if (exita == exitb) return false; - if (block2->getOut(0) == exita) { - if (block2->getOut(1) != exitb) return false; - a_in2 = block2->getOutRevIndex(0); - b_in2 = block2->getOutRevIndex(1); - } - else if (block2->getOut(0) == exitb) { - if (block2->getOut(1) != exita) return false; - a_in2 = block2->getOutRevIndex(1); - b_in2 = block2->getOutRevIndex(0); - } - else - return false; + if (block2->getOut(0) != exita) return false; // False exits must match + if (block2->getOut(1) != exitb) return false; // True exits must match + a_in2 = block2->getOutRevIndex(0); + b_in2 = block2->getOutRevIndex(1); a_in1 = block1->getOutRevIndex(0); b_in1 = block1->getOutRevIndex(1); diff --git a/Ghidra/Features/Decompiler/src/decompile/cpp/coreaction.cc b/Ghidra/Features/Decompiler/src/decompile/cpp/coreaction.cc index c76121c410..2d0a90edb8 100644 --- a/Ghidra/Features/Decompiler/src/decompile/cpp/coreaction.cc +++ b/Ghidra/Features/Decompiler/src/decompile/cpp/coreaction.cc @@ -2169,8 +2169,19 @@ int4 ActionLikelyTrash::apply(Funcdata &data) return 0; } +/// \param vn is the given Varnode +/// \return \b true if it is a constant or a COPY of a constant +bool ActionRestructureVarnode::isCopyConstant(Varnode *vn) + +{ + if (vn->isConstant()) return true; + if (!vn->isWritten()) return false; + if (vn->getDef()->code() != CPUI_COPY) return false; + return vn->getDef()->getIn(0)->isConstant(); +} + /// Return \b true if either the Varnode is a constant or if it is the not yet simplified -/// INT_ADD of constants. +/// COPY or INT_ADD of constants. /// \param vn is the given Varnode to test /// \return \b true if the Varnode will be a constant bool ActionRestructureVarnode::isDelayedConstant(Varnode *vn) @@ -2179,14 +2190,13 @@ bool ActionRestructureVarnode::isDelayedConstant(Varnode *vn) if (vn->isConstant()) return true; if (!vn->isWritten()) return false; PcodeOp *op = vn->getDef(); - if (op->code() != CPUI_INT_ADD) return false; - if (!op->getIn(1)->isConstant()) return false; - Varnode *cvn = op->getIn(0); - if (cvn->isConstant()) return true; - if (!cvn->isWritten()) return false; - PcodeOp *copy = cvn->getDef(); - if (copy->code() != CPUI_COPY) return false; - return copy->getIn(0)->isConstant(); + OpCode opc = op->code(); + if (opc == CPUI_COPY) + return op->getIn(0)->isConstant(); + if (opc != CPUI_INT_ADD) return false; + if (!isCopyConstant(op->getIn(1))) return false; + if (!isCopyConstant(op->getIn(0))) return false; + return true; } /// Test if the path to the given BRANCHIND originates from a constant but passes through INDIRECT operations. @@ -5349,7 +5359,7 @@ void ActionDatabase::buildDefaultGroups(void) setGroup("decompile",members); const char *jumptab[] = { "base", "noproto", "localrecovery", "deadcode", "stackptrflow", - "stackvars", "analysis", "segment", "subvar", "conditionalexe", "" }; + "stackvars", "analysis", "segment", "subvar", "normalizebranches", "conditionalexe", "" }; setGroup("jumptable",jumptab); const char *normali[] = { "base", "protorecovery", "protorecovery_b", "deindirect", "localrecovery", diff --git a/Ghidra/Features/Decompiler/src/decompile/cpp/coreaction.hh b/Ghidra/Features/Decompiler/src/decompile/cpp/coreaction.hh index 3c6ac0fa4c..19a1be62b5 100644 --- a/Ghidra/Features/Decompiler/src/decompile/cpp/coreaction.hh +++ b/Ghidra/Features/Decompiler/src/decompile/cpp/coreaction.hh @@ -4,9 +4,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -831,6 +831,7 @@ public: /// This produces on intermediate view of symbols on the stack. class ActionRestructureVarnode : public Action { int4 numpass; ///< Number of passes performed for this function + static bool isCopyConstant(Varnode *vn); ///< Is the given Varnode a constant or a COPY of a constant static bool isDelayedConstant(Varnode *vn); ///< Determine if given Varnode is or will be a constant static void protectSwitchPathIndirects(PcodeOp *op); ///< Protect path to the given switch from INDIRECT collapse static void protectSwitchPaths(Funcdata &data); ///< Look for switches and protect path of switch variable diff --git a/Ghidra/Features/Decompiler/src/decompile/cpp/jumptable.cc b/Ghidra/Features/Decompiler/src/decompile/cpp/jumptable.cc index 860a07a594..ba71812299 100644 --- a/Ghidra/Features/Decompiler/src/decompile/cpp/jumptable.cc +++ b/Ghidra/Features/Decompiler/src/decompile/cpp/jumptable.cc @@ -1284,6 +1284,18 @@ bool JumpBasic::flowsOnlyToModel(Varnode *vn,PcodeOp *trailOp) return true; } +/// \param arr is the array of Varnodes +/// \return \b true if all elements are the same +bool JumpBasic::duplicateVarnodes(const vector &arr) + +{ + Varnode *vn = arr[0]; + for(int4 i=1;igetIn(0)->getFlipPath() ? 1-indpath : indpath; PcodeOp *readOp = cbranch; for(int4 j=0;jfindMultiequal(varArray); - if (multiOp != (PcodeOp *)0) { - selectguards.push_back(GuardRecord(cbranch,readOp,indpathstore,rng,multiOp->getOut(),true)); + if (duplicateVarnodes(varArray)) { + selectguards.push_back(GuardRecord(cbranch,readOp,indpathstore,rng,varArray[0],true)); + } + else { + PcodeOp *multiOp = bl->findMultiequal(varArray); + if (multiOp != (PcodeOp *)0) { + selectguards.push_back(GuardRecord(cbranch,readOp,indpathstore,rng,multiOp->getOut(),true)); + } } Varnode *markup; // Throw away markup information Varnode *vn = varArray[0]; diff --git a/Ghidra/Features/Decompiler/src/decompile/cpp/jumptable.hh b/Ghidra/Features/Decompiler/src/decompile/cpp/jumptable.hh index eb6e1d7d11..2b1b121258 100644 --- a/Ghidra/Features/Decompiler/src/decompile/cpp/jumptable.hh +++ b/Ghidra/Features/Decompiler/src/decompile/cpp/jumptable.hh @@ -382,6 +382,7 @@ protected: static int4 getStride(Varnode *vn); ///< Get the step/stride associated with the Varnode static uintb backup2Switch(Funcdata *fd,uintb output,Varnode *outvn,Varnode *invn); static uintb getMaxValue(Varnode *vn); ///< Get maximum value associated with the given Varnode + static bool duplicateVarnodes(const vector &arr); ///< Return \b true if all array elements are the same Varnode void findDeterminingVarnodes(PcodeOp *op,int4 slot); void analyzeGuards(BlockBasic *bl,int4 pathout); void calcRange(Varnode *vn,CircleRange &rng) const; diff --git a/Ghidra/Features/Decompiler/src/decompile/cpp/typeop.cc b/Ghidra/Features/Decompiler/src/decompile/cpp/typeop.cc index d8350e28b1..bb12d46769 100644 --- a/Ghidra/Features/Decompiler/src/decompile/cpp/typeop.cc +++ b/Ghidra/Features/Decompiler/src/decompile/cpp/typeop.cc @@ -591,7 +591,12 @@ void TypeOpBranch::printRaw(ostream &s,const PcodeOp *op) { s << name << ' '; - Varnode::printRaw(s,op->getIn(0)); + const BlockBasic *parent = op->getParent(); + if (parent != (const BlockBasic *)0 && parent->sizeOut() == 1) { + parent->getOut(0)->printShortHeader(s); + } + else + Varnode::printRaw(s,op->getIn(0)); } TypeOpCbranch::TypeOpCbranch(TypeFactory *t) : TypeOp(t,CPUI_CBRANCH,"goto") @@ -617,13 +622,25 @@ void TypeOpCbranch::printRaw(ostream &s,const PcodeOp *op) { s << name << ' '; - Varnode::printRaw(s,op->getIn(0)); // Print the distant (non-fallthru) destination + const BlockBasic *parent = op->getParent(); + FlowBlock *falseOut = (FlowBlock *)0; + if (parent != (const BlockBasic *)0 && parent->sizeOut() == 2) { + FlowBlock *trueOut = parent->getTrueOut(); + falseOut = parent->getFalseOut(); + trueOut->printShortHeader(s); + } + else + Varnode::printRaw(s,op->getIn(0)); // Print the distant (non-fallthru) destination s << " if ("; Varnode::printRaw(s,op->getIn(1)); - if (op->isBooleanFlip()^op->isFallthruTrue()) + if (op->isBooleanFlip()) s << " == 0)"; else s << " != 0)"; + if (falseOut != (FlowBlock *)0) { + s << " else "; + falseOut->printShortHeader(s); + } } TypeOpBranchind::TypeOpBranchind(TypeFactory *t) : TypeOp(t,CPUI_BRANCHIND,"switch") diff --git a/Ghidra/Features/Decompiler/src/main/java/ghidra/app/decompiler/component/DecompilerPanel.java b/Ghidra/Features/Decompiler/src/main/java/ghidra/app/decompiler/component/DecompilerPanel.java index 9f8101bc2a..0b470332fa 100644 --- a/Ghidra/Features/Decompiler/src/main/java/ghidra/app/decompiler/component/DecompilerPanel.java +++ b/Ghidra/Features/Decompiler/src/main/java/ghidra/app/decompiler/component/DecompilerPanel.java @@ -1047,7 +1047,7 @@ public class DecompilerPanel extends JPanel implements FieldMouseListener, Field } HighSymbol highSymbol = highVar.getSymbol(); - if (highSymbol.isParameter()) { + if (highSymbol != null && highSymbol.isParameter()) { // decomp param that is not in the listing; put on signature return new FunctionNameDecompilerLocation(program, entryPoint, cvt.getText(), info); } diff --git a/Ghidra/Features/Decompiler/src/main/java/ghidra/app/plugin/core/analysis/DecompilerSwitchAnalyzer.java b/Ghidra/Features/Decompiler/src/main/java/ghidra/app/plugin/core/analysis/DecompilerSwitchAnalyzer.java index 85673203a0..48f44d5e0b 100644 --- a/Ghidra/Features/Decompiler/src/main/java/ghidra/app/plugin/core/analysis/DecompilerSwitchAnalyzer.java +++ b/Ghidra/Features/Decompiler/src/main/java/ghidra/app/plugin/core/analysis/DecompilerSwitchAnalyzer.java @@ -57,7 +57,7 @@ public class DecompilerSwitchAnalyzer extends AbstractAnalyzer { // cache for pcode callother injection payloads private HashMap injectPayloadCache = new HashMap<>(); - private boolean hitNonReturningFunction = false; + private boolean hitNonReturningThunkFunction = false; //================================================================================================== @@ -103,12 +103,12 @@ public class DecompilerSwitchAnalyzer extends AbstractAnalyzer { return true; } - List definedFunctions = new ArrayList<>(); - List undefinedFunctions = new ArrayList<>(); + Collection definedFunctions = new HashSet<>(); + Collection undefinedFunctions = new HashSet<>(); findFunctions(program, locations, definedFunctions, undefinedFunctions, monitor); - if (hitNonReturningFunction) { - hitNonReturningFunction = false; + if (hitNonReturningThunkFunction) { + hitNonReturningThunkFunction = false; // if hit a non-returning function, code needs to be fixed up // before wasting time on analyzing potentially bad code // This will also clean out locations that were thunks for the next go round. @@ -209,8 +209,9 @@ public class DecompilerSwitchAnalyzer extends AbstractAnalyzer { } // kids, don't do thunks if (function.isThunk()) { + // unless they are non-returning if (function.hasNoReturn()) { - hitNonReturningFunction = true; + hitNonReturningThunkFunction = true; } continue; } @@ -428,7 +429,7 @@ public class DecompilerSwitchAnalyzer extends AbstractAnalyzer { program.getFunctionManager().getFunctionContaining(location); if (fixupFunc != null) { CreateFunctionCmd.fixupFunctionBody(program, fixupFunc, monitor); - // send function back, so non-returning nature will be picked up by decompiler + // send function back, so non-returning nature will be picked up if (fixupFunc.hasNoReturn()) { return fixupFunc; } diff --git a/Ghidra/Features/DecompilerDependent/src/main/java/ghidra/app/extension/datatype/finder/DecompilerDataTypeReferenceFinder.java b/Ghidra/Features/DecompilerDependent/src/main/java/ghidra/app/extension/datatype/finder/DecompilerDataTypeReferenceFinder.java index b3de9e39ed..e583baae85 100644 --- a/Ghidra/Features/DecompilerDependent/src/main/java/ghidra/app/extension/datatype/finder/DecompilerDataTypeReferenceFinder.java +++ b/Ghidra/Features/DecompilerDependent/src/main/java/ghidra/app/extension/datatype/finder/DecompilerDataTypeReferenceFinder.java @@ -4,9 +4,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -130,7 +130,7 @@ public class DecompilerDataTypeReferenceFinder implements DataTypeReferenceFinde } results.addAll(callers); - + // Add any callers to external function that use any form of the data type it = listing.getExternalFunctions(); callers = new HashSet<>(); @@ -142,7 +142,7 @@ public class DecompilerDataTypeReferenceFinder implements DataTypeReferenceFinde callers.addAll(callingFunctions); } } - + results.addAll(callers); return results; @@ -298,16 +298,12 @@ public class DecompilerDataTypeReferenceFinder implements DataTypeReferenceFinde private DataType dataType; private FieldMatcher fieldMatcher; - private String dbgPrefix; - DecompilerDataTypeFinder(DecompileResults results, Function function, DataType dataType, FieldMatcher fieldMatcher) { this.decompilation = results; this.function = function; this.dataType = dataType; this.fieldMatcher = fieldMatcher; - - this.dbgPrefix = "f: " + function + "\n\t"; } List findUsage() { @@ -331,16 +327,16 @@ public class DecompilerDataTypeReferenceFinder implements DataTypeReferenceFinde return; } - DtrfDbg.println(dbgPrefix + "checking vars..."); + DtrfDbg.println(function, "checking vars..."); List variables = findVariableReferences(tokens); - DtrfDbg.println(dbgPrefix + "DONE searching decompilation\nMatching results"); + DtrfDbg.println(function, "DONE searching decompilation\nMatching results"); variables.forEach(v -> matchUsage(v, results)); } /** Finds any search input match in the given reference */ private void matchUsage(DecompilerReference reference, List results) { - DtrfDbg.println("Checking " + reference); + DtrfDbg.println(function, "Checking " + reference); reference.accumulateMatches(dataType, fieldMatcher, results); } @@ -388,12 +384,12 @@ public class DecompilerDataTypeReferenceFinder implements DataTypeReferenceFinde VariableAccessDR access = null; for (ClangToken token : filteredTokens) { - DtrfDbg.println(dbgPrefix + "checking token: " + token); + DtrfDbg.println(function, "checking token: " + token); if (token instanceof ClangTypeToken) { if (token.Parent() instanceof ClangReturnType) { - DtrfDbg.println(dbgPrefix + "\treturn type: " + line); + DtrfDbg.println(function, "\treturn type: " + line); results.add(new ReturnTypeDR(line, (ClangTypeToken) token)); } @@ -401,13 +397,13 @@ public class DecompilerDataTypeReferenceFinder implements DataTypeReferenceFinde // Note: variable refs will get their variable in an upcoming token if (isFunctionPrototype(token.Parent())) { - DtrfDbg.println(dbgPrefix + "\tparameter: " + line); + DtrfDbg.println(function, "\tparameter: " + line); declaration = new ParameterDR(line, (ClangTypeToken) token); } else { - DtrfDbg.println(dbgPrefix + "\tlocal var: " + line); + DtrfDbg.println(function, "\tlocal var: " + line); declaration = new LocalVariableDR(line, (ClangTypeToken) token); } @@ -416,7 +412,7 @@ public class DecompilerDataTypeReferenceFinder implements DataTypeReferenceFinde } else { - DtrfDbg.println(dbgPrefix + "\tadding a cast"); + DtrfDbg.println(function, "\tadding a cast"); // Assumption: this is a cast inside of a ClangStatement // Assumption: there can be multiple casts concatenated @@ -438,7 +434,7 @@ public class DecompilerDataTypeReferenceFinder implements DataTypeReferenceFinde // if (declaration != null) { - DtrfDbg.println(dbgPrefix + "\thave declaration - " + declaration); + DtrfDbg.println(function, "\thave declaration - " + declaration); declaration.setVariable((ClangVariableToken) token); declaration = null; @@ -446,7 +442,7 @@ public class DecompilerDataTypeReferenceFinder implements DataTypeReferenceFinde else { if (access == null || access.getVariable() != null) { - DtrfDbg.println(dbgPrefix + "\tcreating variable access: " + line); + DtrfDbg.println(function, "\tcreating variable access: " + line); access = new VariableAccessDR(line); results.add(access); @@ -479,8 +475,8 @@ public class DecompilerDataTypeReferenceFinder implements DataTypeReferenceFinde ClangFieldToken field = (ClangFieldToken) token; if (typesDoNotMatch(access, field)) { - DtrfDbg.println( - dbgPrefix + "\tcreating an anonymous variable access: " + line); + DtrfDbg.println(function, + "\tcreating an anonymous variable access: " + line); // this can happen when a field is used anonymously, such as directly // after a nested array index operation diff --git a/Ghidra/Features/DecompilerDependent/src/main/java/ghidra/app/extension/datatype/finder/DtrfDbg.java b/Ghidra/Features/DecompilerDependent/src/main/java/ghidra/app/extension/datatype/finder/DtrfDbg.java index 199bb656f6..5ab56184ce 100644 --- a/Ghidra/Features/DecompilerDependent/src/main/java/ghidra/app/extension/datatype/finder/DtrfDbg.java +++ b/Ghidra/Features/DecompilerDependent/src/main/java/ghidra/app/extension/datatype/finder/DtrfDbg.java @@ -4,9 +4,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -18,10 +18,12 @@ package ghidra.app.extension.datatype.finder; import java.io.ByteArrayOutputStream; import java.io.PrintWriter; import java.util.*; +import java.util.Map.Entry; import org.apache.commons.lang3.StringUtils; import generic.io.NullPrintWriter; +import ghidra.program.model.listing.Function; import ghidra.util.Msg; /** @@ -36,6 +38,8 @@ class DtrfDbg { private static List clientFilters = new ArrayList<>(); + private static Map> linesByFunction = new HashMap<>(); + DtrfDbg() { // static class } @@ -57,6 +61,16 @@ class DtrfDbg { return; } + Set>> entries = linesByFunction.entrySet(); + for (Entry> entry : entries) { + Function function = entry.getKey(); + List lines = entry.getValue(); + debugWriter.println("\n\nFunction Debug: " + function.getName()); + for (String line : lines) { + debugWriter.println(line); + } + } + debugWriter.flush(); String output = debugBytes.toString(); if (!StringUtils.isBlank(output)) { @@ -76,16 +90,16 @@ class DtrfDbg { clientFilters.addAll(Arrays.asList(filters)); } - static void println(String s) { - debugWriter.println(s); + static void println(Function f, String s) { + linesByFunction.computeIfAbsent(f, ff -> new ArrayList<>()).add(s); } - static void println(Object client, String s) { + static void println(Function f, Object client, String s) { if (!passesFilter(client)) { return; } - debugWriter.println(s); + linesByFunction.computeIfAbsent(f, ff -> new ArrayList<>()).add(s); } private static boolean passesFilter(Object client) { diff --git a/Ghidra/Features/DecompilerDependent/src/main/java/ghidra/app/extension/datatype/finder/VariableAccessDR.java b/Ghidra/Features/DecompilerDependent/src/main/java/ghidra/app/extension/datatype/finder/VariableAccessDR.java index cb62fd64d2..a2ba9307a9 100644 --- a/Ghidra/Features/DecompilerDependent/src/main/java/ghidra/app/extension/datatype/finder/VariableAccessDR.java +++ b/Ghidra/Features/DecompilerDependent/src/main/java/ghidra/app/extension/datatype/finder/VariableAccessDR.java @@ -4,9 +4,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -25,7 +25,6 @@ import ghidra.app.services.FieldMatcher; import ghidra.program.model.address.Address; import ghidra.program.model.data.DataType; import ghidra.program.model.listing.Function; -import ghidra.program.model.pcode.HighGlobal; import ghidra.program.model.pcode.HighVariable; import ghidra.util.StringUtilities; import ghidra.util.exception.AssertException; @@ -106,7 +105,7 @@ public class VariableAccessDR extends DecompilerReference { private DecompilerVariable getMatch(DataType dt, FieldMatcher fieldMatcher, DecompilerVariable var, DecompilerVariable potentialField) { - String indent = "\t\t"; + String indent = "\t\t\t"; // Note: for now, I ignore the precedence of casting; if any cast type is a match, then // signal hooray @@ -114,19 +113,21 @@ public class VariableAccessDR extends DecompilerReference { DecompilerVariable fieldVar = searchForField ? potentialField : null; DecompilerVariable match = getMatchingVarialbe(dt, var, fieldVar); if (match == null) { - DtrfDbg.println(this, indent + "NO MATCHING VARIABLE"); + DtrfDbg.println(getFunction(), this, indent + "NO MATCHING VARIABLE"); return null; // wrong type, nothing to do } // Matches on the type, does the field match? if (fieldMatcher.isIgnored()) { - DtrfDbg.println(this, indent + "field macher is ignored; returning match"); + DtrfDbg.println(getFunction(), this, + indent + "field macher is ignored; returning match"); return match; // no field to match } if (potentialField == null) { - DtrfDbg.println(this, indent + "No potential field to match; name / offset match?"); + DtrfDbg.println(getFunction(), this, + indent + "No potential field to match; name / offset match?"); // check for the case where we have not been passed a 'potential field', but the given // 'var' is itself may be the field we seek, such as in an if statement like this: @@ -135,23 +136,25 @@ public class VariableAccessDR extends DecompilerReference { String name = var.getName(); int offset = var.getOffset(); if (fieldMatcher.matches(name, offset)) { - DtrfDbg.println(this, indent + "\tfield matcher matched on variable: " + var); + StringUtilities.indentLines(var.toString(), indent + '\t'); + DtrfDbg.println(getFunction(), this, + indent + "\tfield matcher matched on variable: " + var); return var; } - DtrfDbg.println(this, indent + "\tNO FIELD MATCHER MATCH"); + DtrfDbg.println(getFunction(), this, indent + "\tNO FIELD MATCHER MATCH"); return null; // we seek a field, but there is none } - DtrfDbg.println(this, indent + "Checking 'potential field' match..."); + DtrfDbg.println(getFunction(), this, indent + "Checking 'potential field' match..."); String name = potentialField.getName(); int offset = potentialField.getOffset(); if (fieldMatcher.matches(name, offset)) { - DtrfDbg.println(this, indent + "\tMATCHED"); + DtrfDbg.println(getFunction(), this, indent + "\tMATCHED"); return match; } - DtrfDbg.println(this, indent + "\tNO MATCH"); + DtrfDbg.println(getFunction(), this, indent + "\tNO MATCH"); return null; } @@ -160,26 +163,27 @@ public class VariableAccessDR extends DecompilerReference { String indent = "\t\t\t"; - DtrfDbg.println(this, indent + "Checking for matching variable; any casts?"); + DtrfDbg.println(getFunction(), this, indent + "Checking for matching variable; any casts?"); List castVariables = var.getCasts(); for (DecompilerVariable cast : castVariables) { if (matchesType(cast, dt)) { - DtrfDbg.println(this, indent + "MATCHED cast: " + cast); + DtrfDbg.println(getFunction(), this, indent + "MATCHED cast: " + cast); return cast; } } String dtString = dt == null ? "null" : dt.toString(); - DtrfDbg.println(this, + DtrfDbg.println(getFunction(), this, indent + "No matched casts; checking type against var:\n" + StringUtilities.indentLines("type: " + dtString, indent + "\t") + "\n" + StringUtilities.indentLines("var: " + var.toString(), indent + "\t")); if (matchesType(var, dt)) { - DtrfDbg.println(this, indent + "MATCHED type: "); + DtrfDbg.println(getFunction(), this, indent + "MATCHED type: "); return var; } - DtrfDbg.println(this, indent + "Type did not match; checking High Variable: "); + DtrfDbg.println(getFunction(), this, + indent + "Type did not match; checking High Variable: "); // // Unusual Code Alert! @@ -194,12 +198,12 @@ public class VariableAccessDR extends DecompilerReference { HighVariable highVariable = var.variable.getHighVariable(); if (highVariable != null) { if (matchesParentType(potentialField, dt)) { - DtrfDbg.println(this, indent + "MATCHED on parent type: " + dt); + DtrfDbg.println(getFunction(), this, indent + "MATCHED on parent type: " + dt); return potentialField; } } - DtrfDbg.println(this, indent + "NOT MATCHED"); + DtrfDbg.println(getFunction(), this, indent + "NOT MATCHED"); return null; } @@ -218,7 +222,7 @@ public class VariableAccessDR extends DecompilerReference { String indent = "\t\t\t\t"; if (var == null) { - DtrfDbg.println(this, indent + "Types Match? no variable to check"); + DtrfDbg.println(getFunction(), this, indent + "Types Match? no variable to check"); return false; } @@ -226,7 +230,7 @@ public class VariableAccessDR extends DecompilerReference { if (varType == null) { // it seems odd to me that there is no type, but I have seen this in the case // statement of a switch - DtrfDbg.println(this, indent + "ypes Match? no variable TYPE to check"); + DtrfDbg.println(getFunction(), this, indent + "ypes Match? no variable TYPE to check"); return false; } boolean matches = isEqual(varType, dt); diff --git a/Ghidra/Features/PDB/src/main/java/ghidra/app/util/pdb/pdbapplicator/CppCompositeType.java b/Ghidra/Features/PDB/src/main/java/ghidra/app/util/pdb/pdbapplicator/CppCompositeType.java index bf4192a52a..2df9a91286 100644 --- a/Ghidra/Features/PDB/src/main/java/ghidra/app/util/pdb/pdbapplicator/CppCompositeType.java +++ b/Ghidra/Features/PDB/src/main/java/ghidra/app/util/pdb/pdbapplicator/CppCompositeType.java @@ -1025,16 +1025,15 @@ public class CppCompositeType { * @throws CancelledException upon user cancellation */ private void createMembersOnlyClassLayout(TaskMonitor monitor) throws CancelledException { - TreeMap map = new TreeMap<>(); + List pdbMembers = new ArrayList<>(); for (Member member : layoutMembers) { ClassPdbMember classPdbMember = new ClassPdbMember(member.getName(), member.getDataType(), member.isFlexibleArray(), member.getOffset(), member.getComment()); - map.put((long) member.getOffset(), classPdbMember); + pdbMembers.add(classPdbMember); } - List sm = new ArrayList<>(map.values()); if (!DefaultCompositeMember.applyDataTypeMembers(composite, false, false, size, - sm, msg -> Msg.warn(this, msg), monitor)) { + pdbMembers, msg -> Msg.warn(this, msg), monitor)) { clearComponents(composite); } selfBaseType = composite; diff --git a/Ghidra/Features/SwiftDemangler/src/main/java/ghidra/app/util/demangler/swift/SwiftDemangledBuiltinType.java b/Ghidra/Features/SwiftDemangler/src/main/java/ghidra/app/util/demangler/swift/SwiftDemangledBuiltinType.java index c7def18a13..fdd3e37a21 100644 --- a/Ghidra/Features/SwiftDemangler/src/main/java/ghidra/app/util/demangler/swift/SwiftDemangledBuiltinType.java +++ b/Ghidra/Features/SwiftDemangler/src/main/java/ghidra/app/util/demangler/swift/SwiftDemangledBuiltinType.java @@ -4,9 +4,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -20,7 +20,7 @@ import ghidra.app.util.demangler.swift.nodes.SwiftNode; /** * Kinds of Swift demangling {@link SwiftNode}s * - * @see DemangleNodes.def + * @see DemangleNodes.def */ public enum SwiftDemangledBuiltinType { //@formatter:off diff --git a/Ghidra/Features/SwiftDemangler/src/main/java/ghidra/app/util/demangler/swift/SwiftDemangledNodeKind.java b/Ghidra/Features/SwiftDemangler/src/main/java/ghidra/app/util/demangler/swift/SwiftDemangledNodeKind.java index ac21c313ba..6fd3caf1d2 100644 --- a/Ghidra/Features/SwiftDemangler/src/main/java/ghidra/app/util/demangler/swift/SwiftDemangledNodeKind.java +++ b/Ghidra/Features/SwiftDemangler/src/main/java/ghidra/app/util/demangler/swift/SwiftDemangledNodeKind.java @@ -4,9 +4,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -20,7 +20,7 @@ import ghidra.app.util.demangler.swift.nodes.SwiftNode; /** * Kinds of Swift demangling {@link SwiftNode}s * - * @see DemangleNodes.def + * @see DemangleNodes.def */ public enum SwiftDemangledNodeKind { //@formatter:off diff --git a/Ghidra/Framework/Generic/src/main/java/generic/test/ConcurrentTestExceptionStatement.java b/Ghidra/Framework/Generic/src/main/java/generic/test/ConcurrentTestExceptionStatement.java index b8720a9e43..3009cdf2b1 100644 --- a/Ghidra/Framework/Generic/src/main/java/generic/test/ConcurrentTestExceptionStatement.java +++ b/Ghidra/Framework/Generic/src/main/java/generic/test/ConcurrentTestExceptionStatement.java @@ -16,12 +16,10 @@ package generic.test; import java.util.List; -import java.util.concurrent.TimeUnit; import org.junit.runners.model.Statement; import ghidra.util.Msg; -import ghidra.util.SystemUtilities; import ghidra.util.timer.GTimer; import ghidra.util.timer.GTimerMonitor; import junit.framework.AssertionFailedError; @@ -204,10 +202,11 @@ public class ConcurrentTestExceptionStatement extends Statement { return; } - if (SystemUtilities.isInDevelopmentMode()) { - throw new AssertionFailedError("Test timeout after " + - TimeUnit.MINUTES.convert(TIMEOUT_MILLIS, TimeUnit.MILLISECONDS) + " mins"); - } +// Not sure why we were doing this before +// if (SystemUtilities.isInDevelopmentMode()) { +// throw new AssertionFailedError("Test timeout after " + +// TimeUnit.MINUTES.convert(TIMEOUT_MILLIS, TimeUnit.MILLISECONDS) + " mins"); +// } String vmTrace = AbstractGenericTest.createStackTraceForAllThreads(); Msg.error(ConcurrentTestExceptionStatement.class, diff --git a/Ghidra/Processors/AARCH64/data/languages/AARCH64_swift.cspec b/Ghidra/Processors/AARCH64/data/languages/AARCH64_swift.cspec index 926a155ea5..a78ec35644 100644 --- a/Ghidra/Processors/AARCH64/data/languages/AARCH64_swift.cspec +++ b/Ghidra/Processors/AARCH64/data/languages/AARCH64_swift.cspec @@ -66,7 +66,7 @@ - + @@ -228,7 +228,7 @@ - + diff --git a/Ghidra/Processors/MIPS/src/main/java/ghidra/app/util/bin/format/elf/relocation/MIPS_ElfRelocationHandler.java b/Ghidra/Processors/MIPS/src/main/java/ghidra/app/util/bin/format/elf/relocation/MIPS_ElfRelocationHandler.java index 1701c8fe0e..80b326adc8 100644 --- a/Ghidra/Processors/MIPS/src/main/java/ghidra/app/util/bin/format/elf/relocation/MIPS_ElfRelocationHandler.java +++ b/Ghidra/Processors/MIPS/src/main/java/ghidra/app/util/bin/format/elf/relocation/MIPS_ElfRelocationHandler.java @@ -357,8 +357,14 @@ public class MIPS_ElfRelocationHandler } value = symbolValue; if (elfRelocationContext.extractAddend()) { - // extract addend based upon pointer size - addend = memory.getInt(relocationAddress); + // Extract addend based upon pointer size when saving 64-bit addend + // for packed relocation type + if (saveValue && program.getDefaultPointerSize() == 8) { + addend = memory.getLong(relocationAddress); + } + else { + addend = memory.getInt(relocationAddress); + } } newValue = value + addend; diff --git a/Ghidra/Processors/PowerPC/data/languages/SPE_APU.sinc b/Ghidra/Processors/PowerPC/data/languages/SPE_APU.sinc index cc07249e2a..9a3c36864b 100644 --- a/Ghidra/Processors/PowerPC/data/languages/SPE_APU.sinc +++ b/Ghidra/Processors/PowerPC/data/languages/SPE_APU.sinc @@ -593,45 +593,27 @@ define pcodeop VectorDivideWordUnsigned2; # evldd RT,D(RA) # ISA-cmt: Vector Load Double Word into Double Word # evldd rD,d(rA) -define pcodeop VectorLoadDoubleWordIntoDoubleWord; -# TODO: defined in evx.sinc -# if (RA == 0) { -# b = 0; -# } else { -# b = RA; -# } -# EA = b + EXTZ(UI*8); -# RT = MEM(EA,8); - -#:evldd D,A is OP=4 & D & A & XOP_0_10=769 & BITS_11_15=0 { - # TODO: defined in evx.sinc -# VectorLoadDoubleWordIntoDoubleWord(D,A); -#} +:evldd RT,dUI16PlusRAOrZeroAddress is OP=4 & RT & dUI16PlusRAOrZeroAddress & XOP_0_10=769 +{ + ea:$(REGISTER_SIZE) = dUI16PlusRAOrZeroAddress; + RT = *:8 ($(EATRUNC)); +} # evlddx RT,RA,RB # ISA-cmt: Vector Load Double Word into Double Word Indexed # evlddx -# define pcodeop vectorLoadDoubleWordIntoDoubleWordIndexed1; -# TODO: defined in evx.sinc -# if (RA == 0) { -# b = 0; -# } else { -# b = RA; -# } -# EA = b + RB; -# RT = MEM(EA, 8); - -# :evlddx S,A,B is OP=4 & S & A & B & XOP_0_10=768 { -# TODO: defined in evx.sinc -# vectorLoadDoubleWordIntoDoubleWordIndexed1(S,A,B); -#} +:evlddx RT,RA_OR_ZERO,RB is OP=4 & RT & RA_OR_ZERO & RB & XOP_0_10=768 +{ + ea:$(REGISTER_SIZE) = RA_OR_ZERO + RB; + RT = *:8 ($(EATRUNC)); +} # evldh RT,D(RA) # ISA-cmt: Vector Load Double into Four Halfwords # evldh rD,rA 011 0000 0101 -:evldh RT,EVUIMM_8_RAt is OP=4 & A & D & RT & EVUIMM_8 & EVUIMM_8_RAt & XOP_0_10=0x305 { +:evldh RT,EVUIMM_8_RAt is OP=4 & RT & EVUIMM_8_RAt & XOP_0_10=0x305 { # if (RA == 0) { # b = 0; # } else { @@ -643,7 +625,7 @@ define pcodeop VectorLoadDoubleWordIntoDoubleWord; # RT.S2 = MEM(EA+4, 2); # RT.S3 = MEM(EA+6, 2); - EA:8 = A + zext(EVUIMM_8_RAt); + EA:8 = EVUIMM_8_RAt; *:2 (RT) = *:2 ((EA) & $(MEMMASK)); *:2 (RT+2) = *:2 ((EA+2) & $(MEMMASK)); *:2 (RT+4) = *:2 ((EA+4) & $(MEMMASK)); @@ -676,7 +658,7 @@ define pcodeop VectorLoadDoubleWordIntoDoubleWord; # evldw RT,D(RA) # ISA-cmt: Vector Load Double into Two Words # evldw rD,rA 011 0000 0011 -:evldw RT,EVUIMM_8_RAt is OP=4 & A & D & RT & EVUIMM_8 & EVUIMM_8_RAt & XOP_0_10=0x303 { +:evldw RT,EVUIMM_8_RAt is OP=4 & RT & EVUIMM_8_RAt & XOP_0_10=0x303 { # if (RA == 0) { # b = 0; # } else { @@ -686,7 +668,7 @@ define pcodeop VectorLoadDoubleWordIntoDoubleWord; # RT.l = MEM(EA, 4); # RT.h = MEM(EA+4, 4); - EA:$(REGISTER_SIZE) = A + zext(EVUIMM_8_RAt); + EA:$(REGISTER_SIZE) = EVUIMM_8_RAt; *:4 (RT) = *:4 ((EA) & $(MEMMASK)); *:4 (RT+4) = *:4 ((EA+4) & $(MEMMASK)); } @@ -712,7 +694,7 @@ define pcodeop VectorLoadDoubleWordIntoDoubleWord; # evlhhesplat RT,D(RA) # ISA-cmt: Vector Load Halfword into Halfwords Even and Splat # evlhhesplat rD,rA 011 0000 1001 -:evlhhesplat RT,EVUIMM_2_RAt is OP=4 & A & RT & EVUIMM_2_RAt & D & XOP_0_10=0x309 { +:evlhhesplat RT,EVUIMM_2_RAt is OP=4 & RT & EVUIMM_2_RAt & XOP_0_10=0x309 { # if (RA == 0) { # b = 0; # } else { @@ -724,7 +706,7 @@ define pcodeop VectorLoadDoubleWordIntoDoubleWord; # RT.S2 = MEM(EA,2); # RT.S3 = 0x0000; - EA:$(REGISTER_SIZE) = A + zext(EVUIMM_2_RAt); + EA:$(REGISTER_SIZE) = EVUIMM_2_RAt; *:2 (RT) = *:2 ((EA) & $(MEMMASK)); *:2 (RT+2) = 0x0000; *:2 (RT+4) = *:2 ((EA) & $(MEMMASK)); @@ -756,7 +738,7 @@ define pcodeop VectorLoadDoubleWordIntoDoubleWord; # evlhhossplat RT,D(RA) # ISA-cmt: Vector Load Halfword into Halfword Odd Signed and Splat # evlhhossplat rD,rA 011 0000 1111 -:evlhhossplat RT,EVUIMM_2_RAt is OP=4 & A & RT & EVUIMM_2_RAt & D & XOP_0_10=0x30F { +:evlhhossplat RT,EVUIMM_2_RAt is OP=4 & RT & EVUIMM_2_RAt & XOP_0_10=0x30F { # if (RA == 0) { # b = 0; # } else { @@ -766,7 +748,7 @@ define pcodeop VectorLoadDoubleWordIntoDoubleWord; # RT.l = EXTS(MEM(EA, 2)); # RT.h = EXTS(MEM(EA, 2)); - EA:$(REGISTER_SIZE) = A + zext(EVUIMM_2_RAt); + EA:$(REGISTER_SIZE) = EVUIMM_2_RAt; *:4 (RT) = sext( *:2 (((EA) & $(MEMMASK)))); *:4 (RT+4) = sext( *:2 (((EA) & $(MEMMASK)))); } @@ -792,7 +774,7 @@ define pcodeop VectorLoadDoubleWordIntoDoubleWord; # evlhhousplat RT,D(RA) # ISA-cmt: Vector Load Halfword into Halfword Odd Unsigned and Splat # evlhhousplat rD,rA 011 0000 1101 -:evlhhousplat RT,EVUIMM_2_RAt is OP=4 & A & RT & EVUIMM_2_RAt & D & XOP_0_10=0x30D { +:evlhhousplat RT,EVUIMM_2_RAt is OP=4 & RT & EVUIMM_2_RAt & XOP_0_10=0x30D { # if (RA == 0) { # b = 0; # } else { @@ -802,7 +784,7 @@ define pcodeop VectorLoadDoubleWordIntoDoubleWord; # RT.l = EXTZ(MEM(EA, 2)); # RT.h = EXTZ(MEM(EA, 2)); - EA:$(REGISTER_SIZE) = A + zext(EVUIMM_2_RAt); + EA:$(REGISTER_SIZE) = EVUIMM_2_RAt; *:4 (RT) = zext( *:2 (((EA) & $(MEMMASK)))); *:4 (RT+4) = zext( *:2 (((EA) & $(MEMMASK)))); } @@ -871,7 +853,7 @@ define pcodeop VectorLoadDoubleWordIntoDoubleWord; # evlwhos RT,D(RA) # ISA-cmt: Vector Load Word into Two Halfwords Odd Signed (with sign extension) # evlwhos rD,rA 011 0001 0111 -:evlwhos RT,EVUIMM_4_RAt is OP=4 & A & EVUIMM_4_RAt & RT & D & XOP_0_10=0x317 { +:evlwhos RT,EVUIMM_4_RAt is OP=4 & EVUIMM_4_RAt & RT & XOP_0_10=0x317 { # if (RA == 0) { # b = 0; # } else { @@ -881,7 +863,7 @@ define pcodeop VectorLoadDoubleWordIntoDoubleWord; # RT.l = EXTS(MEM(EA, 2)); # RT.h = EXTS(MEM(EA+2, 2)); - EA:$(REGISTER_SIZE) = A + zext(EVUIMM_4_RAt); + EA:$(REGISTER_SIZE) = EVUIMM_4_RAt; *:4 (RT) = sext( *:2 (((EA) & $(MEMMASK)))); *:4 (RT+4) = sext( *:2 (((EA+2) & $(MEMMASK)))); } @@ -907,7 +889,7 @@ define pcodeop VectorLoadDoubleWordIntoDoubleWord; # evlwhou RT,D(RA) # ISA-cmt: Vector Load Word into Two Halfwords Odd Unsigned (zero-extended) # evlwhou rD,rA 011 0001 0101 -:evlwhou RT,EVUIMM_4_RAt is OP=4 & A & EVUIMM_4_RAt & RT & D & XOP_0_10=0x315 { +:evlwhou RT,EVUIMM_4_RAt is OP=4 & EVUIMM_4_RAt & RT & XOP_0_10=0x315 { # if (RA == 0) { # b = 0; # } else { @@ -917,7 +899,7 @@ define pcodeop VectorLoadDoubleWordIntoDoubleWord; # RT.l = EXTZ(MEM(EA, 2)); # RT.h = EXTZ(MEM(EA+2, 2)); - EA:$(REGISTER_SIZE) = A + zext(EVUIMM_4_RAt); + EA:$(REGISTER_SIZE) = EVUIMM_4_RAt; *:4 (RT) = zext( *:2 (((EA) & $(MEMMASK)))); *:4 (RT+4) = zext( *:2 (((EA+2) & $(MEMMASK)))); } @@ -943,7 +925,7 @@ define pcodeop VectorLoadDoubleWordIntoDoubleWord; # evlwhsplat RT,D(RA) # ISA-cmt: Vector Load Word into Two Halfwords and Splat # evlwhsplat rD,rA 011 0001 1101 -:evlwhsplat RS,EVUIMM_4_RAt is OP=4 & A & B & D & XOP_0_10=0x31D & EVUIMM_4_RAt & RS { +:evlwhsplat RS,EVUIMM_4_RAt is OP=4 & XOP_0_10=0x31D & EVUIMM_4_RAt & RS { # if (RA == 0) { # b = 0; # } else { @@ -955,7 +937,7 @@ define pcodeop VectorLoadDoubleWordIntoDoubleWord; # RT.S2 = MEM(EA+2,2); # RT.S3 = MEM(EA+2,2); - EA:$(REGISTER_SIZE) = A + zext(EVUIMM_4_RAt); + EA:$(REGISTER_SIZE) = EVUIMM_4_RAt; *:2 (RS) = *:2 ((EA) & $(MEMMASK)); *:2 (RS+2) = *:2 ((EA) & $(MEMMASK)); *:2 (RS+4) = *:2 ((EA+2) & $(MEMMASK)); @@ -1023,64 +1005,38 @@ define pcodeop VectorLoadDoubleWordIntoDoubleWord; # evmergehi RT,RA,RB # ISA-cmt: Vector Merge High # evmergehi rD,rA,rB 010 0010 1100 -# defined evx.sinc XXX -# define pcodeop VectorMergeHigh; -# :evmergehi D,A,B is OP=4 & A & B & D & XOP_0_10=0x22C { -# RT.l = RA.l; -# RT.h = RB.h; - -# VectorMergeHigh(D,A,B); -# } +@if REGISTER_SIZE=="8" +:evmergehi S,A,B is OP=4 & S & A & B & XOP_0_10=556 +{ + S[32,32] = A[32,32]; + S[ 0,32] = B[32,32]; +} # evmergehilo RT,RA,RB # ISA-cmt: Vector Merge High/Low # evmergehilo rD,rA,rB 010 0010 1110 -#define pcodeop VectorMergeHighLow; -#:evmergehilo D,A,B is OP=4 & A & B & D & XOP_0_10=0x22E { -# RT.l = RA.l; -# RT.h = RA.h; - -# lo = (A & 0x00000000FFFFFFFF); -# hi = ((A & 0xFFFFFFFF00000000) >> 32); -# b_lo = (B & 0x00000000FFFFFFFF); -# b_hi = ((B & 0xFFFFFFFF00000000) >> 32); -# -# lo = lo; -# hi = b_hi; -# -# D = ((hi << 32) | lo); -#} +:evmergehilo S,A,B is OP=4 & S & A & B & XOP_0_10=558 { + S[32,32] = A[32,32]; + S[ 0,32] = B[ 0,32]; +} # evmergelo RT,RA,RB # ISA-cmt: Vector Merge Low # evmergelo rD,rA,rB 010 0010 1101 -# defined evx.sinc XXX -# define pcodeop VectorMergeLow; -# :evmergelo D,A,B is OP=4 & A & B & D & XOP_0_10=0x22D { -# RT.l = RA.h; -# RT.h = RA.l; - -# VectorMergeLow(D,A,B); -# } +:evmergelo S,A,B is OP=4 & S & A & B & XOP_0_10=557 +{ + S[32,32] = A[0,32]; + S[ 0,32] = B[0,32]; +} # evmergelohi RT,RA,RB # ISA-cmt: Vector Merge Low/High # evmergelohi rD,rA,rB 010 0010 1111 -#:evmergelohi D,A,B is OP=4 & D & A & B & XOP_0_10=0x22F { -# RT.l = RA.h; -# RT.h = RA.l; - -# lo = (A & 0x00000000FFFFFFFF); -# hi = ((A & 0xFFFFFFFF00000000) >> 32); -# b_lo = (B & 0x00000000FFFFFFFF); -# b_hi = ((B & 0xFFFFFFFF00000000) >> 32); -# -# lo = lo; -# hi = b_lo; -# -# D = ((hi << 32) | lo); -#} - +:evmergelohi S,A,B is OP=4 & S & A & B & XOP_0_10=559 { + S[32,32] = A[ 0,32]; + S[ 0,32] = B[32,32]; +} +@endif # evmhegsmfaa RT,RA,RB # ISA-cmt: Vector Multiply Halfwords, Even, Guarded, Signed, Modulo, Fractional and Accumulate @@ -1962,17 +1918,11 @@ define pcodeop VectorMultiplyHalfWordsOddUnsignedSaturateIntegerAndAccumulateNeg # evmra RT,RA # ISA-cmt: Initialize Accumulator # evmra rD,rA 100 1100 0100 -# defined evx.sinc -# define pcodeop InitializeAccumulator; -# :evmra D,A is OP=4 & A & D & XOP_0_10=0x4C4 { -# ACC = RA; -# RT = RA; - -# ACC = A; -# D = A; - -# InitializeAccumulator(D,A); -# } +:evmra RT,RA is OP=4 & RT & RA & BITS_11_15=0 & XOP_0_10=1220 +{ + ACC = zext(RA); + RT = RA; +} # evmwhsmf RT,RA,RB # ISA-cmt: Vector Multiply Word High Signed, Modulo, Fractional @@ -2452,53 +2402,6 @@ define pcodeop VectorMultiplyWordSignedSaturateFractionalAndAccumulateNegative2; spr200 = spr200 | (flags & (0x1000000000000)); } -# evmwumi RT,RA,RB -# ISA-cmt: Vector Multiply Word Unsigned, Modulo, Integer -# evmwumi rD,rA,rB 100 01A1 1000 A=0 -# evmwumi confict with machhwo -# define pcodeop VectorMultiplyWordUnsignedModuloInteger; -# :evmwumi D,A,B is OP=4 & A & B & D & XOP_0_10=0x458 { -# RT = RA.h *ui RB.h; -# VectorMultiplyWordUnsignedModuloInteger(D,A,B,ACC); -# } - -# evmwumia RT,RA,RB -# ISA-cmt: Vector Multiply Word Unsigned, Modulo, Integer to Accumulator -# evmwumia rD,rA,rB 100 01A1 1000 A=1 -:evmwumia D,A,B is OP=4 & A & B & D & XOP_0_10=0x478 { -# RT = RA.h *ui RB.h; -# ACC = RT; - - D = (( A & (0xFFFFFFFF00000000) ) >> 32) * (( B & (0xFFFFFFFF00000000) ) >> 32); - ACC = D; -} - -# evmwumiaa RT,RA,RB -# ISA-cmt: Vector Multiply Word Unsigned, Modulo, Integer and Accumulate -# evmwumiaa rD,rA,rB 101 0101 1000 -# evmwumiaa confict with macchwo -# :evmwumiaa D,A,B is OP=4 & A & B & D & XOP_0_10=0x558 { -# u64 temp; -# temp = RA.h *ui RB.h; -# RT = ACC + temp; -# ACC = RT; - -# VectorMultiplyWordUnsignedModuloIntegerAndAccumulate2(D,A,B,ACC); -# } - -# evmwumian RT,RA,RB -# ISA-cmt: Vector Multiply Word Unsigned, Modulo, Integer and Accumulate Negative -# evmwumian rD,rA,rB 101 1101 1000 -# evmwumian confict with macchwso -# :evmwumian D,A,B is OP=4 & A & B & D & XOP_0_10=0x5D8 { -# u64 temp; -# temp = RA.h *ui RB.h; -# RT = ACC - temp; -# ACC = RT; - -# VectorMultiplyWordUnsignedModuloIntegerAndAccumulateNegative(D,A,B,ACC); -# } - # ================================================================= # Page D-15 @@ -2712,85 +2615,52 @@ define pcodeop VectorShiftRightWordImmediateUnsigned; D = VectorShiftRightWordImmediateUnsigned(A); } -# evsrws RT,RA,RB -# ISA-cmt: Vector Shift Right Word Signed -# evsrws rD,rA,rB 010 0010 0001 -:evsrws D,A,B is OP=4 & A & B & D & XOP_0_10=0x221 { -# nh = RB.bsub(26:31); -# hl = RB.bsub(58:63); -# RT.l = EXTS(RA.bsub(0:32-nh)); -# RT.h = EXTS(RA.bsub(32:63-nl)); - - nh:$(REGISTER_SIZE) = 32-((B & 0x00000000fc000000) >> 26); - nl:$(REGISTER_SIZE) = 63-((B & 0xfc00000000000000) >> 58); - tmp:$(REGISTER_SIZE) = (A & ((0xFFFFFFFFFFFFFFFF >> (64 - ((nh) - (0) + 1))) << (0)) >> 0); - lo:8 = sext(tmp:4); - tmp = (A & ((0xFFFFFFFFFFFFFFFF >> (64 - ((nl) - (32) + 1))) << (32)) >> 32); - hi:8 = sext(tmp:4); - D = (( zext(hi) << 32) | zext(lo) ); +@if REGISTER_SIZE=="8" +:evsrws S,A,B is OP=4 & S & A & B & XOP_0_10=545 +{ + local low:4 = A[0,32]; + local high:4 = A[32,32]; + local low_shift:1 = B[0,5]; + local high_shift:1 = B[32,5]; + S[0,32] = low s>> zext(low_shift); + S[32,32] = high s>> zext(high_shift); } -# evsrwu RT,RA,RB -# ISA-cmt: Vector Shift Right Word Unsigned -# evsrwu rD,rA,rB 010 0010 0000 -:evsrwu D,A,B is OP=4 & A & B & D & XOP_0_10=0x220 { -# nh = RB.bsub(26:31); -# nl = RB.bsub(58:63); -# RT.l = EXTZ(RA.bsub(0:32-nh)); -# RT.h = EXTZ(RA.bsub(32:63-nl)); - - nh:$(REGISTER_SIZE) = 32-((B & 0x00000000fc000000) >> 26); - nl:$(REGISTER_SIZE) = 63-((B & 0xfc00000000000000) >> 58); - tmp:$(REGISTER_SIZE) = (A & ((0xFFFFFFFFFFFFFFFF >> (64 - ((nh) - (0) + 1))) << (0)) >> 0); - lo:8 = zext(tmp:4); - tmp = (A & ((0xFFFFFFFFFFFFFFFF >> (64 - ((nl) - (32) + 1))) << (32)) >> 32); - hi:8 = zext(tmp:4); - D = (( zext(hi) << 32) | zext(lo) ); +:evsrwu S,A,B is OP=4 & S & A & B & XOP_0_10=544 +{ + local low:4 = A[0,32]; + local high:4 = A[32,32]; + local low_shift:1 = B[0,5]; + local high_shift:1 = B[32,5]; + S[0,32] = low >> zext(low_shift); + S[32,32] = high >> zext(high_shift); } +@endif + # evstdd RS,D(RA) # ISA-cmt: Vector Store Double of Double # evstdd rD,rA,EVUIMM_8 011 0010 0001 -# defined evx.sinc EJ XXX -#define pcodeop VectorStoreDoubleOfDouble; -#:evstdd D,A,EVUIMM_8 is OP=4 & A & D & EVUIMM_8 & XOP_0_10=0x321 { -# if (RA == 0) { -# b = 0; -# } else { -# b = RA; -# } -# EA = b + EXTZ(UI*8); -# MEM(EA,8) = RS; - -# VectorStoreDoubleOfDouble(D,A); -# } +:evstdd RS,dUI16PlusRAOrZeroAddress is OP=4 & RS & dUI16PlusRAOrZeroAddress & XOP_0_10=801 +{ + ea:$(REGISTER_SIZE) = dUI16PlusRAOrZeroAddress; + *:8 ($(EATRUNC)) = RS; +} # evstddx RS,RA,RB # ISA-cmt: Vector Store Double of Double Indexed # evstddx rS,rA,rB 011 0010 0000 -# defined evx.sinc EJ XXX -# define pcodeop VectorStoreDoubleOfDoubleIndexed; -# :evstddx S,A,B is OP=4 & A & S & B & XOP_0_10=0x320 { -# if (RA == 0) { -# b = 0; -# } else { -# b = RA; -# } -# EA = b + RB; -# MEM(EA,8) = RS; +:evstddx RS,RA_OR_ZERO,RB is OP=4 & RS & RA_OR_ZERO & RB & XOP_0_10=800 +{ + ea:$(REGISTER_SIZE) = RA_OR_ZERO + RB; + *:8 ($(EATRUNC)) = RS; +} -# VectorStoreDoubleOfDoubleIndexed(S,A,B); -# } -# :evstddx RS,RA_OR_ZERO,RB is OP=4 & RS & RA_OR_ZERO & RB & XOP_0_10=800 -# { -# ea = RA_OR_ZERO + RB; -# *:8 ($(EATRUNC)) = RS; -# } # evstdh RS,D(RA) # ISA-cmt: Vector Store Double of Four Halfwords # evstdh rS,rA,EVUIMM_8 011 0010 0101 -:evstdh S,EVUIMM_8_RAt is OP=4 & A & S & EVUIMM_8 & EVUIMM_8_RAt & XOP_0_10=0x325 { +:evstdh S,EVUIMM_8_RAt is OP=4 & S & EVUIMM_8_RAt & XOP_0_10=0x325 { # if (RA == 0) { # b = 0; # } else { @@ -2802,7 +2672,7 @@ define pcodeop VectorShiftRightWordImmediateUnsigned; # MEM(EA+4,2) = RS.S2; # MEM(EA+6,2) = RS.S3; - EA:$(REGISTER_SIZE) = A + zext(EVUIMM_8_RAt); + EA:$(REGISTER_SIZE) = EVUIMM_8_RAt; *:2 (EA) = *:2 ((S) & $(MEMMASK)); *:2 (EA+2) = *:2 ((S+2) & $(MEMMASK)); *:2 (EA+4) = *:2 ((S+4) & $(MEMMASK)); @@ -2834,7 +2704,7 @@ define pcodeop VectorShiftRightWordImmediateUnsigned; # evstdw RS,D(RA) # ISA-cmt: Vector Store Double of Two Words # evstdw rS,rA,EVUIMM_8 011 0010 0011 -:evstdw S,EVUIMM_8_RAt is OP=4 & A & S & EVUIMM_8 & EVUIMM_8_RAt & XOP_0_10=0x323 { +:evstdw S,EVUIMM_8_RAt is OP=4 & S & EVUIMM_8_RAt & XOP_0_10=0x323 { # if (RA == 0) { # b = 0; # } else { @@ -2844,7 +2714,7 @@ define pcodeop VectorShiftRightWordImmediateUnsigned; # MEM(EA,4) = RS.l; # MEM(EA+4,4) = RS.h; - EA:$(REGISTER_SIZE) = A + zext(EVUIMM_8_RAt); + EA:$(REGISTER_SIZE) = EVUIMM_8_RAt; *:4 (EA) = *:4 ((S) & $(MEMMASK)); *:4 (EA+4) = *:4 ((S+4) & $(MEMMASK)); } @@ -2870,7 +2740,7 @@ define pcodeop VectorShiftRightWordImmediateUnsigned; # evstwhe RS,D(RA) # ISA-cmt: Vector Store Word of Two Halfwords from Even # evstwhe rS,rA,EVUIMM_4 011 0011 0001 -:evstwhe S,EVUIMM_4_RAt is OP=4 & A & S & EVUIMM_4_RAt & XOP_0_10=0x331 { +:evstwhe S,EVUIMM_4_RAt is OP=4 & S & EVUIMM_4_RAt & XOP_0_10=0x331 { # if (RA == 0) { # b = 0; # } else { @@ -2880,7 +2750,7 @@ define pcodeop VectorShiftRightWordImmediateUnsigned; # MEM(EA,2) = RS.S0; # MEM(EA+2,2) = RS.S2; - EA:$(REGISTER_SIZE) = A + zext(EVUIMM_4_RAt); + EA:$(REGISTER_SIZE) = EVUIMM_4_RAt; *:2 (EA) = *:2 ((S) & $(MEMMASK)); *:2 (EA+2) = *:2 ((S+2) & $(MEMMASK)); } @@ -2906,7 +2776,7 @@ define pcodeop VectorShiftRightWordImmediateUnsigned; # evstwho RS,D(RA) # ISA-cmt: Vector Store Word of Two Halfwords from Odd # evstwho rS,rA,EVUIMM_4 011 0011 0101 -:evstwho S,EVUIMM_4_RAt is OP=4 & A & S & EVUIMM_4_RAt & XOP_0_10=0x335 { +:evstwho S,EVUIMM_4_RAt is OP=4 & S & EVUIMM_4_RAt & XOP_0_10=0x335 { # if (RA == 0) { # b = 0; # } else { @@ -2916,7 +2786,7 @@ define pcodeop VectorShiftRightWordImmediateUnsigned; # MEM(EA,2) = RS.S1; # MEM(EA+2,2) = RS.S3; - EA:$(REGISTER_SIZE) = A + zext(EVUIMM_4_RAt); + EA:$(REGISTER_SIZE) = EVUIMM_4_RAt; *:2 (EA) = *:2 ((S+2) & $(MEMMASK)); *:2 (EA+2) = *:2 ((S+6) & $(MEMMASK)); } @@ -2924,7 +2794,7 @@ define pcodeop VectorShiftRightWordImmediateUnsigned; # evstwhox RS,RA,RB # ISA-cmt: Vector Store Word of Two Halfwords from Odd Indexed # evstwhox rS,rA,rB 011 0011 0100 -:evstwhox S,A,B is OP=4 & A & B & S & XOP_0_10=0x334 { +:evstwhox S,RA_OR_ZERO,B is OP=4 & RA_OR_ZERO & B & S & XOP_0_10=0x334 { # if (RA == 0) { # b = 0; # } else { @@ -2934,47 +2804,33 @@ define pcodeop VectorShiftRightWordImmediateUnsigned; # MEM(EA,2) = RS.S1; # MEM(EA+2,2) = RS.S3; - EA:$(REGISTER_SIZE) = A + B; + EA:$(REGISTER_SIZE) = RA_OR_ZERO + B; *:2 (EA) = *:2 ((S+2) & $(MEMMASK)); *:2 (EA+2) = *:2 ((S+6) & $(MEMMASK)); } # evstwwe RS,D(RA) # ISA-cmt: Vector Store Word of Word from Even -# evstwwe rS,rA,EVUIMM_4 011 0011 1001 -#define pcodeop VectorStoreWordOfWordFromEven; -#:evstwwe S,EVUIMM_4_RAt is OP=4 & A & S & EVUIMM_4_RAt & XOP_0_10=0x339 { -# if (RA == 0) { -# b = 0; -# } else { -# b = RA; -# } -# EA = b + EXTZ(UI*4); -# MEM(EA,4) = RS; - -# VectorStoreWordOfWordFromEven(S,A); -# } +# evstwwe rS,rA,UIMM 011 0011 1001 +:evstwwe S,EVUIMM_4_RAt is OP=4 & S & EVUIMM_4_RAt & UI & XOP_0_10=0x339 +{ + ea:$(REGISTER_SIZE) = EVUIMM_4_RAt; + *:4 ($(EATRUNC)) = S:4; +} # evstwwex RS,RA,RB # ISA-cmt: Vector Store Word of Word from Even Indexed # evstwwex rS,rA,rB 011 0011 1000 -#define pcodeop VectorStoreWordOfWordFromEvenIndexed; -#:evstwwex S,A,B is OP=4 & A & B & S & XOP_0_10=0x338 { -# if (RA == 0) { -# b = 0; -# } else { -# b = RA; -# } -# EA = b + RB; -# MEM(EA,4) = RS; - -# VectorStoreWordOfWordFromEvenIndexed(S,A,B); -# } +:evstwwex S,RA_OR_ZERO,RB is OP=4 & S & RA_OR_ZERO & RB & XOP_0_10=0x338 +{ + ea:$(REGISTER_SIZE) = RA_OR_ZERO + RB; + *:4 ($(EATRUNC)) = S:4; +} # evstwwo RS,D(RA) # ISA-cmt: Vector Store Word of Word from Odd # evstwwo rS,rA,EVUIMM_4 011 0011 1101 -:evstwwo S,EVUIMM_4_RAt is OP=4 & A & S & EVUIMM_4_RAt & XOP_0_10=0x33D { +:evstwwo S,EVUIMM_4_RAt is OP=4 & S & EVUIMM_4_RAt & UI & XOP_0_10=0x33D { # if (RA == 0) { # b = 0; # } else { @@ -2983,7 +2839,7 @@ define pcodeop VectorShiftRightWordImmediateUnsigned; # EA = b + EXTZ(UI*4); # MEM(EA,4) = RS.h; - EA:$(REGISTER_SIZE) = A + zext(EVUIMM_4_RAt); + EA:$(REGISTER_SIZE) = EVUIMM_4_RAt; *:4 (EA) = *:4 ((S+4) & $(MEMMASK)); } @@ -3105,19 +2961,10 @@ define pcodeop VectorSubtractUnsignedSaturateIntegerToAccumulatorWord2; # evxor RT,RA,RB # ISA-cmt: Vector XOR # evxor rD,rA,rB 010 0001 0110 -# defined evx.sinc EJ XXX -# define pcodeop VectorXOR; -# : D = 64From2_32(hi,lo); -# :evxor S,A,B is OP=4 & S & A & B & XOP_0_10=0x216 { -# RT.l = RA.l ^ RB.l; -# RT.h = RA.h ^ RB.h; - -# VectorXOR(S,A,B); -# lo = A:2 ^ B:2; -# hi = A(2) ^ B(2); -# D:2 = lo; -# D(2) = hi; -# } +:evxor vrD_64_0,vrA_64_0,vrB_64_0 is OP=4 & vrD_64_0 & vrA_64_0 & vrB_64_0 & XOP_0_10=534 +{ + vrD_64_0 = vrA_64_0 ^ vrB_64_0; +} # TODO evmwlssianw RT,RA,RB # TODO complicated diff --git a/Ghidra/Processors/PowerPC/data/languages/SPE_EFV.sinc b/Ghidra/Processors/PowerPC/data/languages/SPE_EFV.sinc index b71ddd36da..5a94925d0b 100644 --- a/Ghidra/Processors/PowerPC/data/languages/SPE_EFV.sinc +++ b/Ghidra/Processors/PowerPC/data/languages/SPE_EFV.sinc @@ -1137,9 +1137,9 @@ # evlwhe RT,D(RA) # evlwhe rT,rA,UI -:evlwhe D,EVUIMM_4_RAt is OP=4 & D & EVUIMM_4_RAt & RA_OR_ZERO & UI & XOP_0_10=785 +:evlwhe D,EVUIMM_4_RAt is OP=4 & D & EVUIMM_4_RAt & XOP_0_10=785 { - ea:$(REGISTER_SIZE) = RA_OR_ZERO + (UI * 4); + ea:$(REGISTER_SIZE) = EVUIMM_4_RAt; # move results into upper and lower words tmpZ:8 = zext( *:2(ea + 2) ); @@ -1179,9 +1179,9 @@ # ISA-info: evlwwsplat - Form "EVX" Page 521 Category "SP" # binutils: NO-EXAMPLE - evlwwsplat # collides with maclhwu -:evlwwsplat D,EVUIMM_4_RAt is OP=4 & D & RA_OR_ZERO & EVUIMM_4_RAt & UI & XOP_0_10=793 +:evlwwsplat D,EVUIMM_4_RAt is OP=4 & D & EVUIMM_4_RAt & XOP_0_10=793 { - ea:$(REGISTER_SIZE) = RA_OR_ZERO + (UI * 4); + ea:$(REGISTER_SIZE) = EVUIMM_4_RAt; # move results into upper and lower words tmpZ:8 = zext( *:4(ea) ); @@ -1413,10 +1413,34 @@ tmpAL:8 = zext( A:4 ); tmpBL:8 = zext( B:4 ); - D = tmpAL * tmpBL; + temp:8 = tmpAL * tmpBL; + D = temp; } +# evmwumia RT,RA,RB +# ISA-cmt: Vector Multiply Word Unsigned, Modulo, Integer to Accumulator +# evmwumia rD,rA,rB 100 01A1 1000 A=1 +:evmwumia D,A,B is OP=4 & A & B & D & XOP_0_10=0x478 { + tmpAL:8 = zext( A:4 ); + tmpBL:8 = zext( B:4 ); + temp:8 = tmpAL * tmpBL; + D = temp; + ACC = D; +} + +# evmwumiaa RT,RA,RB +# ISA-cmt: Vector Multiply Word Unsigned, Modulo, Integer and Accumulate +# evmwumiaa rD,rA,rB 101 0101 1000 +# evmwumiaa confict with macchwo +:evmwumiaa D,A,B is OP=4 & A & B & D & XOP_0_10=0x558 { + tmpAL:8 = zext( A:4 ); + tmpBL:8 = zext( B:4 ); + + temp:8 = tmpAL * tmpBL; + D = ACC + temp; + ACC = D; +} # ================================================================= # Page 547 diff --git a/Ghidra/Processors/PowerPC/data/languages/evx.sinc b/Ghidra/Processors/PowerPC/data/languages/evx.sinc index 190b52513e..d2f68addb5 100644 --- a/Ghidra/Processors/PowerPC/data/languages/evx.sinc +++ b/Ghidra/Processors/PowerPC/data/languages/evx.sinc @@ -4,120 +4,6 @@ @include "SPE_APU.sinc" @endif -define pcodeop vectorExclusiveOr; -define pcodeop vectorMergeHigh; -define pcodeop vectorMergeLow; -define pcodeop vectorLoadDoubleWordIntoDoubleWordIndexed; -define pcodeop vectorStoreDoubleOfDoubleIndexed; -define pcodeop initializeAccumulator; -define pcodeop vectorShiftRightWordSigned; -define pcodeop vectorShiftRightWordUnsigned; - -:evxor vrD_64_0,vrA_64_0,vrB_64_0 is OP=4 & vrD_64_0 & vrA_64_0 & vrB_64_0 & XOP_0_10=534 -{ - vrD_64_0 = vrA_64_0 ^ vrB_64_0; -} - -@if REGISTER_SIZE=="8" -:evmergehi S,A,B is OP=4 & S & A & B & XOP_0_10=556 -{ - S[32,32] = A[32,32]; - S[ 0,32] = B[ 0,32]; -} - -:evmergelo S,A,B is OP=4 & S & A & B & XOP_0_10=557 -{ - S[32,32] = A[0,32]; - S[ 0,32] = B[0,32]; -} -@endif - - -:evldd RT,dUI16PlusRAOrZeroAddress is OP=4 & RT & dUI16PlusRAOrZeroAddress & XOP_0_10=769 -{ - ea:$(REGISTER_SIZE) = dUI16PlusRAOrZeroAddress; - RT = *:8 ($(EATRUNC)); -} - -:evlddx RT,RA_OR_ZERO,RB is OP=4 & RT & RA_OR_ZERO & RB & XOP_0_10=768 -{ - ea:$(REGISTER_SIZE) = RA_OR_ZERO + RB; - RT = *:8 ($(EATRUNC)); -} - -@if REGISTER_SIZE=="8" -@ifndef IS_ISA -:evsrws S,A,B is OP=4 & S & A & B & XOP_0_10=545 -{ - local low:4 = A[0,32]; - local high:4 = A[32,32]; - local low_shift:1 = B[0,5]; - local high_shift:1 = B[32,5]; - S[0,32] = low s>> zext(low_shift); - S[32,32] = high s>> zext(high_shift); -} -@endif - -@ifndef IS_ISA -:evsrwu S,A,B is OP=4 & S & A & B & XOP_0_10=544 -{ - local low:4 = A[0,32]; - local high:4 = A[32,32]; - local low_shift:1 = B[0,5]; - local high_shift:1 = B[32,5]; - S[0,32] = low >> zext(low_shift); - S[32,32] = high >> zext(high_shift); -} -@endif -@endif - -:evstdd RS,dUI16PlusRAOrZeroAddress is OP=4 & RS & dUI16PlusRAOrZeroAddress & XOP_0_10=801 -{ - ea:$(REGISTER_SIZE) = dUI16PlusRAOrZeroAddress; - *:8 ($(EATRUNC)) = RS; -} - -:evstddx RS,RA_OR_ZERO,RB is OP=4 & RS & RA_OR_ZERO & RB & XOP_0_10=800 -{ - ea:$(REGISTER_SIZE) = RA_OR_ZERO + RB; - *:8 ($(EATRUNC)) = RS; -} - -:evmra RT,RA is OP=4 & RT & RA & BITS_11_15=0 & XOP_0_10=1220 -{ - ACC = zext(RA); - RT = RA; -} - -@if REGISTER_SIZE=="8" -# evmergehilo rD,rA,rB 010 0010 1110 -:evmergehilo S,A,B is OP=4 & S & A & B & XOP_0_10=558 { - S[32,32] = A[32,32]; - S[ 0,32] = B[ 0,32]; - -} - -# evmergelohi rD,rA,rB 010 0010 1111 -:evmergelohi S,A,B is OP=4 & S & A & B & XOP_0_10=559 { - S[32,32] = A[ 0,32]; - S[ 0,32] = B[32,32]; -} -@endif - -# evstwwe rS,rA,UIMM 011 0011 1001 -:evstwwe RS,dUI16PlusRAOrZeroAddress is OP=4 & RS & dUI16PlusRAOrZeroAddress & XOP_0_10=0x339 -{ - ea:$(REGISTER_SIZE) = dUI16PlusRAOrZeroAddress; - *:4 ($(EATRUNC)) = RS:4; -} - -# evstwwex rS,rA,rB 011 0011 1000 -:evstwwex RS,RA_OR_ZERO,RB is OP=4 & RS & RA_OR_ZERO & RB & XOP_0_10=0x338 -{ - ea:$(REGISTER_SIZE) = RA_OR_ZERO + RB; - *:4 ($(EATRUNC)) = RS:4; -} - :lvx vrD, RA_OR_ZERO, RB is OP=31 & vrD & RA_OR_ZERO & RB & XOP_1_10=103 & BIT_0=0 { ea:$(REGISTER_SIZE) = RA_OR_ZERO + RB; diff --git a/Ghidra/Processors/PowerPC/data/languages/ppc_32_e500_be.slaspec b/Ghidra/Processors/PowerPC/data/languages/ppc_32_e500_be.slaspec index 5a9b490d75..7982406913 100644 --- a/Ghidra/Processors/PowerPC/data/languages/ppc_32_e500_be.slaspec +++ b/Ghidra/Processors/PowerPC/data/languages/ppc_32_e500_be.slaspec @@ -4,7 +4,7 @@ # by the actual processor (e.g., floating pointer registers and associated instructions). # The actual processor only supports a subset of the registers and instructions implemented. -@define E500 +@define E500 "1" @define ENDIAN "big" @@ -19,10 +19,11 @@ @define CTR_OFFSET "32" -@define NoLegacyIntegerMultiplyAccumulate +@define NoLegacyIntegerMultiplyAccumulate "1" @include "ppc_common.sinc" @include "quicciii.sinc" +@include "SPE_APU.sinc" @include "evx.sinc" @include "SPEF_SCR.sinc" @include "SPE_EFSD.sinc" diff --git a/Ghidra/Processors/PowerPC/data/languages/ppc_32_e500_le.slaspec b/Ghidra/Processors/PowerPC/data/languages/ppc_32_e500_le.slaspec index 719c022459..a905d79e8e 100644 --- a/Ghidra/Processors/PowerPC/data/languages/ppc_32_e500_le.slaspec +++ b/Ghidra/Processors/PowerPC/data/languages/ppc_32_e500_le.slaspec @@ -4,7 +4,7 @@ # by the actual processor (e.g., floating pointer registers and associated instructions). # The actual processor only supports a subset of the registers and instructions implemented. -@define E500 +@define E500 "1" @define ENDIAN "little" @@ -19,10 +19,11 @@ @define CTR_OFFSET "32" -@define NoLegacyIntegerMultiplyAccumulate +@define NoLegacyIntegerMultiplyAccumulate "1" @include "ppc_common.sinc" @include "quicciii.sinc" +@include "SPE_APU.sinc" @include "evx.sinc" @include "SPEF_SCR.sinc" @include "SPE_EFSD.sinc" diff --git a/Ghidra/Processors/PowerPC/data/languages/ppc_32_e500mc_be.slaspec b/Ghidra/Processors/PowerPC/data/languages/ppc_32_e500mc_be.slaspec index d95cc07227..2c6e098091 100644 --- a/Ghidra/Processors/PowerPC/data/languages/ppc_32_e500mc_be.slaspec +++ b/Ghidra/Processors/PowerPC/data/languages/ppc_32_e500mc_be.slaspec @@ -14,7 +14,7 @@ # @define CTR_OFFSET "32" -@define NoLegacyIntegerMultiplyAccumulate +@define NoLegacyIntegerMultiplyAccumulate "1" @include "ppc_common.sinc" @include "quicciii.sinc" diff --git a/Ghidra/Processors/PowerPC/data/languages/ppc_32_e500mc_le.slaspec b/Ghidra/Processors/PowerPC/data/languages/ppc_32_e500mc_le.slaspec index dd9a9c20b7..ba65acec9c 100644 --- a/Ghidra/Processors/PowerPC/data/languages/ppc_32_e500mc_le.slaspec +++ b/Ghidra/Processors/PowerPC/data/languages/ppc_32_e500mc_le.slaspec @@ -12,7 +12,7 @@ # @define CTR_OFFSET "32" -@define NoLegacyIntegerMultiplyAccumulate +@define NoLegacyIntegerMultiplyAccumulate "1" @include "ppc_common.sinc" @include "quicciii.sinc" diff --git a/Ghidra/Processors/PowerPC/data/languages/ppc_common.sinc b/Ghidra/Processors/PowerPC/data/languages/ppc_common.sinc index aaa76cc4ac..3a3d9a2e6a 100644 --- a/Ghidra/Processors/PowerPC/data/languages/ppc_common.sinc +++ b/Ghidra/Processors/PowerPC/data/languages/ppc_common.sinc @@ -1064,9 +1064,14 @@ define token instrvle(16) LK0_VLE=(0,0) ; -EVUIMM_2_RAt: val^"("^A^")" is A & EVUIMM_2 [ val = EVUIMM_2*2; ] { tmp:4 = A+(EVUIMM_2*2); export tmp; } -EVUIMM_4_RAt: val^"("^A^")" is A & EVUIMM_4 [ val = EVUIMM_4*4; ] { tmp:4 = A+(EVUIMM_4*4); export tmp; } -EVUIMM_8_RAt: val^"("^A^")" is A & EVUIMM_8 [ val = EVUIMM_8*8; ] { tmp:4 = A+(EVUIMM_8*8); export tmp; } +EVUIMM_2_RAt: val^"("^RA^")" is RA & A & EVUIMM_2 [ val = EVUIMM_2*2; ] { tmp:$(REGISTER_SIZE) = RA+zext(val:4); export tmp; } +EVUIMM_2_RAt: val^"("^RA^")" is RA & A=0 & EVUIMM_2 [ val = EVUIMM_2*2; ] { tmp:$(REGISTER_SIZE) = zext(val:4); export tmp; } + +EVUIMM_4_RAt: val^"("^RA^")" is RA & A & EVUIMM_4 [ val = EVUIMM_4*4; ] { tmp:$(REGISTER_SIZE) = RA+zext(val:4); export tmp; } +EVUIMM_4_RAt: val^"("^RA^")" is RA & A=0 & EVUIMM_4 [ val = EVUIMM_4*4; ] { tmp:$(REGISTER_SIZE) = zext(val:4); export tmp; } + +EVUIMM_8_RAt: val^"("^RA^")" is RA & A & EVUIMM_8 [ val = EVUIMM_8*8; ] { tmp:$(REGISTER_SIZE) = RA+zext(val:4); export tmp; } +EVUIMM_8_RAt: val^"("^RA^")" is RA & A=0 & EVUIMM_8 [ val = EVUIMM_8*8; ] { tmp:$(REGISTER_SIZE) = zext(val:4); export tmp; } attach variables [ T ] [ vs0 vs1 vs2 vs3 vs4 vs5 vs6 vs7 vs8 vs9 vs10 vs11 vs12 vs13 vs14 vs15 diff --git a/Ghidra/Processors/PowerPC/data/languages/ppc_embedded.sinc b/Ghidra/Processors/PowerPC/data/languages/ppc_embedded.sinc index f826beae39..0094d68cdf 100644 --- a/Ghidra/Processors/PowerPC/data/languages/ppc_embedded.sinc +++ b/Ghidra/Processors/PowerPC/data/languages/ppc_embedded.sinc @@ -49,6 +49,13 @@ dataCacheBlockClearToZero(ea); } +#dcbzl 0,r0 0x7c 20 07 ec +:dcbzl RA_OR_ZERO,B is OP=31 & BITS_21_25=1 & B & XOP_1_10=1014 & BIT_0=0 & RA_OR_ZERO +{ + ea:$(REGISTER_SIZE) = RA_OR_ZERO + B; + dataCacheBlockClearToZero(ea); +} + define pcodeop memoryBarrier; #mbar 0 7c 00 06 ac :mbar MO is OP=31 & MO & XOP_1_10=854 diff --git a/Ghidra/Processors/PowerPC/data/languages/ppc_vle.sinc b/Ghidra/Processors/PowerPC/data/languages/ppc_vle.sinc index c8bd8877e7..510bf96343 100644 --- a/Ghidra/Processors/PowerPC/data/languages/ppc_vle.sinc +++ b/Ghidra/Processors/PowerPC/data/languages/ppc_vle.sinc @@ -829,17 +829,17 @@ IMM16B: val is IMM_0_10_VLE & IMM_16_20_VLE [ val = (IMM_16_20_VLE << 11) | tmpS:4 = S:4; tmpA:4 = (tmpS << SHL) | (tmpS >> (32 - SHL)); - tmpM1 = (~0:4) << MBL; - tmpM1 = tmpM1 >> ((31-ME) + MBL); - tmpM1 = tmpM1 << (31-ME); + tmpM1:4 = (~0:4) << MBL; + tmpM1 = tmpM1 >> ((31-ME) + MBL); + tmpM1 = tmpM1 << (31-ME); - tmpM2 = (~0:4) << ME; - tmpM2 = tmpM2 >> ((31-MBL) + ME); - tmpM2 = tmpM2 << (31-MBL); - tmpM2 = ~tmpM2; + tmpM2:4 = (~0:4) << ME; + tmpM2 = tmpM2 >> ((31-MBL) + ME); + tmpM2 = tmpM2 << (31-MBL); + tmpM2 = ~tmpM2; local invert = (ME:1 < MBL:1); - tmpM = (zext(invert == 0)*tmpM1) + (zext(invert == 1)*tmpM2); + tmpM:4 = (zext(invert == 0)*tmpM1) + (zext(invert == 1)*tmpM2); A = zext(tmpA & tmpM) | (A & zext(~tmpM)); } @@ -847,17 +847,17 @@ IMM16B: val is IMM_0_10_VLE & IMM_16_20_VLE [ val = (IMM_16_20_VLE << 11) | tmpS:4 = S:4; tmpA:4 = (tmpS << SHL) | (tmpS >> (32 - SHL)); - tmpM1 = (~0:4) << MBL; - tmpM1 = tmpM1 >> ((31-ME) + MBL); - tmpM1 = tmpM1 << (31-ME); + tmpM1:4 = (~0:4) << MBL; + tmpM1 = tmpM1 >> ((31-ME) + MBL); + tmpM1 = tmpM1 << (31-ME); - tmpM2 = (~0:4) << ME; + tmpM2:4 = (~0:4) << ME; tmpM2 = tmpM2 >> ((31-MBL) + ME); tmpM2 = tmpM2 << (31-MBL); tmpM2 = ~tmpM2; local invert = (ME:1 < MBL:1); - tmpM = (zext(invert == 0)*tmpM1) + (zext(invert == 1)*tmpM2); + tmpM:4 = (zext(invert == 0)*tmpM1) + (zext(invert == 1)*tmpM2); A = zext(tmpA & tmpM); } diff --git a/Ghidra/Processors/PowerPC/data/patterns/PPC_BE_patterns.xml b/Ghidra/Processors/PowerPC/data/patterns/PPC_BE_patterns.xml index 4a9b96fc78..d69520f08d 100644 --- a/Ghidra/Processors/PowerPC/data/patterns/PPC_BE_patterns.xml +++ b/Ghidra/Processors/PowerPC/data/patterns/PPC_BE_patterns.xml @@ -6,6 +6,7 @@ 10010100 00100001 11...... .....000 + 011111.. ...01000 00000010 10100110 0x7c2c0b78 0x38 0x21 ........ ........ 0x91810000 @@ -17,8 +18,11 @@ 10010100 00100001 11...... .....000 011111.. ...01000 00000010 10100110 + 011111.. ...01000 00000010 10100110 10010100 00100001 11...... .....000 10010100 00100001 11...... .....000 0x........ 011111.. ...01000 00000010 10100110 + 011111.. ...01000 00000010 10100110 0x........ 10010100 00100001 11...... .....000 10010100 00100001 11...... .....000 0x........ 0x........ 011111.. ...01000 00000010 10100110 + 011111.. ...01000 00000010 10100110 0x........ 0x........ 10010100 00100001 11...... .....000 0x7c2c0b78 0x38 0x21 ........ ........ 0x91810000 @@ -31,6 +35,12 @@ + + 011111.. ...01000 00000010 10100110 10010100 00100001 11...... .....000 + + + + 0x4e 0x80 0x00 0x21 diff --git a/Ghidra/Processors/PowerPC/data/patterns/PPC_LE_patterns.xml b/Ghidra/Processors/PowerPC/data/patterns/PPC_LE_patterns.xml index e334a96bac..6e4e7b739e 100644 --- a/Ghidra/Processors/PowerPC/data/patterns/PPC_LE_patterns.xml +++ b/Ghidra/Processors/PowerPC/data/patterns/PPC_LE_patterns.xml @@ -6,6 +6,7 @@ .....000 11...... 00100001 10010100 + 10100110 00000010 ...01000 011111.. 0x780b2c7c ........ ........ 0x21 0x38 0x00008191 @@ -17,8 +18,11 @@ .....000 11...... 00100001 10010100 10100110 00000010 ...01000 011111.. + 10100110 00000010 ...01000 011111.. .....000 11...... 00100001 10010100 .....000 11...... 00100001 10010100 0x........ 10100110 00000010 ...01000 011111.. + 10100110 00000010 ...01000 011111.. 0x........ .....000 11...... 00100001 10010100 .....000 11...... 00100001 10010100 0x........ 0x........ 10100110 00000010 ...01000 011111.. + 10100110 00000010 ...01000 011111.. 0x........ 0x........ .....000 11...... 00100001 10010100 0x780b2c7c ........ ........ 0x21 0x38 0x00008191 @@ -31,6 +35,12 @@ + + 10100110 00000010 ...01000 011111.. .....000 11...... 00100001 10010100 + + + + 0x21 0x00 0x80 0x4e diff --git a/Ghidra/Processors/SuperH/data/languages/superh.cspec b/Ghidra/Processors/SuperH/data/languages/superh.cspec index 2a06d7a5a0..f73a1a27e7 100644 --- a/Ghidra/Processors/SuperH/data/languages/superh.cspec +++ b/Ghidra/Processors/SuperH/data/languages/superh.cspec @@ -62,6 +62,7 @@ + diff --git a/Ghidra/Processors/SuperH/data/languages/superh2a.cspec b/Ghidra/Processors/SuperH/data/languages/superh2a.cspec index 0114e1f5f8..aad2b1073e 100644 --- a/Ghidra/Processors/SuperH/data/languages/superh2a.cspec +++ b/Ghidra/Processors/SuperH/data/languages/superh2a.cspec @@ -78,6 +78,7 @@ + diff --git a/Ghidra/Processors/x86/data/languages/x86-64-swift.cspec b/Ghidra/Processors/x86/data/languages/x86-64-swift.cspec index 92af97dd4e..71bfa360ec 100644 --- a/Ghidra/Processors/x86/data/languages/x86-64-swift.cspec +++ b/Ghidra/Processors/x86/data/languages/x86-64-swift.cspec @@ -32,7 +32,7 @@ - + @@ -146,7 +146,7 @@ - + diff --git a/Ghidra/RuntimeScripts/Windows/ghidraRun.bat b/Ghidra/RuntimeScripts/Windows/ghidraRun.bat index 36bcb0227a..a4117fa6e3 100644 --- a/Ghidra/RuntimeScripts/Windows/ghidraRun.bat +++ b/Ghidra/RuntimeScripts/Windows/ghidraRun.bat @@ -1,3 +1,18 @@ +:: ### +:: IP: GHIDRA +:: +:: Licensed under the Apache License, Version 2.0 (the "License"); +:: you may not use this file except in compliance with the License. +:: You may obtain a copy of the License at +:: +:: http://www.apache.org/licenses/LICENSE-2.0 +:: +:: Unless required by applicable law or agreed to in writing, software +:: distributed under the License is distributed on an "AS IS" BASIS, +:: WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +:: See the License for the specific language governing permissions and +:: limitations under the License. +:: ## :: Ghidra launch @echo off diff --git a/Ghidra/RuntimeScripts/Windows/server/ghidraSvr.bat b/Ghidra/RuntimeScripts/Windows/server/ghidraSvr.bat index 41e2467e8e..702cbb7f6a 100644 --- a/Ghidra/RuntimeScripts/Windows/server/ghidraSvr.bat +++ b/Ghidra/RuntimeScripts/Windows/server/ghidraSvr.bat @@ -1,3 +1,18 @@ +:: ### +:: IP: GHIDRA +:: +:: Licensed under the Apache License, Version 2.0 (the "License"); +:: you may not use this file except in compliance with the License. +:: You may obtain a copy of the License at +:: +:: http://www.apache.org/licenses/LICENSE-2.0 +:: +:: Unless required by applicable law or agreed to in writing, software +:: distributed under the License is distributed on an "AS IS" BASIS, +:: WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +:: See the License for the specific language governing permissions and +:: limitations under the License. +:: ## @echo off :: --------------------------------------------------------------------------------------- diff --git a/Ghidra/RuntimeScripts/Windows/server/svrAdmin.bat b/Ghidra/RuntimeScripts/Windows/server/svrAdmin.bat index debb9b3503..f467a11642 100644 --- a/Ghidra/RuntimeScripts/Windows/server/svrAdmin.bat +++ b/Ghidra/RuntimeScripts/Windows/server/svrAdmin.bat @@ -1,3 +1,18 @@ +:: ### +:: IP: GHIDRA +:: +:: Licensed under the Apache License, Version 2.0 (the "License"); +:: you may not use this file except in compliance with the License. +:: You may obtain a copy of the License at +:: +:: http://www.apache.org/licenses/LICENSE-2.0 +:: +:: Unless required by applicable law or agreed to in writing, software +:: distributed under the License is distributed on an "AS IS" BASIS, +:: WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +:: See the License for the specific language governing permissions and +:: limitations under the License. +:: ## @echo off :: *********************************************************** diff --git a/Ghidra/RuntimeScripts/Windows/server/svrInstall.bat b/Ghidra/RuntimeScripts/Windows/server/svrInstall.bat index 2e73d7afab..1f6d95c6c7 100644 --- a/Ghidra/RuntimeScripts/Windows/server/svrInstall.bat +++ b/Ghidra/RuntimeScripts/Windows/server/svrInstall.bat @@ -1,3 +1,18 @@ +:: ### +:: IP: GHIDRA +:: +:: Licensed under the Apache License, Version 2.0 (the "License"); +:: you may not use this file except in compliance with the License. +:: You may obtain a copy of the License at +:: +:: http://www.apache.org/licenses/LICENSE-2.0 +:: +:: Unless required by applicable law or agreed to in writing, software +:: distributed under the License is distributed on an "AS IS" BASIS, +:: WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +:: See the License for the specific language governing permissions and +:: limitations under the License. +:: ## @echo off setlocal diff --git a/Ghidra/RuntimeScripts/Windows/server/svrUninstall.bat b/Ghidra/RuntimeScripts/Windows/server/svrUninstall.bat index eb58d014c4..05dd76eb65 100644 --- a/Ghidra/RuntimeScripts/Windows/server/svrUninstall.bat +++ b/Ghidra/RuntimeScripts/Windows/server/svrUninstall.bat @@ -1,3 +1,18 @@ +:: ### +:: IP: GHIDRA +:: +:: Licensed under the Apache License, Version 2.0 (the "License"); +:: you may not use this file except in compliance with the License. +:: You may obtain a copy of the License at +:: +:: http://www.apache.org/licenses/LICENSE-2.0 +:: +:: Unless required by applicable law or agreed to in writing, software +:: distributed under the License is distributed on an "AS IS" BASIS, +:: WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +:: See the License for the specific language governing permissions and +:: limitations under the License. +:: ## @echo off setlocal diff --git a/Ghidra/RuntimeScripts/Windows/support/GhidraGo/ghidraGo.bat b/Ghidra/RuntimeScripts/Windows/support/GhidraGo/ghidraGo.bat index 8a7061b997..33a97f012d 100644 --- a/Ghidra/RuntimeScripts/Windows/support/GhidraGo/ghidraGo.bat +++ b/Ghidra/RuntimeScripts/Windows/support/GhidraGo/ghidraGo.bat @@ -1,3 +1,18 @@ +:: ### +:: IP: GHIDRA +:: +:: Licensed under the Apache License, Version 2.0 (the "License"); +:: you may not use this file except in compliance with the License. +:: You may obtain a copy of the License at +:: +:: http://www.apache.org/licenses/LICENSE-2.0 +:: +:: Unless required by applicable law or agreed to in writing, software +:: distributed under the License is distributed on an "AS IS" BASIS, +:: WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +:: See the License for the specific language governing permissions and +:: limitations under the License. +:: ## :: GhidraGo launch @echo off diff --git a/Ghidra/RuntimeScripts/Windows/support/analyzeHeadless.bat b/Ghidra/RuntimeScripts/Windows/support/analyzeHeadless.bat index e577293f24..496ae49803 100644 --- a/Ghidra/RuntimeScripts/Windows/support/analyzeHeadless.bat +++ b/Ghidra/RuntimeScripts/Windows/support/analyzeHeadless.bat @@ -1,3 +1,18 @@ +:: ### +:: IP: GHIDRA +:: +:: Licensed under the Apache License, Version 2.0 (the "License"); +:: you may not use this file except in compliance with the License. +:: You may obtain a copy of the License at +:: +:: http://www.apache.org/licenses/LICENSE-2.0 +:: +:: Unless required by applicable law or agreed to in writing, software +:: distributed under the License is distributed on an "AS IS" BASIS, +:: WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +:: See the License for the specific language governing permissions and +:: limitations under the License. +:: ## :: Ghidra Headless Analyzer launch (see analyzeHeadlessREADME.html) @echo off diff --git a/Ghidra/RuntimeScripts/Windows/support/bsim.bat b/Ghidra/RuntimeScripts/Windows/support/bsim.bat index fcc059ca19..7cad14976d 100644 --- a/Ghidra/RuntimeScripts/Windows/support/bsim.bat +++ b/Ghidra/RuntimeScripts/Windows/support/bsim.bat @@ -1,3 +1,18 @@ +:: ### +:: IP: GHIDRA +:: +:: Licensed under the Apache License, Version 2.0 (the "License"); +:: you may not use this file except in compliance with the License. +:: You may obtain a copy of the License at +:: +:: http://www.apache.org/licenses/LICENSE-2.0 +:: +:: Unless required by applicable law or agreed to in writing, software +:: distributed under the License is distributed on an "AS IS" BASIS, +:: WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +:: See the License for the specific language governing permissions and +:: limitations under the License. +:: ## :: Command-line script for interacting with a BSim database @echo off diff --git a/Ghidra/RuntimeScripts/Windows/support/buildGhidraJar.bat b/Ghidra/RuntimeScripts/Windows/support/buildGhidraJar.bat index 4ae026640e..96e0f3323a 100644 --- a/Ghidra/RuntimeScripts/Windows/support/buildGhidraJar.bat +++ b/Ghidra/RuntimeScripts/Windows/support/buildGhidraJar.bat @@ -1,3 +1,18 @@ +:: ### +:: IP: GHIDRA +:: +:: Licensed under the Apache License, Version 2.0 (the "License"); +:: you may not use this file except in compliance with the License. +:: You may obtain a copy of the License at +:: +:: http://www.apache.org/licenses/LICENSE-2.0 +:: +:: Unless required by applicable law or agreed to in writing, software +:: distributed under the License is distributed on an "AS IS" BASIS, +:: WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +:: See the License for the specific language governing permissions and +:: limitations under the License. +:: ## :: Ghidra Jar Builder launch @echo off diff --git a/Ghidra/RuntimeScripts/Windows/support/convertStorage.bat b/Ghidra/RuntimeScripts/Windows/support/convertStorage.bat index 7e6a894651..66912c65c7 100644 --- a/Ghidra/RuntimeScripts/Windows/support/convertStorage.bat +++ b/Ghidra/RuntimeScripts/Windows/support/convertStorage.bat @@ -1,3 +1,18 @@ +:: ### +:: IP: GHIDRA +:: +:: Licensed under the Apache License, Version 2.0 (the "License"); +:: you may not use this file except in compliance with the License. +:: You may obtain a copy of the License at +:: +:: http://www.apache.org/licenses/LICENSE-2.0 +:: +:: Unless required by applicable law or agreed to in writing, software +:: distributed under the License is distributed on an "AS IS" BASIS, +:: WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +:: See the License for the specific language governing permissions and +:: limitations under the License. +:: ## :: Ghidra Filesystem Conversion launch @echo off diff --git a/Ghidra/RuntimeScripts/Windows/support/createPdbXmlFiles.bat b/Ghidra/RuntimeScripts/Windows/support/createPdbXmlFiles.bat index fed8c216c4..c0e9b52176 100644 --- a/Ghidra/RuntimeScripts/Windows/support/createPdbXmlFiles.bat +++ b/Ghidra/RuntimeScripts/Windows/support/createPdbXmlFiles.bat @@ -1,3 +1,18 @@ +:: ### +:: IP: GHIDRA +:: +:: Licensed under the Apache License, Version 2.0 (the "License"); +:: you may not use this file except in compliance with the License. +:: You may obtain a copy of the License at +:: +:: http://www.apache.org/licenses/LICENSE-2.0 +:: +:: Unless required by applicable law or agreed to in writing, software +:: distributed under the License is distributed on an "AS IS" BASIS, +:: WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +:: See the License for the specific language governing permissions and +:: limitations under the License. +:: ## :: Script that takes either a single .pdb file or a directory :: that contains .pdb files (search for files is recursive). :: diff --git a/Ghidra/RuntimeScripts/Windows/support/dbgengGADPServerRun.bat b/Ghidra/RuntimeScripts/Windows/support/dbgengGADPServerRun.bat index 58747dbeb6..820daf39cb 100644 --- a/Ghidra/RuntimeScripts/Windows/support/dbgengGADPServerRun.bat +++ b/Ghidra/RuntimeScripts/Windows/support/dbgengGADPServerRun.bat @@ -1,3 +1,18 @@ +:: ### +:: IP: GHIDRA +:: +:: Licensed under the Apache License, Version 2.0 (the "License"); +:: you may not use this file except in compliance with the License. +:: You may obtain a copy of the License at +:: +:: http://www.apache.org/licenses/LICENSE-2.0 +:: +:: Unless required by applicable law or agreed to in writing, software +:: distributed under the License is distributed on an "AS IS" BASIS, +:: WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +:: See the License for the specific language governing permissions and +:: limitations under the License. +:: ## :: GADP Server launch @echo off diff --git a/Ghidra/RuntimeScripts/Windows/support/dbgmodelGADPServerRun.bat b/Ghidra/RuntimeScripts/Windows/support/dbgmodelGADPServerRun.bat index 163a00c823..2106c0bf22 100644 --- a/Ghidra/RuntimeScripts/Windows/support/dbgmodelGADPServerRun.bat +++ b/Ghidra/RuntimeScripts/Windows/support/dbgmodelGADPServerRun.bat @@ -1,3 +1,18 @@ +:: ### +:: IP: GHIDRA +:: +:: Licensed under the Apache License, Version 2.0 (the "License"); +:: you may not use this file except in compliance with the License. +:: You may obtain a copy of the License at +:: +:: http://www.apache.org/licenses/LICENSE-2.0 +:: +:: Unless required by applicable law or agreed to in writing, software +:: distributed under the License is distributed on an "AS IS" BASIS, +:: WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +:: See the License for the specific language governing permissions and +:: limitations under the License. +:: ## :: GADP Server launch @echo off diff --git a/Ghidra/RuntimeScripts/Windows/support/ghidraClean.bat b/Ghidra/RuntimeScripts/Windows/support/ghidraClean.bat index 8b8c4a59fb..49e506f737 100644 --- a/Ghidra/RuntimeScripts/Windows/support/ghidraClean.bat +++ b/Ghidra/RuntimeScripts/Windows/support/ghidraClean.bat @@ -1,3 +1,18 @@ +:: ### +:: IP: GHIDRA +:: +:: Licensed under the Apache License, Version 2.0 (the "License"); +:: you may not use this file except in compliance with the License. +:: You may obtain a copy of the License at +:: +:: http://www.apache.org/licenses/LICENSE-2.0 +:: +:: Unless required by applicable law or agreed to in writing, software +:: distributed under the License is distributed on an "AS IS" BASIS, +:: WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +:: See the License for the specific language governing permissions and +:: limitations under the License. +:: ## :: Ghidra-Clean :: An interactive utility to discover and delete artifacts that Ghidra lays down on the filesystem. @@ -6,4 +21,4 @@ setlocal set VMARG_LIST=-Djava.awt.headless=true -call "%~dp0launch.bat" fg jdk Ghidra-Clean "" "" utility.application.AppCleaner Ghidra \ No newline at end of file +call "%~dp0launch.bat" fg jdk Ghidra-Clean "" "" utility.application.AppCleaner Ghidra diff --git a/Ghidra/RuntimeScripts/Windows/support/ghidraDebug.bat b/Ghidra/RuntimeScripts/Windows/support/ghidraDebug.bat index 5b335a0fb5..e5d6f1f1c0 100644 --- a/Ghidra/RuntimeScripts/Windows/support/ghidraDebug.bat +++ b/Ghidra/RuntimeScripts/Windows/support/ghidraDebug.bat @@ -1,3 +1,18 @@ +:: ### +:: IP: GHIDRA +:: +:: Licensed under the Apache License, Version 2.0 (the "License"); +:: you may not use this file except in compliance with the License. +:: You may obtain a copy of the License at +:: +:: http://www.apache.org/licenses/LICENSE-2.0 +:: +:: Unless required by applicable law or agreed to in writing, software +:: distributed under the License is distributed on an "AS IS" BASIS, +:: WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +:: See the License for the specific language governing permissions and +:: limitations under the License. +:: ## :: Ghidra debug launch @echo off diff --git a/Ghidra/RuntimeScripts/Windows/support/jshellRun.bat b/Ghidra/RuntimeScripts/Windows/support/jshellRun.bat index 37238450c0..155b46b916 100644 --- a/Ghidra/RuntimeScripts/Windows/support/jshellRun.bat +++ b/Ghidra/RuntimeScripts/Windows/support/jshellRun.bat @@ -1,3 +1,18 @@ +:: ### +:: IP: GHIDRA +:: +:: Licensed under the Apache License, Version 2.0 (the "License"); +:: you may not use this file except in compliance with the License. +:: You may obtain a copy of the License at +:: +:: http://www.apache.org/licenses/LICENSE-2.0 +:: +:: Unless required by applicable law or agreed to in writing, software +:: distributed under the License is distributed on an "AS IS" BASIS, +:: WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +:: See the License for the specific language governing permissions and +:: limitations under the License. +:: ## :: Ghidra JShell launch @echo off diff --git a/Ghidra/RuntimeScripts/Windows/support/jythonRun.bat b/Ghidra/RuntimeScripts/Windows/support/jythonRun.bat index 8782f9cec7..a4ae43bf51 100644 --- a/Ghidra/RuntimeScripts/Windows/support/jythonRun.bat +++ b/Ghidra/RuntimeScripts/Windows/support/jythonRun.bat @@ -1,3 +1,18 @@ +:: ### +:: IP: GHIDRA +:: +:: Licensed under the Apache License, Version 2.0 (the "License"); +:: you may not use this file except in compliance with the License. +:: You may obtain a copy of the License at +:: +:: http://www.apache.org/licenses/LICENSE-2.0 +:: +:: Unless required by applicable law or agreed to in writing, software +:: distributed under the License is distributed on an "AS IS" BASIS, +:: WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +:: See the License for the specific language governing permissions and +:: limitations under the License. +:: ## :: Ghidra jython launch @echo off diff --git a/Ghidra/RuntimeScripts/Windows/support/launch.bat b/Ghidra/RuntimeScripts/Windows/support/launch.bat index 47c95d81b6..ca6b5d94f8 100644 --- a/Ghidra/RuntimeScripts/Windows/support/launch.bat +++ b/Ghidra/RuntimeScripts/Windows/support/launch.bat @@ -1,3 +1,18 @@ +:: ### +:: IP: GHIDRA +:: +:: Licensed under the Apache License, Version 2.0 (the "License"); +:: you may not use this file except in compliance with the License. +:: You may obtain a copy of the License at +:: +:: http://www.apache.org/licenses/LICENSE-2.0 +:: +:: Unless required by applicable law or agreed to in writing, software +:: distributed under the License is distributed on an "AS IS" BASIS, +:: WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +:: See the License for the specific language governing permissions and +:: limitations under the License. +:: ## @echo off goto continue diff --git a/Ghidra/RuntimeScripts/Windows/support/pyghidraRun.bat b/Ghidra/RuntimeScripts/Windows/support/pyghidraRun.bat index 2af21aac33..96e331ec67 100644 --- a/Ghidra/RuntimeScripts/Windows/support/pyghidraRun.bat +++ b/Ghidra/RuntimeScripts/Windows/support/pyghidraRun.bat @@ -1,3 +1,18 @@ +:: ### +:: IP: GHIDRA +:: +:: Licensed under the Apache License, Version 2.0 (the "License"); +:: you may not use this file except in compliance with the License. +:: You may obtain a copy of the License at +:: +:: http://www.apache.org/licenses/LICENSE-2.0 +:: +:: Unless required by applicable law or agreed to in writing, software +:: distributed under the License is distributed on an "AS IS" BASIS, +:: WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +:: See the License for the specific language governing permissions and +:: limitations under the License. +:: ## :: PyGhidra launch @echo off diff --git a/Ghidra/RuntimeScripts/Windows/support/sleigh.bat b/Ghidra/RuntimeScripts/Windows/support/sleigh.bat index 8b602f8024..15003568de 100644 --- a/Ghidra/RuntimeScripts/Windows/support/sleigh.bat +++ b/Ghidra/RuntimeScripts/Windows/support/sleigh.bat @@ -1,3 +1,18 @@ +:: ### +:: IP: GHIDRA +:: +:: Licensed under the Apache License, Version 2.0 (the "License"); +:: you may not use this file except in compliance with the License. +:: You may obtain a copy of the License at +:: +:: http://www.apache.org/licenses/LICENSE-2.0 +:: +:: Unless required by applicable law or agreed to in writing, software +:: distributed under the License is distributed on an "AS IS" BASIS, +:: WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +:: See the License for the specific language governing permissions and +:: limitations under the License. +:: ## :: Ghidra Sleigh language compiler launch @echo off diff --git a/Ghidra/RuntimeScripts/certification.manifest b/Ghidra/RuntimeScripts/certification.manifest index c50f377991..339a44c4c2 100644 --- a/Ghidra/RuntimeScripts/certification.manifest +++ b/Ghidra/RuntimeScripts/certification.manifest @@ -30,25 +30,5 @@ Linux/support/jshellRun||GHIDRA||||END| Linux/support/jythonRun||GHIDRA||||END| Linux/support/pyghidraRun||GHIDRA||||END| Linux/support/sleigh||GHIDRA||||END| -Windows/ghidraRun.bat||GHIDRA||||END| -Windows/server/ghidraSvr.bat||GHIDRA||||END| -Windows/server/svrAdmin.bat||GHIDRA||||END| -Windows/server/svrInstall.bat||GHIDRA||||END| -Windows/server/svrUninstall.bat||GHIDRA||||END| -Windows/support/GhidraGo/ghidraGo.bat||GHIDRA||||END| Windows/support/README_createPdbXmlFiles.txt||GHIDRA||||END| -Windows/support/analyzeHeadless.bat||GHIDRA||||END| -Windows/support/bsim.bat||GHIDRA||||END| -Windows/support/buildGhidraJar.bat||GHIDRA||||END| -Windows/support/convertStorage.bat||GHIDRA||||END| -Windows/support/createPdbXmlFiles.bat||GHIDRA||||END| -Windows/support/dbgengGADPServerRun.bat||GHIDRA||||END| -Windows/support/dbgmodelGADPServerRun.bat||GHIDRA||||END| Windows/support/ghidra.ico||GHIDRA||||END| -Windows/support/ghidraClean.bat||GHIDRA||||END| -Windows/support/ghidraDebug.bat||GHIDRA||||END| -Windows/support/jshellRun.bat||GHIDRA||||END| -Windows/support/jythonRun.bat||GHIDRA||||END| -Windows/support/launch.bat||GHIDRA||||END| -Windows/support/pyghidraRun.bat||GHIDRA||||END| -Windows/support/sleigh.bat||GHIDRA||||END| diff --git a/Ghidra/application.properties b/Ghidra/application.properties index e9bab12548..f5c62f1219 100644 --- a/Ghidra/application.properties +++ b/Ghidra/application.properties @@ -1,5 +1,5 @@ application.name=Ghidra -application.version=11.4.1 +application.version=11.4.2 application.release.name=DEV application.layout.version=3 application.gradle.min=8.5 diff --git a/build.gradle b/build.gradle index 159eb7dd7b..da978cca88 100644 --- a/build.gradle +++ b/build.gradle @@ -16,7 +16,6 @@ apply plugin: 'eclipse' apply from: 'gradle/root/eclipse.gradle' -apply from: "gradle/support/eclipseLauncher.gradle" apply from: "gradle/support/loadApplicationProperties.gradle" diff --git a/certification.local.manifest b/certification.local.manifest index f5bd4d865f..41a63dceb1 100644 --- a/certification.local.manifest +++ b/certification.local.manifest @@ -11,4 +11,3 @@ README.md||GHIDRA||||END| ghidra.repos.config||GHIDRA||||END| gradle.properties||GHIDRA||||END| gradlew||Apache License 2.0||||END| -gradlew.bat||Apache License 2.0||||END| diff --git a/gradle.properties b/gradle.properties index 879249cd9f..350935b0ba 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,3 +1,6 @@ # Increase maximum Gradle heap size (default is 1G) # And fix build in locales with non-default capitalizations (e.g. tr_TR) org.gradle.jvmargs=-Xmx2G -Duser.language=en -Duser.country=US + +# Preserve file system permisisons in archives (Gradle 9 uses fixed permissions by default) +org.gradle.archives.use-file-system-permissions=true diff --git a/gradle/support/eclipseLauncher.gradle b/gradle/support/eclipseLauncher.gradle deleted file mode 100644 index d45c0f1faf..0000000000 --- a/gradle/support/eclipseLauncher.gradle +++ /dev/null @@ -1,164 +0,0 @@ -/* ### - * IP: GHIDRA - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -import org.gradle.api.*; -import org.gradle.artifacts.*; -import org.gradle.process.JavaExecSpec; -import org.gradle.api.file.*; -import org.gradle.api.tasks.*; -import org.gradle.api.internal.file.UnionFileCollection; - -import groovy.xml.MarkupBuilder; - -public class WriteEclipseLauncher extends JavaExec { - @OutputFile - File dest; - - @Input - boolean isRunFave = false; - - @Input - boolean isDbgFave = false; - - @Input - boolean useEclipseDefaultClasspath = false - - public E one(Collection col) { - assert col.size() == 1; - return col.iterator().next(); - } - - void walkFileCollection(UnionFileCollection col, Set gathered) { - col.sources.each { - walkFileCollection(it, gathered); - } - } - - void walkFileCollection(ConfigurableFileCollection col, Set gathered) { - col.from.each { - walkFileCollection(it, gathered); - } - } - - void walkFileCollection(SourceSetOutput col, Set gathered) { - gathered.add(col); - } - - void walkFileCollection(Configuration col, Set gathered) { - col.allDependencies.each { - walkDependency(it, gathered) - } - } - - void walkDependency(ExternalModuleDependency dep, Set gathered) { - gathered.add(dep) - } - - void walkDependency(ProjectDependency dep, Set gathered) { - gathered.add(dep) - Project project = dep.dependencyProject - String confName = dep.targetConfiguration ?: 'default' - Configuration configuration = project.configurations."$confName" - walkFileCollection(configuration, gathered) - } - - String makeEntryXml(ExternalModuleDependency dep, FileCollection cp) { - def writer = new StringWriter(); - def xml = new MarkupBuilder(writer); - def file = cp.find { it.name.contains(dep.name) } - xml.mkp.xmlDeclaration(version: '1.0', encoding: 'UTF-8', standalone: 'no') - xml.runtimeClasspathEntry( - externalArchive: file, - path: 5, - // TODO: Figure out source jar - type: 2 - ); - return writer - } - - String makeEntryXml(Project proj) { - def writer = new StringWriter(); - def xml = new MarkupBuilder(writer); - xml.mkp.xmlDeclaration(version: '1.0', encoding: 'UTF-8', standalone: 'no') - xml.runtimeClasspathEntry( - path: 5, - projectName: proj.eclipse.project.name, - type: 1 - ) - return writer - } - - String makeEntryXml(ProjectDependency dep, FileCollection cp) { - return makeEntryXml(dep.dependencyProject); - } - - String makeEntryXml(SourceSetOutput out, FileCollection cp) { - Task task = one(out.buildDependencies.getDependencies(null)) - return makeEntryXml(task.project) - } - - public File forName(String name) { - return project.file(".launch/${name}.launch") - } - - List getJvmArgumentsForEclipse() { - List all = allJvmArgs; - int index = all.indexOf('-cp'); - if (index == -1) { - return all; - } - all.remove(index); - all.remove(index); - return all; - } - - @TaskAction - void exec() { // Override exec. Instead write launcher - dest.parentFile.mkdirs(); - def launcher = new MarkupBuilder(new FileWriter(dest)); - Set gathered = new LinkedHashSet(); - if (!useEclipseDefaultClasspath) { - walkFileCollection(classpath, gathered); - } - launcher.mkp.xmlDeclaration(version: '1.0', encoding: 'UTF-8', standalone: 'no') - launcher.launchConfiguration(type: 'org.eclipse.jdt.launching.localJavaApplication') { - listAttribute(key: 'org.eclipse.debug.ui.favoriteGroups') { - if (isRunFave) { - listEntry(value: 'org.eclipse.debug.ui.launchGroup.run'); - } - if (isDbgFave) { - listEntry(value: 'org.eclipse.debug.ui.launchGroup.debug'); - } - } - if (!useEclipseDefaultClasspath) { - listAttribute(key: 'org.eclipse.jdt.launching.CLASSPATH') { - gathered.each { - listEntry(value: makeEntryXml(it, classpath)) - } - } - } - booleanAttribute(key: 'org.eclipse.jdt.launching.DEFAULT_CLASSPATH', value: useEclipseDefaultClasspath); - stringAttribute(key: 'org.eclipse.jdt.launching.MAIN_TYPE', value: main); - // TODO: Proper escaping of program and JVM arguments. - stringAttribute(key: 'org.eclipse.jdt.launching.PROGRAM_ARGUMENTS', value: args.join(' ')); - stringAttribute(key: 'org.eclipse.jdt.launching.PROJECT_ATTR', value: project.eclipse.project.name); - stringAttribute(key: 'org.eclipse.jdt.launching.VM_ARGUMENTS', value: jvmArgumentsForEclipse.join(' ')); - } - } -} - -allprojects { - ext.WriteEclipseLauncher = WriteEclipseLauncher -} diff --git a/gradle/support/ip.gradle b/gradle/support/ip.gradle index bedd453246..8244aa2786 100644 --- a/gradle/support/ip.gradle +++ b/gradle/support/ip.gradle @@ -217,10 +217,21 @@ def isBashSourceFile(File file) { // NOTE: bash/shell scripts without extension will not utilize a header return filename.endsWith(".py") || filename.endsWith(".sh") || + filename.endsWith(".ps1") || filename.endsWith(".bash") || filename.endsWith(".command"); } +/********************************************************************************* + * checks if a file supports a Windows Batch style header based on its extension. + *********************************************************************************/ +def isBatchSourceFile(File file) { + + String filename = file.getName().toLowerCase(); + + return filename.endsWith(".bat"); +} + /********************************************************************************* * Gets the ip for a file in the module from its header (or certification.manifest) @@ -236,6 +247,9 @@ def getIp(File projectDir, File file) { ip = getIpForSourceFile(file, "# IP:"); } } + else if (isBatchSourceFile(file)) { + ip = getIpForSourceFile(file, ":: IP:"); + } if (ip == null) { ip = getIpForNonSourceFile(projectDir, file); } diff --git a/gradle/support/sbom.gradle b/gradle/support/sbom.gradle index 806c0334a1..62c22b9104 100644 --- a/gradle/support/sbom.gradle +++ b/gradle/support/sbom.gradle @@ -4,9 +4,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -15,6 +15,7 @@ */ import java.util.jar.JarFile import groovy.json.JsonOutput +import groovy.xml.XmlSlurper /****************************************************************************************** * diff --git a/gradlew b/gradlew index 5650f893ce..72670208f6 100755 --- a/gradlew +++ b/gradlew @@ -128,7 +128,7 @@ fi # Read application properties while IFS='=' read -r key value do - key=$(echo $key | tr '.' '_') + key=$(echo $key | tr '.-' '_') eval ${key}=\${value} done < "${GHIDRA_HOME}/Ghidra/application.properties" diff --git a/gradlew.bat b/gradlew.bat index eb0c161e41..5ee39252b5 100644 --- a/gradlew.bat +++ b/gradlew.bat @@ -1,3 +1,6 @@ +:: ### +:: IP: Apache License 2.0 +:: ## @rem @rem Copyright 2015 the original author or authors. @rem