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

Function lookupLabel

src/e9patch/e9trampoline.cpp:724–742  ·  view source on GitHub ↗

* Lookup a label value. */

Source from the content-addressed store, hash-verified

722 * Lookup a label value.
723 */
724static off_t lookupLabel(const Binary *B, const char *label,
725 const Instr *I, intptr_t addr, const LabelSet &labels)
726{
727 if (label[0] != '.' && label[1] != 'L')
728 error("failed to build trampoline at address 0x%lx; "
729 "unknown prefix for \"%s\" label", I->addr, label);
730
731 intptr_t target = getBuiltinLabelAddress(B, I, label);
732 if (target != INTPTR_MIN)
733 return target - addr;
734
735 // Check for user labels:
736 Label L(I, label);
737 auto i = labels.find(L);
738 if (i == labels.end())
739 error("failed to build trampoline at address 0x%lx; "
740 "unknown label \"%s\"", I->addr, label);
741 return i->second - addr;
742}
743
744/*
745 * Build the trampoline bytes.

Callers 1

buildBytesFunction · 0.85

Calls 4

errorFunction · 0.85
getBuiltinLabelAddressFunction · 0.85
findMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected