Skip to content

Commit 26d561f

Browse files
committed
2 parents 19fe070 + 1c8f346 commit 26d561f

File tree

38 files changed

+343
-198
lines changed

38 files changed

+343
-198
lines changed

.github/workflows/rust.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ jobs:
1313
steps:
1414
- name: Checkout code
1515
uses: actions/checkout@v3
16+
with:
17+
submodules: true
1618

1719
- name: Install Clang
1820
run: |
@@ -29,7 +31,7 @@ jobs:
2931

3032
- name: cargo check
3133
working-directory: ./rust
32-
run: cargo check --workspace
34+
run: cargo check --workspace --all-features
3335

3436
- name: cargo clippy
3537
working-directory: ./rust

basicblock.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,18 @@ void DisassemblySettings::SetAddressMode(BNDisassemblyAddressMode mode)
102102
}
103103

104104

105+
uint64_t DisassemblySettings::GetAddressBaseOffset() const
106+
{
107+
return BNGetDisassemblyAddressBaseOffset(m_object);
108+
}
109+
110+
111+
void DisassemblySettings::SetAddressBaseOffset(uint64_t addressBaseOffset)
112+
{
113+
BNSetDisassemblyAddressBaseOffset(m_object, addressBaseOffset);
114+
}
115+
116+
105117
DisassemblyTextLine::DisassemblyTextLine()
106118
{
107119
addr = 0;

binaryninjaapi.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9722,6 +9722,8 @@ namespace BinaryNinja {
97229722
void SetGutterWidth(size_t width);
97239723
BNDisassemblyAddressMode GetAddressMode() const;
97249724
void SetAddressMode(BNDisassemblyAddressMode mode);
9725+
uint64_t GetAddressBaseOffset() const;
9726+
void SetAddressBaseOffset(uint64_t addressBaseOffset);
97259727
};
97269728

97279729
/*!

binaryninjacore.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -708,6 +708,7 @@ extern "C"
708708
RelativeToSegmentStartDisassemblyAddressMode,
709709
RelativeToSectionStartDisassemblyAddressMode,
710710
RelativeToFunctionStartDisassemblyAddressMode,
711+
RelativeToAddressBaseOffsetDisassemblyAddressMode,
711712
DisassemblyAddressModeMask = 0xFFFF,
712713

713714
IncludeNameDisassemblyAddressModeFlag = 0x10000,
@@ -5079,6 +5080,8 @@ extern "C"
50795080
BINARYNINJACOREAPI void BNSetDisassemblyGutterWidth(BNDisassemblySettings* settings, size_t width);
50805081
BINARYNINJACOREAPI BNDisassemblyAddressMode BNGetDisassemblyAddressMode(BNDisassemblySettings* settings);
50815082
BINARYNINJACOREAPI void BNSetDisassemblyAddressMode(BNDisassemblySettings* settings, BNDisassemblyAddressMode mode);
5083+
BINARYNINJACOREAPI uint64_t BNGetDisassemblyAddressBaseOffset(BNDisassemblySettings* settings);
5084+
BINARYNINJACOREAPI void BNSetDisassemblyAddressBaseOffset(BNDisassemblySettings* settings, uint64_t addressBaseOffset);
50825085

50835086
// Flow graphs
50845087
BINARYNINJACOREAPI BNFlowGraph* BNCreateFlowGraph(void);

docs/guide/types/index.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,5 @@ Additionally, several types of containers for type information are documented he
1313
- [Platform Types](platformtypes.md): Types that automatically apply to a platform
1414
- [Type Archives](typearchives.md): How you can use type archives to share types between analysis databases
1515
- [Signature Libraries](../../dev/annotation.md#signature-library): Signature libraries are used to match names of functions with signatures for code that is statically compiled
16-
- [Platform Types](platformtypes.md): Platform types are base types that apply to all binaries on a particular platform
1716

18-
Additionally, make sure to see the [applying annotations](../../dev/annotation.md) section of the developer guide for information about using the API with types and covering the creation of many of the items described below.
17+
Additionally, make sure to see the [applying annotations](../../dev/annotation.md) section of the developer guide for information about using the API with types and covering the creation of many of the items described below.

python/highlevelil.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343
from .commonil import (
4444
BaseILInstruction, Tailcall, Syscall, Localcall, Comparison, Signed, UnaryOperation, BinaryOperation, SSA, Phi,
4545
Loop, ControlFlow, Memory, Constant, Arithmetic, DoublePrecision, Terminal, FloatingPoint, Intrinsic, Return,
46-
VariableInstruction, SSAVariableInstruction
46+
VariableInstruction, SSAVariableInstruction, SetVar
4747
)
4848
from . import deprecation
4949

@@ -1267,7 +1267,7 @@ def detailed_operands(self) -> List[Tuple[str, HighLevelILOperandType, str]]:
12671267

12681268

12691269
@dataclass(frozen=True, repr=False, eq=False)
1270-
class HighLevelILVarInit(HighLevelILInstruction):
1270+
class HighLevelILVarInit(HighLevelILInstruction, SetVar):
12711271
@property
12721272
def dest(self) -> 'variable.Variable':
12731273
return self.get_var(0)
@@ -1289,7 +1289,7 @@ def vars_written(self) -> VariablesList:
12891289

12901290

12911291
@dataclass(frozen=True, repr=False, eq=False)
1292-
class HighLevelILVarInitSsa(HighLevelILInstruction, SSA):
1292+
class HighLevelILVarInitSsa(HighLevelILInstruction, SetVar, SSA):
12931293
@property
12941294
def dest(self) -> 'mediumlevelil.SSAVariable':
12951295
return self.get_var_ssa(0, 1)
@@ -1311,7 +1311,7 @@ def vars_written(self) -> VariablesList:
13111311

13121312

13131313
@dataclass(frozen=True, repr=False, eq=False)
1314-
class HighLevelILAssign(HighLevelILInstruction):
1314+
class HighLevelILAssign(HighLevelILInstruction, SetVar):
13151315
@property
13161316
def dest(self) -> HighLevelILInstruction:
13171317
return self.get_expr(0)
@@ -1338,7 +1338,7 @@ def vars_written(self) -> VariablesList:
13381338

13391339

13401340
@dataclass(frozen=True, repr=False, eq=False)
1341-
class HighLevelILAssignUnpack(HighLevelILInstruction):
1341+
class HighLevelILAssignUnpack(HighLevelILInstruction, SetVar):
13421342
@property
13431343
def dest(self) -> List[HighLevelILInstruction]:
13441344
return self.get_expr_list(0, 1)
@@ -1448,7 +1448,7 @@ def detailed_operands(self) -> List[Tuple[str, HighLevelILOperandType, str]]:
14481448

14491449

14501450
@dataclass(frozen=True, repr=False, eq=False)
1451-
class HighLevelILVarPhi(HighLevelILInstruction, Phi):
1451+
class HighLevelILVarPhi(HighLevelILInstruction, Phi, SetVar):
14521452
@property
14531453
def dest(self) -> 'mediumlevelil.SSAVariable':
14541454
return self.get_var_ssa(0, 1)

python/mediumlevelil.py

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -80,25 +80,32 @@ def type(self) -> 'types.Type':
8080

8181
@property
8282
def function(self) -> 'function.Function':
83+
"""returns the source Function object which this variable belongs to"""
8384
return self.var.function
8485

86+
@property
87+
def il_function(self) -> 'function.ILFunctionType':
88+
"""returns the il Function object which this variable belongs to"""
89+
return self.var._il_function
90+
8591
@property
8692
def dead_store_elimination(self) -> DeadStoreElimination:
93+
"""returns the dead store elimination setting for this variable (read-only)"""
8794
return self.var.dead_store_elimination
8895

8996
@property
90-
def def_site(self) -> Optional['MediumLevelILInstruction']:
97+
def def_site(self) -> Optional[Union['MediumLevelILInstruction', 'highlevelil.HighLevelILInstruction']]:
9198
"""
92-
Gets the MediumLevelILInstruction where this SSAVariable is defined.
99+
Gets the IL instructions where this SSAVariable is defined.
93100
"""
94-
return self.var.function.get_ssa_var_definition(self)
101+
return self.il_function.get_ssa_var_definition(self)
95102

96103
@property
97-
def use_sites(self) -> List['MediumLevelILInstruction']:
104+
def use_sites(self) -> List[Union['MediumLevelILInstruction', 'highlevelil.HighLevelILInstruction']]:
98105
"""
99-
Gets the list of MediumLevelILInstructions where this SSAVariable is used inside of this function.
106+
Gets the list of IL instructions where this SSAVariable is used inside of this function.
100107
"""
101-
return self.var.function.get_ssa_var_uses(self)
108+
return self.il_function.get_ssa_var_uses(self)
102109

103110

104111
class MediumLevelILLabel:

python/variable.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -886,6 +886,11 @@ def function(self) -> 'binaryninja.function.Function':
886886
"""returns the source Function object which this variable belongs to"""
887887
return self._function
888888

889+
@property
890+
def il_function(self) -> 'function.ILFunctionType':
891+
"""returns the IL Function object which this variable belongs to"""
892+
return self.var._il_function
893+
889894
def set_name_async(self, name: Optional[str]) -> None:
890895
"""
891896
``set_name_async`` provides a way to asynchronously set the name of a variable. This method should be used

rust/examples/decompile/src/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ fn decompile_to_c(view: &BinaryView, func: &Function) {
2626
let last = view.get_next_linear_disassembly_lines(&mut cursor.duplicate());
2727
let first = view.get_previous_linear_disassembly_lines(&mut cursor);
2828

29-
let lines = first.into_iter().chain(last.into_iter());
29+
let lines = first.into_iter().chain(&last);
3030

3131
for line in lines {
3232
println!("{}", line.as_ref());

rust/examples/dwarf/dwarf_export/src/lib.rs

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -522,13 +522,11 @@ fn export_data_vars(
522522

523523
for data_variable in &bv.data_variables() {
524524
if let Some(symbol) = data_variable.symbol(bv) {
525-
if symbol.sym_type() == SymbolType::External {
526-
continue;
527-
} else if symbol.sym_type() == SymbolType::Function {
528-
continue;
529-
} else if symbol.sym_type() == SymbolType::ImportedFunction {
530-
continue;
531-
} else if symbol.sym_type() == SymbolType::LibraryFunction {
525+
if let SymbolType::External
526+
| SymbolType::Function
527+
| SymbolType::ImportedFunction
528+
| SymbolType::LibraryFunction = symbol.sym_type()
529+
{
532530
continue;
533531
}
534532
}

0 commit comments

Comments
 (0)