Skip to content

Commit 83653f2

Browse files
committed
merge master
2 parents 6397c23 + 87b1470 commit 83653f2

File tree

135 files changed

+55697
-24844
lines changed

Some content is hidden

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

135 files changed

+55697
-24844
lines changed

.github/workflows/rust.yml

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
name: Rust PR Checks
2+
3+
on:
4+
pull_request:
5+
paths:
6+
- 'rust/**'
7+
8+
jobs:
9+
build_and_lint:
10+
name: cargo check & cargo clippy
11+
runs-on: ubuntu-latest
12+
13+
steps:
14+
- name: Checkout code
15+
uses: actions/checkout@v3
16+
17+
- name: Install Clang
18+
run: |
19+
sudo apt update
20+
sudo apt install clang -y
21+
22+
- name: Install Rust
23+
uses: actions-rs/toolchain@v1
24+
with:
25+
toolchain: 1.77.0
26+
profile: minimal
27+
override: true
28+
components: clippy
29+
30+
- name: cargo check
31+
working-directory: ./rust
32+
run: cargo check --workspace
33+
34+
- name: cargo clippy
35+
working-directory: ./rust
36+
run: cargo clippy -- -D warnings
37+
continue-on-error: true
38+
# If this step fails, it will warn (?)

.gitmodules

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,6 @@
1919
[submodule "arch/x86/mbuild"]
2020
path = arch/x86/mbuild
2121
url = https://github.com/intelxed/mbuild.git
22+
[submodule "rust/examples/pdb-ng/pdb-0.8.0-patched"]
23+
path = rust/examples/pdb-ng/pdb-0.8.0-patched
24+
url = https://github.com/Vector35/pdb-rs.git

README.md

Lines changed: 22 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -88,31 +88,39 @@ This repository contains all of our Platform plugins available here:
8888
* [EFI](https://github.com/Vector35/binaryninja-api/tree/dev/platform/efi)
8989

9090

91-
## Related Repositories
91+
## Architectures
92+
93+
This repository contains all of our Architecture plugins available here:
94+
95+
* [ARMv7](https://github.com/Vector35/binaryninja-api/tree/dev/arch/armv7)
96+
* [PPC](https://github.com/Vector35/binaryninja-api/tree/dev/arch/powerpc)
97+
* [MIPS32](https://github.com/Vector35/binaryninja-api/tree/dev/arch/mips)
98+
* [ARM64](https://github.com/Vector35/binaryninja-api/tree/dev/arch/arm64)
99+
* [x86/x86_64](https://github.com/Vector35/binaryninja-api/tree/dev/arch/x86)
100+
* [RISCV](https://github.com/Vector35/binaryninja-api/tree/dev/arch/riscv)
92101

93-
In addition to this main API repository being open source Vector35 also has open sourced Architecture, BinaryView, DebugInfo and Debugger plugins open source as well:
94102

95-
### Architectures
103+
## BinaryViewTypes
96104

97-
* [ARMv7](https://github.com/Vector35/arch-armv7)
98-
* [PPC](https://github.com/Vector35/arch-ppc)
99-
* [MIPS32](https://github.com/Vector35/arch-mips)
100-
* [ARM64](https://github.com/Vector35/arch-arm64)
101-
* [x86/x86_64](https://github.com/Vector35/arch-x86)
105+
This repository contains all of our Binary View Type plugins available here:
102106

103-
### BinaryViewTypes
107+
* [Mach-O](https://github.com/Vector35/binaryninja-api/tree/dev/view/macho)
108+
* [ELF](https://github.com/Vector35/binaryninja-api/tree/dev/view/elf)
109+
* [PE/COFF/TE](https://github.com/Vector35/binaryninja-api/tree/dev/view/pe)
110+
* [MD1Rom](https://github.com/Vector35/binaryninja-api/tree/dev/view/md1rom)
104111

105-
* [Mach-O](https://github.com/Vector35/view-macho)
106-
* [ELF](https://github.com/Vector35/view-elf)
107-
* [PE/COFF](https://github.com/Vector35/view-pe)
108112

109-
### DebugInfo
113+
## DebugInfo
110114

111115
* [DWARF Import](https://github.com/Vector35/binaryninja-api/tree/dev/rust/examples/dwarf/dwarf_import)
112116

113-
### Debugger
117+
118+
## Related Repositories
119+
120+
In addition to this main API repository being open source Vector35 also has open sourced the Debugger and the Objective-C plugins open source as well:
114121

115122
* [Debugger](https://github.com/Vector35/debugger)
123+
* [workflow_objc](https://github.com/Vector35/workflow_objc)
116124

117125
## Licensing
118126

arch/mips/arch_mips.cpp

Lines changed: 118 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1829,6 +1829,121 @@ class MipsImportedFunctionRecognizer: public FunctionRecognizer
18291829
return false;
18301830
}
18311831

1832+
1833+
bool RecognizeELFPLTEntries2(BinaryView* data, Function* func, LowLevelILFunction* il)
1834+
{
1835+
// Look for the following code pattern:
1836+
// $t7 = addr_past_got_end
1837+
// $t9 = [$t7 - backward_offset_into_got].d
1838+
// $t8 = $t7 + (-backward_offset_into_got)
1839+
// OPTIONAL: $t7 = addr_past_got_end
1840+
// tailcall($t9)
1841+
if (il->GetInstructionCount() < 4)
1842+
return false;
1843+
if (il->GetInstructionCount() > 5)
1844+
return false;
1845+
1846+
LowLevelILInstruction lui = il->GetInstruction(0);
1847+
if (lui.operation != LLIL_SET_REG)
1848+
return false;
1849+
LowLevelILInstruction luiOperand = lui.GetSourceExpr<LLIL_SET_REG>();
1850+
if (!LowLevelILFunction::IsConstantType(luiOperand.operation))
1851+
return false;
1852+
if (luiOperand.size != func->GetArchitecture()->GetAddressSize())
1853+
return false;
1854+
uint64_t addrPastGot = luiOperand.GetConstant();
1855+
uint32_t pltReg = lui.GetDestRegister<LLIL_SET_REG>();
1856+
1857+
LowLevelILInstruction ld = il->GetInstruction(1);
1858+
if (ld.operation != LLIL_SET_REG)
1859+
return false;
1860+
uint32_t targetReg = ld.GetDestRegister<LLIL_SET_REG>();
1861+
LowLevelILInstruction ldOperand = ld.GetSourceExpr<LLIL_SET_REG>();
1862+
if (ldOperand.operation != LLIL_LOAD)
1863+
return false;
1864+
if (ldOperand.size != func->GetArchitecture()->GetAddressSize())
1865+
return false;
1866+
LowLevelILInstruction ldAddrOperand = ldOperand.GetSourceExpr<LLIL_LOAD>();
1867+
uint64_t entry = addrPastGot;
1868+
int64_t ldAddrRightOperandValue = 0;
1869+
1870+
if ((ldAddrOperand.operation == LLIL_ADD) || (ldAddrOperand.operation == LLIL_SUB))
1871+
{
1872+
LowLevelILInstruction ldAddrLeftOperand = ldAddrOperand.GetRawOperandAsExpr(0);
1873+
LowLevelILInstruction ldAddrRightOperand = ldAddrOperand.GetRawOperandAsExpr(1);
1874+
if (ldAddrLeftOperand.operation != LLIL_REG)
1875+
return false;
1876+
if (ldAddrLeftOperand.GetSourceRegister<LLIL_REG>() != pltReg)
1877+
return false;
1878+
if (!LowLevelILFunction::IsConstantType(ldAddrRightOperand.operation))
1879+
return false;
1880+
ldAddrRightOperandValue = ldAddrRightOperand.GetConstant();
1881+
if (ldAddrOperand.operation == LLIL_SUB)
1882+
ldAddrRightOperandValue = -ldAddrRightOperandValue;
1883+
entry = addrPastGot + ldAddrRightOperandValue;
1884+
}
1885+
else if (ldAddrOperand.operation != LLIL_REG) //If theres no constant
1886+
return false;
1887+
1888+
Ref<Symbol> sym = data->GetSymbolByAddress(entry);
1889+
if (!sym)
1890+
return false;
1891+
if (sym->GetType() != ImportAddressSymbol)
1892+
return false;
1893+
1894+
LowLevelILInstruction add = il->GetInstruction(2);
1895+
if (add.operation != LLIL_SET_REG)
1896+
return false;
1897+
LowLevelILInstruction addOperand = add.GetSourceExpr<LLIL_SET_REG>();
1898+
1899+
if (addOperand.operation == LLIL_ADD)
1900+
{
1901+
LowLevelILInstruction addLeftOperand = addOperand.GetLeftExpr<LLIL_ADD>();
1902+
LowLevelILInstruction addRightOperand = addOperand.GetRightExpr<LLIL_ADD>();
1903+
if (addLeftOperand.operation != LLIL_REG)
1904+
return false;
1905+
if (addLeftOperand.GetSourceRegister<LLIL_REG>() != pltReg)
1906+
return false;
1907+
if (!LowLevelILFunction::IsConstantType(addRightOperand.operation))
1908+
return false;
1909+
if (addRightOperand.GetConstant() != ldAddrRightOperandValue)
1910+
return false;
1911+
}
1912+
else if ((addOperand.operation != LLIL_REG) || (addOperand.GetSourceRegister<LLIL_REG>() != pltReg)) //Simple assignment
1913+
return false;
1914+
1915+
LowLevelILInstruction jump = il->GetInstruction(3);
1916+
if (jump.operation == LLIL_SET_REG)
1917+
{
1918+
if (il->GetInstructionCount() != 5)
1919+
return false;
1920+
if (jump.GetDestRegister<LLIL_SET_REG>() != pltReg)
1921+
return false;
1922+
LowLevelILInstruction luiOperand = jump.GetSourceExpr<LLIL_SET_REG>();
1923+
if (!LowLevelILFunction::IsConstantType(luiOperand.operation))
1924+
return false;
1925+
if (luiOperand.size != func->GetArchitecture()->GetAddressSize())
1926+
return false;
1927+
if (((uint64_t) luiOperand.GetConstant()) != addrPastGot)
1928+
return false;
1929+
jump = il->GetInstruction(4);
1930+
}
1931+
1932+
if ((jump.operation != LLIL_JUMP) && (jump.operation != LLIL_TAILCALL))
1933+
return false;
1934+
LowLevelILInstruction jumpOperand = (jump.operation == LLIL_JUMP) ? jump.GetDestExpr<LLIL_JUMP>() : jump.GetDestExpr<LLIL_TAILCALL>();
1935+
if (jumpOperand.operation != LLIL_REG)
1936+
return false;
1937+
if (jumpOperand.GetSourceRegister<LLIL_REG>() != targetReg)
1938+
return false;
1939+
1940+
Ref<Symbol> funcSym = Symbol::ImportedFunctionFromImportAddressSymbol(sym, func->GetStart());
1941+
data->DefineAutoSymbol(funcSym);
1942+
func->ApplyImportedTypes(funcSym);
1943+
return true;
1944+
}
1945+
1946+
18321947
public:
18331948
virtual bool RecognizeLowLevelIL(BinaryView* data, Function* func, LowLevelILFunction* il) override
18341949
{
@@ -1838,6 +1953,9 @@ class MipsImportedFunctionRecognizer: public FunctionRecognizer
18381953
if (RecognizeELFPLTEntries1(data, func, il))
18391954
return true;
18401955

1956+
if (RecognizeELFPLTEntries2(data, func, il))
1957+
return true;
1958+
18411959
return false;
18421960
}
18431961
};

0 commit comments

Comments
 (0)