Skip to content

Commit a0996bd

Browse files
committed
CHB:MIPS: fix warnings and reformat
1 parent a1c5df5 commit a0996bd

Some content is hidden

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

41 files changed

+617
-703
lines changed

CodeHawk/CHB/bchlibmips32/bCHAssembleMIPSInstruction.ml

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
11
(* =============================================================================
2-
CodeHawk Binary Analyzer
2+
CodeHawk Binary Analyzer
33
Author: Henny Sipma
44
------------------------------------------------------------------------------
55
The MIT License (MIT)
6-
7-
Copyright (c) 2022 Aarno Labs LLC
6+
7+
Copyright (c) 2022-2024 Aarno Labs LLC
88
99
Permission is hereby granted, free of charge, to any person obtaining a copy
1010
of this software and associated documentation files (the "Software"), to deal
1111
in the Software without restriction, including without limitation the rights
1212
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
1313
copies of the Software, and to permit persons to whom the Software is
1414
furnished to do so, subject to the following conditions:
15-
15+
1616
The above copyright notice and this permission notice shall be included in all
1717
copies or substantial portions of the Software.
18-
18+
1919
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
2020
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
2121
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
@@ -28,11 +28,15 @@
2828
(* chlib *)
2929
open CHNumerical
3030

31+
(* chutil *)
32+
open CHLogger
33+
3134
(* bchlib *)
3235
open BCHDoubleword
3336
open BCHLibTypes
3437

3538
(* bchlibmips32 *)
39+
open BCHMIPSOpcodeRecords
3640
open BCHMIPSOperand
3741
open BCHMIPSTypes
3842

@@ -49,6 +53,7 @@ let int2dw (i: int) = TR.tget_ok (int_to_doubleword i)
4953
let ri (op: mips_operand_int): int = op#get_register_index
5054
let rii (op: mips_operand_int): int = op#get_indirect_register_index
5155

56+
5257
let assemble_mips_instruction
5358
?(iaddr=wordzero) (opc: mips_opcode_t): doubleword_int =
5459
match opc with
@@ -62,7 +67,18 @@ let assemble_mips_instruction
6267
+ ((ri rs) lsl 16)
6368
+ mem#get_indirect_offset#toInt in
6469
int2dw v
65-
| _ -> wordzero
70+
| _ ->
71+
begin
72+
chlog#add
73+
"assemble mips instruction"
74+
(LBLOCK [
75+
STR "Opcode ";
76+
STR (mips_opcode_to_string opc);
77+
STR " at address ";
78+
iaddr#toPretty;
79+
STR " not yet supported"]);
80+
wordzero
81+
end
6682

6783

6884
let assemble_mips_move_instruction
@@ -90,4 +106,3 @@ let assemble_mips_sw_stack_instruction
90106
dw#to_fixed_length_hex_string
91107
else
92108
dw#to_fixed_length_hex_string_le
93-

CodeHawk/CHB/bchlibmips32/bCHAssembleMIPSInstruction.mli

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
------------------------------------------------------------------------------
55
The MIT License (MIT)
66
7-
Copyright (c) 2022 Aarno Labs LLC
7+
Copyright (c) 2022-2024 Aarno Labs LLC
88
99
Permission is hereby granted, free of charge, to any person obtaining a copy
1010
of this software and associated documentation files (the "Software"), to deal

CodeHawk/CHB/bchlibmips32/bCHDisassembleMIPS.ml

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -28,40 +28,33 @@
2828
============================================================================= *)
2929

3030
(* chlib *)
31-
open CHNumerical
3231
open CHPretty
3332

3433
(* chutil *)
3534
open CHLogger
3635

3736
(* xprlib *)
38-
open Xprt
3937
open XprToPretty
4038
open XprTypes
41-
open Xsimplify
4239

4340
(* bchlib *)
4441
open BCHBasicTypes
4542
open BCHByteUtilities
4643
open BCHDataBlock
4744
open BCHDoubleword
4845
open BCHFloc
49-
open BCHFunctionInterface
5046
open BCHFunctionData
5147
open BCHFunctionInfo
5248
open BCHFunctionSummaryLibrary
53-
open BCHJumpTable
5449
open BCHLibTypes
5550
open BCHLocation
5651
open BCHMakeCallTargetInfo
5752
open BCHStreamWrapper
5853
open BCHSystemInfo
5954
open BCHSystemSettings
60-
open BCHUtilities
6155

6256
(* bchlibelf *)
6357
open BCHELFHeader
64-
open BCHELFTypes
6558

6659
(* bchlibmips32 *)
6760
open BCHMIPSAssemblyBlock
@@ -427,10 +420,11 @@ let set_library_stub_name faddr =
427420
chlog#add "faddr is not a program address" faddr#toPretty
428421

429422

430-
let extract_so_symbol (opcodes:mips_opcode_t list) = None (* TBD *)
423+
let extract_so_symbol (_opcodes:mips_opcode_t list) = None (* TBD *)
431424

432425

433-
let get_so_target (tgtaddr:doubleword_int) (instr:mips_assembly_instruction_int) =
426+
let get_so_target
427+
(tgtaddr:doubleword_int) (_instr:mips_assembly_instruction_int) =
434428
if functions_data#has_function_name tgtaddr then
435429
let fndata = functions_data#get_function tgtaddr in
436430
if fndata#is_library_stub then
@@ -459,7 +453,7 @@ let collect_function_entry_points () =
459453
begin
460454
addresses#addList functions_data#get_function_entry_points;
461455
!mips_assembly_instructions#itera
462-
(fun va instr ->
456+
(fun _va instr ->
463457
match instr#get_opcode with
464458
| BranchLTZeroLink (_,tgt)
465459
| BranchGEZeroLink (_,tgt)
@@ -554,10 +548,12 @@ let set_block_boundaries () =
554548
end
555549

556550

551+
(*
557552
let is_so_jump_target (target_address:doubleword_int) =
558553
match elf_header#get_relocation target_address with
559554
| Some _ -> true
560555
| _ -> false
556+
*)
561557

562558

563559
let get_successors (faddr:doubleword_int) (iaddr:doubleword_int) =
@@ -749,7 +745,7 @@ let trace_function (faddr:doubleword_int) =
749745
make_mips_assembly_function faddr blocklist successors
750746

751747

752-
let construct_mips_assembly_function (count:int) (faddr:doubleword_int) =
748+
let construct_mips_assembly_function (_count: int) (faddr: doubleword_int) =
753749
try
754750
let _ = pverbose [STR " trace function "; faddr#toPretty; NL] in
755751
let fn = trace_function faddr in
@@ -842,7 +838,7 @@ let record_call_targets () =
842838
finfo#set_call_target
843839
ctxtiaddr (mk_app_target op#get_absolute_address)
844840
end
845-
| JumpLinkRegister (ra, op) ->
841+
| JumpLinkRegister (_ra, _op) ->
846842
let iaddr = (ctxt_string_to_location faddr ctxtiaddr)#i in
847843
if finfo#has_call_target ctxtiaddr then
848844
let loc = ctxt_string_to_location faddr ctxtiaddr in
@@ -1037,7 +1033,7 @@ let resolve_indirect_mips_calls (f:mips_assembly_function_int) =
10371033
(fun faddr ctxtiaddr instr ->
10381034
let loc = ctxt_string_to_location faddr ctxtiaddr in
10391035
match instr#get_opcode with
1040-
| JumpLinkRegister (ra, tgt) ->
1036+
| JumpLinkRegister (_ra, tgt) ->
10411037
let floc = get_floc loc in
10421038
if (floc#has_call_target && floc#get_call_target#is_unknown)
10431039
|| not floc#has_call_target then

CodeHawk/CHB/bchlibmips32/bCHDisassembleMIPS.mli

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
77
Copyright (c) 2005-2019 Kestrel Technology LLC
88
Copyright (c) 2020 Henny Sipma
9-
Copyright (c) 2021-2023 Aarno Labs LLC
9+
Copyright (c) 2021-2024 Aarno Labs LLC
1010
1111
Permission is hereby granted, free of charge, to any person obtaining a copy
1212
of this software and associated documentation files (the "Software"), to deal
@@ -27,9 +27,6 @@
2727
SOFTWARE.
2828
============================================================================= *)
2929

30-
(* chlib *)
31-
open CHPretty
32-
3330
(* bchlib *)
3431
open BCHLibTypes
3532

CodeHawk/CHB/bchlibmips32/bCHDisassembleMIPSInstruction.ml

Lines changed: 14 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
77
Copyright (c) 2005-2020 Kestrel Technology LLC
88
Copyright (c) 2020 Henny Sipma
9-
Copyright (c) 2021-2022 Aarno Labs LLC
9+
Copyright (c) 2021-2024 Aarno Labs LLC
1010
1111
Permission is hereby granted, free of charge, to any person obtaining a copy
1212
of this software and associated documentation files (the "Software"), to deal
@@ -33,21 +33,12 @@ open CHNumerical
3333

3434
(* chutil *)
3535
open CHLogger
36-
open CHPrettyUtil
3736

3837
(* bchlib *)
39-
open BCHBasicTypes
40-
open BCHCPURegisters
41-
open BCHDoubleword
42-
open BCHImmediate
4338
open BCHLibTypes
44-
open BCHStreamWrapper
45-
open BCHSystemInfo
46-
open BCHSystemSettings
4739

4840
(* bchlibmips32 *)
4941
open BCHMIPSDisassemblyUtils
50-
open BCHMIPSOpcodeRecords
5142
open BCHMIPSOperand
5243
open BCHMIPSTypes
5344

@@ -173,7 +164,7 @@ let parse_J_opcode
173164

174165
let parse_R_opcode
175166
(instr: doubleword_int)
176-
(opc: int)
167+
(_opc: int)
177168
(rrs: int)
178169
(rrt: int)
179170
(rrd: int)
@@ -228,11 +219,11 @@ let parse_R_opcode
228219

229220
let parse_R2_opcode
230221
(instr: doubleword_int)
231-
(opc: int)
222+
(_opc: int)
232223
(rrs: int)
233224
(rrt: int)
234225
(rrd: int)
235-
(samt: int)
226+
(_samt: int)
236227
(fnct: int) =
237228
let rs = select_mips_reg rrs in
238229
let rt = select_mips_reg rrt in
@@ -252,7 +243,7 @@ let parse_R2_opcode
252243

253244
let parse_R3_opcode
254245
(instr: doubleword_int)
255-
(opc: int)
246+
(_opc: int)
256247
(rrs: int)
257248
(rrt: int)
258249
(rrd: int)
@@ -277,12 +268,12 @@ let parse_R3_opcode
277268

278269
let parse_FPMC_opcode
279270
(instr: doubleword_int)
280-
(opc: int)
271+
(_opc: int)
281272
(rrs: int)
282273
(cc: int)
283274
(tf: int)
284275
(rrd: int)
285-
(ffd: int)
276+
(_ffd: int)
286277
(funct: int) =
287278
let rs = select_mips_reg rrs in
288279
let rd = select_mips_reg rrd in
@@ -298,7 +289,7 @@ let parse_FPMC_opcode
298289

299290
let parse_FPRI_opcode
300291
(instr: doubleword_int)
301-
(opc: int)
292+
(_opc: int)
302293
(sub: int)
303294
(rrt: int)
304295
(fs: int)
@@ -351,7 +342,7 @@ let parse_FPRI_opcode
351342

352343
let parse_FPR_opcode
353344
(instr: doubleword_int)
354-
(opc: int)
345+
(_opc: int)
355346
(fmt: int)
356347
(ft: int)
357348
(fs: int)
@@ -388,8 +379,8 @@ let parse_FPR_opcode
388379
let parse_FPICC_opcode
389380
(instr: doubleword_int)
390381
(iaddr: doubleword_int)
391-
(opc: int)
392-
(sub: int)
382+
(_opc: int)
383+
(_sub: int)
393384
(cc: int)
394385
(nd: int)
395386
(tf: int)
@@ -439,17 +430,17 @@ let parse_opcode
439430
parse_R2_opcode instrbytes opc rs rt rd sa fn
440431
| R3Type (opc, rs, rt, rd, sa, fn) ->
441432
parse_R3_opcode instrbytes opc rs rt rd sa fn
442-
| FPMCType (opc, rs, cc, nd, tf, rd, fd, funct) ->
433+
| FPMCType (opc, rs, cc, _nd, tf, rd, fd, funct) ->
443434
parse_FPMC_opcode instrbytes opc rs cc tf rd fd funct
444435
| FPRIType (opc, sub, rt, fs, imm) ->
445436
parse_FPRI_opcode instrbytes opc sub rt fs imm
446437
| FPRType (opc, fmt, ft, fs, fd, funct) ->
447438
parse_FPR_opcode instrbytes opc fmt ft fs fd funct
448439
| FPICCType (opc, sub, cc, nd, tf, offset) ->
449440
parse_FPICC_opcode instrbytes iaddr opc sub cc nd tf offset
450-
| FPCompareType (opc, fmt, ft, fs, cc, cond) ->
441+
| FPCompareType (_opc, fmt, ft, fs, cc, cond) ->
451442
parse_FPCompare_opcode fmt ft fs cc cond
452-
| FormatUnknown(opc, otherbits) ->
443+
| FormatUnknown(_opc, _otherbits) ->
453444
NotRecognized ("parse_opcode:format_unknown", instrbytes) in
454445
opcode
455446

CodeHawk/CHB/bchlibmips32/bCHDisassembleMIPSInstruction.mli

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
77
Copyright (c) 2005-2019 Kestrel Technology LLC
88
Copyright (c) 2020 Henny Sipma
9-
Copyright (c) 2021-2022 Aarno Labs LLC
9+
Copyright (c) 2021-2024 Aarno Labs LLC
1010
1111
Permission is hereby granted, free of charge, to any person obtaining a copy
1212
of this software and associated documentation files (the "Software"), to deal

CodeHawk/CHB/bchlibmips32/bCHFnMIPSDictionary.ml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
77
Copyright (c) 2005-2020 Kestrel Technology LLC
88
Copyright (c) 2020-2021 Henny Sipma
9-
Copyright (c) 2021-2023 Aarno Labs LLC
9+
Copyright (c) 2021-2024 Aarno Labs LLC
1010
1111
Permission is hereby granted, free of charge, to any person obtaining a copy
1212
of this software and associated documentation files (the "Software"), to deal
@@ -132,7 +132,8 @@ object (self)
132132
(TR.tget_ok (floc#env#get_global_variable_address v)) ->
133133
num_constant_expr
134134
(elf_header#get_program_value
135-
(TR.tget_ok (floc#env#get_global_variable_address v)))#to_numerical
135+
(TR.tget_ok
136+
(floc#env#get_global_variable_address v)))#to_numerical
136137
| XVar v when floc#env#is_symbolic_value v ->
137138
expand (TR.tget_ok (floc#env#get_symbolic_value_expr v))
138139
| XOp (op,l) -> XOp (op, List.map expand l)

CodeHawk/CHB/bchlibmips32/bCHFnMIPSDictionary.mli

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
77
Copyright (c) 2005-2019 Kestrel Technology LLC
88
Copyright (c) 2020 Henny Sipma
9-
Copyright (c) 2021-2023 Aarno Labs LLC
9+
Copyright (c) 2021-2024 Aarno Labs LLC
1010
1111
Permission is hereby granted, free of charge, to any person obtaining a copy
1212
of this software and associated documentation files (the "Software"), to deal

0 commit comments

Comments
 (0)