Skip to content

Commit e0d623d

Browse files
WeiN76LQhWeiN76LQh
authored andcommitted
Merge branch 'dev' into use-cached-exports
2 parents c83ec00 + b14f86d commit e0d623d

125 files changed

Lines changed: 6272 additions & 4627 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/rust.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ jobs:
2424
- name: Install Rust
2525
uses: actions-rs/toolchain@v1
2626
with:
27-
toolchain: 1.77.0
27+
toolchain: 1.83.0
2828
profile: minimal
2929
override: true
3030
components: clippy

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ cmake --build build -j8
3737
In addition to the default build setup, you may want to:
3838

3939
- **Build examples.** To build the [API examples](#examples), pass `-DBN_API_BUILD_EXAMPLES=ON` to CMake when configuring the build. After the build succeeds, you can install the built plugins by running the `install` target. When using the "Unix Makefiles" build generator, this looks like: `make install`.
40-
- **Build UI plugins.** You will need Qt 6.7.2 (as of writing) installed to build UI plugins.
40+
- **Build UI plugins.** You will need Qt 6.7.2 installed to build UI plugins. We use a slightly modified [build configuration](https://github.com/Vector35/qt-build) internally that has some ABI-compatible fixes and changes to defaults, but a stock build can also work. Note that it is not recommended to use pre-built configurations from Homebrew. Either using the official installer or building from our repo is recommended.
4141
- **Build headlessly.** If you are using a headless Binary Ninja distribution or you do not wish to build UI plugins, pass `-DHEADLESS=ON` to CMake when configuring the build.
4242

4343
### Troubleshooting

arch/mips/arch_mips.cpp

Lines changed: 49 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3001,13 +3001,44 @@ class MipsElfRelocationHandler: public RelocationHandler
30013001
}
30023002
case R_MIPS_HI16:
30033003
{
3004-
dest64[0] = swap64((inst64 & 0xffff0000ffffffff) | (((target + 0x8000) << 16) & 0xffff00000000 ));
3004+
// Find the first _LO16 in the list of relocations
3005+
BNRelocationInfo* cur = info.next;
3006+
while (cur && (cur->nativeType != R_MIPS_LO16))
3007+
cur = cur->next;
3008+
3009+
if (cur)
3010+
{
3011+
uint32_t inst2 = *(uint32_t*)(cur->relocationDataCache);
3012+
Instruction instruction;
3013+
memset(&instruction, 0, sizeof(instruction));
3014+
if (mips_decompose(&inst2, sizeof(uint32_t), &instruction, arch->GetAddressSize() == 8 ? MIPS_64 : MIPS_32, cur->address, arch->GetEndianness(), DECOMPOSE_FLAGS_PSEUDO_OP))
3015+
break;
3016+
3017+
int32_t immediate = swap(inst2) & 0xffff;
3018+
3019+
// ADDIU and LW has a signed immediate we have to subtract
3020+
if (instruction.operation == MIPS_ADDIU)
3021+
immediate = instruction.operands[2].immediate;
3022+
else if (instruction.operation == MIPS_LW)
3023+
immediate = instruction.operands[1].immediate;
3024+
uint32_t ahl = ((inst & 0xffff) << 16) + immediate;
3025+
3026+
// ((AHL + S) – (short)(AHL + S)) >> 16
3027+
dest32[0] = swap((uint32_t)(
3028+
(inst & ~0xffff) |
3029+
(((ahl + target) - (short)(ahl + target)) >> 16)
3030+
));
3031+
}
3032+
else
3033+
{
3034+
LogError("No corresponding R_MIPS_LO16 relocation for R_MIPS_HI16 relocation");
3035+
}
30053036
break;
30063037
}
30073038
case R_MIPS_LO16:
30083039
{
3009-
uint64_t ahl = (((inst64 & 0xffff00000000) >> 32) + target) & 0xffff;
3010-
dest64[0] = swap64((inst64 & 0xffff0000ffffffff) | ((ahl << 32) & 0xffff00000000) );
3040+
uint32_t ahl = ((inst & 0xffff) + target) & 0xffff;
3041+
dest32[0] = swap((inst & ~0xffff) | (ahl & 0xffff));
30113042
break;
30123043
}
30133044
case R_MIPS_26:
@@ -3084,6 +3115,21 @@ class MipsElfRelocationHandler: public RelocationHandler
30843115
case R_MIPS_HI16:
30853116
result[i].dataRelocation = false;
30863117
result[i].pcRelative = false;
3118+
// MIPS_HI16 relocations usually come before multiple MIPS_LO16 relocations. But, this is not always
3119+
// the case. Some binaries have MIPS_HI16 relocations after an associated MIPS_LO16 relocation.
3120+
for (size_t j = 0; j < result.size(); j++)
3121+
{
3122+
if (result[j].nativeType == R_MIPS_LO16 && result[j].symbolIndex == result[i].symbolIndex)
3123+
{
3124+
result[j].type = StandardRelocationType;
3125+
result[j].size = 4;
3126+
result[j].pcRelative = false;
3127+
result[j].dataRelocation = false;
3128+
result[i].next = new BNRelocationInfo(result[j]);
3129+
break;
3130+
}
3131+
}
3132+
30873133
break;
30883134
case R_MIPS_LO16:
30893135
result[i].pcRelative = false;

arch/msp430/Cargo.lock

Lines changed: 8 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

arch/powerpc/CMakeLists.txt

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,3 +47,31 @@ if(BN_INTERNAL_BUILD)
4747
LIBRARY_OUTPUT_DIRECTORY ${BN_CORE_PLUGIN_DIR}
4848
RUNTIME_OUTPUT_DIRECTORY ${BN_CORE_PLUGIN_DIR})
4949
endif()
50+
51+
if (DEFINED FORCE_TEST)
52+
set(TEST_INLCUDE_LIST )
53+
set(TEST_LINK_DIRECTORIES )
54+
set(TEST_LINK_LIBRARIES capstone)
55+
56+
if (NOT ${CMAKE_SYSTEM_NAME} MATCHES "Windows")
57+
add_executable(test_disasm test_disasm.cpp disassembler.cpp)
58+
add_executable(test_asm test_asm.cpp assembler.cpp)
59+
60+
target_compile_definitions(test_disasm PRIVATE FORCE_TEST=1)
61+
62+
set_target_properties(test_disasm test_asm PROPERTIES
63+
CXX_STANDARD 17
64+
CXX_VISIBILITY_PRESET hidden
65+
CXX_STANDARD_REQUIRED ON
66+
VISIBILITY_INLINES_HIDDEN ON
67+
POSITION_INDEPENDENT_CODE ON)
68+
69+
target_include_directories(test_disasm PRIVATE ${TEST_INCLUDE_LIST})
70+
target_link_directories(test_disasm PRIVATE ${TEST_LINK_DIRECTORIES})
71+
target_link_libraries(test_disasm PRIVATE ${TEST_LINK_LIBRARIES})
72+
73+
target_include_directories(test_asm PRIVATE ${TEST_INCLUDE_LIST})
74+
target_link_directories(test_asm PRIVATE ${TEST_LINK_DIRECTORIES})
75+
target_link_libraries(test_asm PRIVATE ${TEST_LINK_LIBRARIES})
76+
endif()
77+
endif()

0 commit comments

Comments
 (0)