MCPcopy Create free account
hub / github.com/GJDuck/e9patch / sendLoadArgumentMetadata

Function sendLoadArgumentMetadata

src/e9tool/e9metadata.cpp:1421–2025  ·  view source on GitHub ↗

* Send instructions to load an argument into a register. */

Source from the content-addressed store, hash-verified

1419 * Send instructions to load an argument into a register.
1420 */
1421static Type sendLoadArgumentMetadata(FILE *out, CallInfo &info,
1422 const ELF *elf, const char *name, PatchPos pos,
1423 const std::vector<Instr> &Is, size_t i, const InstrInfo *I, intptr_t id,
1424 const Argument &arg, int argno, int regno)
1425{
1426 if (regno < 0)
1427 error("failed to load argument; call instrumentation exceeds the "
1428 "maximum number of arguments (%d)", argno);
1429 sendSaveRegToStack(out, info, getReg(regno));
1430
1431 bool _static = arg._static;
1432 Type t = TYPE_INT64;
1433 switch (arg.kind)
1434 {
1435 case ARGUMENT_CSV:
1436 {
1437 MatchVal val = getCSVValue(I->address, arg.name, arg.value);
1438 switch (val.type)
1439 {
1440 case MATCH_TYPE_INTEGER:
1441 sendLoadValueMetadata(out, val.i, regno);
1442 break;
1443 case MATCH_TYPE_STRING:
1444 {
1445 std::string offset("{\"rel32\":\".Lstr");
1446 offset += std::to_string(regno);
1447 offset += '@';
1448 offset += name;
1449 offset += "\"}";
1450 sendLeaFromPCRelToR64(out, offset.c_str(), regno);
1451 t = TYPE_CONST_CHAR_PTR;
1452 break;
1453 }
1454 default:
1455 warning(CONTEXT_FORMAT "failed to load CSV file value "
1456 "%s[%ld] into register %s; entry for address 0x%lx %s",
1457 CONTEXT(I), arg.name, arg.value,
1458 getRegName(getReg(regno)), I->address,
1459 (val.type == MATCH_TYPE_UNDEFINED? "is missing":
1460 "is not supported"));
1461 sendSExtFromI32ToR64(out, 0, regno);
1462 t = TYPE_NULL_PTR;
1463 break;
1464 }
1465 break;
1466 }
1467 case ARGUMENT_INTEGER:
1468 sendLoadValueMetadata(out, arg.value, regno);
1469 break;
1470 case ARGUMENT_STRING:
1471 {
1472 std::string offset("{\"rel32\":\".Lstr");
1473 offset += std::to_string(regno);
1474 offset += '@';
1475 offset += name;
1476 offset += "\"}";
1477 sendLeaFromPCRelToR64(out, offset.c_str(), regno);
1478 t = TYPE_CONST_CHAR_PTR;

Callers 1

sendCallMetadataMethod · 0.85

Calls 15

errorFunction · 0.85
sendSaveRegToStackFunction · 0.85
getRegFunction · 0.85
getCSVValueFunction · 0.85
sendLoadValueMetadataFunction · 0.85
sendLeaFromPCRelToR64Function · 0.85
warningFunction · 0.85
sendSExtFromI32ToR64Function · 0.85
sendLoadPointerMetadataFunction · 0.85
sendLoadNextMetadataFunction · 0.85
sendMovFromI64ToR64Function · 0.85

Tested by

no test coverage detected