| 284 | } |
| 285 | |
| 286 | Error Assembler::embedLabel(const Label& label) { |
| 287 | if (_lastError) return _lastError; |
| 288 | ASMJIT_ASSERT(_code != nullptr); |
| 289 | |
| 290 | RelocEntry* re; |
| 291 | LabelEntry* le = _code->getLabelEntry(label); |
| 292 | |
| 293 | if (ASMJIT_UNLIKELY(!le)) |
| 294 | return setLastError(DebugUtils::errored(kErrorInvalidLabel)); |
| 295 | |
| 296 | Error err; |
| 297 | uint32_t gpSize = getGpSize(); |
| 298 | |
| 299 | if (getRemainingSpace() < gpSize) { |
| 300 | err = _code->growBuffer(&_section->_buffer, gpSize); |
| 301 | if (ASMJIT_UNLIKELY(err)) return setLastError(err); |
| 302 | } |
| 303 | |
| 304 | #if !defined(ASMJIT_DISABLE_LOGGING) |
| 305 | if (_globalOptions & kOptionLoggingEnabled) |
| 306 | _code->_logger->logf(gpSize == 4 ? ".dd L%u\n" : ".dq L%u\n", Operand::unpackId(label.getId())); |
| 307 | #endif // !ASMJIT_DISABLE_LOGGING |
| 308 | |
| 309 | err = _code->newRelocEntry(&re, RelocEntry::kTypeRelToAbs, gpSize); |
| 310 | if (ASMJIT_UNLIKELY(err)) return setLastError(err); |
| 311 | |
| 312 | re->_sourceSectionId = _section->getId(); |
| 313 | re->_sourceOffset = static_cast<uint64_t>(getOffset()); |
| 314 | |
| 315 | if (le->isBound()) { |
| 316 | re->_targetSectionId = le->getSectionId(); |
| 317 | re->_data = static_cast<uint64_t>(static_cast<int64_t>(le->getOffset())); |
| 318 | } |
| 319 | else { |
| 320 | LabelLink* link = _code->newLabelLink(le, _section->getId(), getOffset(), 0); |
| 321 | if (ASMJIT_UNLIKELY(!link)) |
| 322 | return setLastError(DebugUtils::errored(kErrorNoHeapMemory)); |
| 323 | link->relocId = re->getId(); |
| 324 | } |
| 325 | |
| 326 | // Emit dummy DWORD/QWORD depending on the address size. |
| 327 | ::memset(_bufferPtr, 0, gpSize); |
| 328 | _bufferPtr += gpSize; |
| 329 | |
| 330 | return kErrorOk; |
| 331 | } |
| 332 | |
| 333 | Error Assembler::embedConstPool(const Label& label, const ConstPool& pool) { |
| 334 | if (_lastError) return _lastError; |
nothing calls this directly
no test coverage detected