From a908bbeeb5af9f51bad279cd6eb19ce7153bd7cd Mon Sep 17 00:00:00 2001 From: Jannis Harder Date: Sat, 8 Jun 2024 22:49:38 +0200 Subject: [PATCH 1/6] Add unused but required vectorPermute pcodeop (#82) This, including the comment, is copied from Ghidra's PPC definitions. Without the vectorPermute pcodeop defined, the PPCEmulateInstructionStateModifier class produces an exception, breaking all Ghidra functionality that depends on pcode emulation. --- data/languages/ppc_gekko_broadway.slaspec | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/data/languages/ppc_gekko_broadway.slaspec b/data/languages/ppc_gekko_broadway.slaspec index 6324b8d..d1979ca 100644 --- a/data/languages/ppc_gekko_broadway.slaspec +++ b/data/languages/ppc_gekko_broadway.slaspec @@ -799,6 +799,10 @@ define pcodeop TLBWrite; define pcodeop WriteExternalEnable; define pcodeop WriteExternalEnableImmediate; +# This is really used in the altivec version, but since it's a registered pcode op +# and due to the way things get @included, this needs to be here +define pcodeop vectorPermute; + ################################################################ # Macros ################################################################ From cf626962429312aa6330f1556d2d273e5c16e083 Mon Sep 17 00:00:00 2001 From: Aiden <86704247+vabold@users.noreply.github.com> Date: Fri, 14 Jun 2024 12:23:04 -0400 Subject: [PATCH 2/6] Fix REL section and symbol loading Co-Authored-By: Seeky <58006653+seekyct@users.noreply.github.com> --- .../java/gamecubeloader/rel/RELHeader.java | 6 ++- .../gamecubeloader/rel/RELProgramBuilder.java | 42 +++++++++++++++---- 2 files changed, 38 insertions(+), 10 deletions(-) diff --git a/src/main/java/gamecubeloader/rel/RELHeader.java b/src/main/java/gamecubeloader/rel/RELHeader.java index 4b0ef01..4fc3b34 100644 --- a/src/main/java/gamecubeloader/rel/RELHeader.java +++ b/src/main/java/gamecubeloader/rel/RELHeader.java @@ -148,7 +148,7 @@ public boolean IsValid(BinaryReader reader) { } public int Size() { - switch ((int) this.moduleId) { + switch ((int) this.moduleVersion) { case 0: case 1: return 0x40; @@ -161,4 +161,8 @@ public int Size() { return 0x4C; } } + + public int FullSize() { + return this.Size() + (int) this.sectionCount * 8; + } } diff --git a/src/main/java/gamecubeloader/rel/RELProgramBuilder.java b/src/main/java/gamecubeloader/rel/RELProgramBuilder.java index f257553..d949d70 100644 --- a/src/main/java/gamecubeloader/rel/RELProgramBuilder.java +++ b/src/main/java/gamecubeloader/rel/RELProgramBuilder.java @@ -244,16 +244,17 @@ else if (fileName.endsWith(".rel") || fileName.endsWith(".szs") || fileName.ends var isText = (section.address & RELProgramBuilder.EXECUTABLE_SECTION) != 0; var blockName = String.format("%s_%s%d", relInfo.name, isText ? ".text" : ".data", isText ? textCount : dataCount); - MemoryBlockUtils.createInitializedBlock(this.program, false, blockName, this.addressSpace.getAddress(currentOutputAddress), - relInfo.reader.getByteProvider().getInputStream(section.address & ~1), section.size, "", null, true, true, isText, null, this.monitor); + // Update the address of the section with its virtual memory address. + var offs = section.address & ~1; + section.address = relBaseAddress + offs; + + MemoryBlockUtils.createInitializedBlock(this.program, false, blockName, this.addressSpace.getAddress(section.address), + relInfo.reader.getByteProvider().getInputStream(offs), section.size, "", null, true, true, isText, null, this.monitor); if (isText) textCount++; else dataCount++; - // Update the address of the section with it's virtual memory address. - section.address = currentOutputAddress; - - currentOutputAddress += section.size; + currentOutputAddress = section.address + section.size; // Ensure output address is aligned to 4 bytes if ((currentOutputAddress & 3) != 0) { @@ -268,7 +269,30 @@ else if (relInfo.header.bssSectionId == 0) { // Add bss section. if (relInfo.header.bssSize != 0 && relInfo.header.bssSectionId != 0) { - if (relInfo.header.moduleVersion < 2 || relInfo.header.bssSectionAlignment == 0) { + if (this.specifyModuleMemAddrs) { + // TODO: Check against addresses already containing memory sections. + var setValidAddress = false; + while (!setValidAddress) { + var selectedAddress = OptionDialog.showInputSingleLineDialog(null, "Specify BSS Address", "Specify the BSS memory address for Module " + + relInfo.name, Long.toHexString(currentOutputAddress)); + + if (selectedAddress == null) { + break; + } + + try { + var specifiedAddr = Long.parseUnsignedLong(selectedAddress, 16) & 0xFFFFFFFF; + if (specifiedAddr >= 0x80000000L && (specifiedAddr + relInfo.header.Size()) < 0x81800000L) { + currentOutputAddress = specifiedAddr; + setValidAddress = true; + } + } + catch (NumberFormatException e) { + continue; + } + } + } + else if (relInfo.header.moduleVersion < 2 || relInfo.header.bssSectionAlignment == 0) { currentOutputAddress = align(currentOutputAddress, 0x20); } else { @@ -311,7 +335,7 @@ else if (relInfo.header.bssSectionId == 0) { name = name.substring(0, name.lastIndexOf(".")); } - mapLoadedResult = SymbolLoader.TryLoadAssociatedMapFile(name, directory, this.program, this.monitor, relBaseAddress, (int)relInfo.header.sectionAlignment, + mapLoadedResult = SymbolLoader.TryLoadAssociatedMapFile(name, directory, this.program, this.monitor, relBaseAddress + relInfo.header.FullSize(), (int)relInfo.header.sectionAlignment, relInfo.header.bssSectionId != 0 ? relInfo.header.sections[relInfo.header.bssSectionId].address : 0); if (mapLoadedResult.loaded != false) { @@ -330,7 +354,7 @@ else if (relInfo.header.bssSectionId == 0) { if (selectedFile != null) { var reader = new FileReader(selectedFile); - var loader = new SymbolLoader(this.program, monitor, reader, relBaseAddress, 0, + var loader = new SymbolLoader(this.program, monitor, reader, relBaseAddress + relInfo.header.FullSize(), 0, relInfo.header.bssSectionId != 0 ? relInfo.header.sections[relInfo.header.bssSectionId].address : 0, this.binaryName, true); this.symbolInfoList.add(loader.ApplySymbols()); From 80baf2c21ab8310d683ced12b6bf2a7e5bcd747d Mon Sep 17 00:00:00 2001 From: Luke Street Date: Sun, 11 Aug 2024 14:36:06 -0600 Subject: [PATCH 3/6] Build for Ghidra 11.1.2 --- .github/workflows/build.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 0ca5416..1f811a9 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -18,11 +18,11 @@ jobs: unzip ghidra.zip -d ~/ghidra rm ghidra.zip env: - GHIDRA_URL: https://github.com/NationalSecurityAgency/ghidra/releases/download/Ghidra_11.1_build/ghidra_11.1_PUBLIC_20240607.zip + GHIDRA_URL: https://github.com/NationalSecurityAgency/ghidra/releases/download/Ghidra_11.1.2_build/ghidra_11.1.2_PUBLIC_20240709.zip - name: Execute Gradle build run: ./gradlew env: - GHIDRA_INSTALL_DIR: /home/runner/ghidra/ghidra_11.1_PUBLIC/ + GHIDRA_INSTALL_DIR: /home/runner/ghidra/ghidra_11.1.2_PUBLIC/ - name: Release uses: softprops/action-gh-release@v1 if: startsWith(github.ref, 'refs/tags/') From 358b82e0abeeefe321a47e4af04b9507f27764df Mon Sep 17 00:00:00 2001 From: Antonio Vazquez Date: Sun, 11 Aug 2024 22:41:21 +0200 Subject: [PATCH 4/6] ci: use a ghidra setup action (#84) --- .github/workflows/build.yml | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 1f811a9..bddea2c 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -11,18 +11,12 @@ jobs: with: distribution: 'temurin' java-version: '17' - - name: Install Ghidra - run: | - curl -L "$GHIDRA_URL" -o ghidra.zip - mkdir ~/ghidra - unzip ghidra.zip -d ~/ghidra - rm ghidra.zip - env: - GHIDRA_URL: https://github.com/NationalSecurityAgency/ghidra/releases/download/Ghidra_11.1.2_build/ghidra_11.1.2_PUBLIC_20240709.zip + - uses: antoniovazquezblanco/setup-ghidra@v2.0.5 + with: + auth_token: ${{ secrets.GITHUB_TOKEN }} + version: 11.1.2 - name: Execute Gradle build - run: ./gradlew - env: - GHIDRA_INSTALL_DIR: /home/runner/ghidra/ghidra_11.1.2_PUBLIC/ + run: ./gradlew -PGHIDRA_INSTALL_DIR=${{ env.GHIDRA_INSTALL_DIR }} - name: Release uses: softprops/action-gh-release@v1 if: startsWith(github.ref, 'refs/tags/') From 1b86e9996c845121ee780ed44db2e4f8ca46106e Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sun, 11 Aug 2024 17:35:28 -0600 Subject: [PATCH 5/6] Bump actions/checkout from 3 to 4 (#78) Bumps [actions/checkout](https://github.com/actions/checkout) from 3 to 4. - [Release notes](https://github.com/actions/checkout/releases) - [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md) - [Commits](https://github.com/actions/checkout/compare/v3...v4) --- updated-dependencies: - dependency-name: actions/checkout dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .github/workflows/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index bddea2c..2f78b7f 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -6,7 +6,7 @@ jobs: gradle: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - uses: actions/setup-java@v3 with: distribution: 'temurin' From 4d18903ed700c6e8d59f1fa9c208167c16b81a23 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sun, 11 Aug 2024 17:37:30 -0600 Subject: [PATCH 6/6] Bump actions/setup-java from 3 to 4 (#79) Bumps [actions/setup-java](https://github.com/actions/setup-java) from 3 to 4. - [Release notes](https://github.com/actions/setup-java/releases) - [Commits](https://github.com/actions/setup-java/compare/v3...v4) --- updated-dependencies: - dependency-name: actions/setup-java dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .github/workflows/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 2f78b7f..9d87f25 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -7,7 +7,7 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - - uses: actions/setup-java@v3 + - uses: actions/setup-java@v4 with: distribution: 'temurin' java-version: '17'