|
43 | 43 |
|
44 | 44 | from chb.bctypes.BCTyp import BCTyp |
45 | 45 |
|
| 46 | +from chb.invariants.XVariable import XVariable |
46 | 47 | from chb.invariants.XXpr import XXpr, XprCompound |
47 | 48 | import chb.invariants.XXprUtil as XU |
48 | 49 |
|
@@ -98,6 +99,12 @@ def operands(self) -> List[ARMOperand]: |
98 | 99 | def opargs(self) -> List[ARMOperand]: |
99 | 100 | return [self.armd.arm_operand(self.args[0])] |
100 | 101 |
|
| 102 | + def lhs(self, xdata: InstrXData) -> List[XVariable]: |
| 103 | + if len(xdata.vars) > 0: |
| 104 | + return [xdata.vars[0]] |
| 105 | + else: |
| 106 | + return [] |
| 107 | + |
101 | 108 | def argument_count(self, xdata: InstrXData) -> int: |
102 | 109 | if self.is_call_instruction(xdata): |
103 | 110 | argcount = xdata.call_target_argument_count() |
@@ -326,29 +333,49 @@ def ast_call_prov( |
326 | 333 | x, xdata, iaddr, astree) |
327 | 334 |
|
328 | 335 | elif x.is_global_address: |
329 | | - hexgaddr = hex(x.constant.value) |
330 | | - if hexgaddr in astree.global_addresses: |
331 | | - vinfo = astree.global_addresses[hexgaddr] |
332 | | - vtype = vinfo.vtype |
333 | | - if vtype is not None: |
334 | | - if vtype.is_array: |
335 | | - hl_arg = astree.mk_vinfo_lval_expression(vinfo) |
| 336 | + if argtype is not None and argtype.is_integer: |
| 337 | + argtype = cast(AST.ASTTypInt, argtype) |
| 338 | + hl_arg = astree.mk_integer_constant( |
| 339 | + x.constant.value, argtype.ikind) |
| 340 | + |
| 341 | + elif ( |
| 342 | + argtype is not None |
| 343 | + and (argtype.is_function |
| 344 | + or (argtype.is_pointer |
| 345 | + and cast( |
| 346 | + AST.ASTTypPtr, |
| 347 | + argtype).tgttyp.is_function))): |
| 348 | + hexaddr = hex(x.constant.value) |
| 349 | + argname = "sub_" + hexaddr[2:] |
| 350 | + hl_arg = astree.mk_global_variable_expr( |
| 351 | + argname, |
| 352 | + vtype=argtype, |
| 353 | + globaladdress=x.constant.value) |
| 354 | + else: |
| 355 | + hexgaddr = hex(x.constant.value) |
| 356 | + if hexgaddr in astree.global_addresses: |
| 357 | + vinfo = astree.global_addresses[hexgaddr] |
| 358 | + vtype = vinfo.vtype |
| 359 | + if vtype is not None: |
| 360 | + if vtype.is_array: |
| 361 | + hl_arg = astree.mk_vinfo_lval_expression( |
| 362 | + vinfo) |
| 363 | + else: |
| 364 | + hl_arg = astree.mk_address_of( |
| 365 | + astree.mk_vinfo_lval(vinfo)) |
336 | 366 | else: |
337 | | - hl_arg = astree.mk_address_of( |
338 | | - astree.mk_vinfo_lval(vinfo)) |
339 | | - else: |
340 | | - chklogger.logger.warning( |
341 | | - ("Type of global address %s at instr. address " |
342 | | - + "%s not known"), |
343 | | - str(x), iaddr) |
| 367 | + chklogger.logger.warning( |
| 368 | + ("Type of global address %s at instr. " |
| 369 | + + "address %s not known"), |
| 370 | + str(x), iaddr) |
344 | 371 | hl_arg = astree.mk_address_of( |
345 | 372 | astree.mk_vinfo_lval(vinfo)) |
346 | | - else: |
347 | | - chklogger.logger.error( |
348 | | - ("Unknown global address %s as call argument at " |
349 | | - + "address %s"), |
350 | | - hexgaddr, iaddr) |
351 | | - hl_arg = astree.mk_temp_lval_expression() |
| 373 | + else: |
| 374 | + chklogger.logger.error( |
| 375 | + ("Unknown global address %s as call " |
| 376 | + + "argument at address %s"), |
| 377 | + hexgaddr, iaddr) |
| 378 | + hl_arg = astree.mk_temp_lval_expression() |
352 | 379 |
|
353 | 380 | else: |
354 | 381 | hl_arg = XU.xxpr_to_ast_def_expr(x, xdata, iaddr, astree) |
|
0 commit comments