| 255 | } |
| 256 | |
| 257 | Error BaseAssembler::embed_label(const Label& label, size_t data_size) { |
| 258 | if (ASMJIT_UNLIKELY(!_code)) { |
| 259 | return report_error(make_error(Error::kNotInitialized)); |
| 260 | } |
| 261 | |
| 262 | if (ASMJIT_UNLIKELY(is_label_valid(label))) { |
| 263 | return report_error(make_error(Error::kInvalidLabel)); |
| 264 | } |
| 265 | |
| 266 | RelocEntry* re; |
| 267 | LabelEntry& le = _code->label_entry_of(label); |
| 268 | |
| 269 | if (data_size == 0) { |
| 270 | data_size = register_size(); |
| 271 | } |
| 272 | |
| 273 | if (ASMJIT_UNLIKELY(!Support::is_power_of_2_up_to(data_size, 8u))) { |
| 274 | return report_error(make_error(Error::kInvalidOperandSize)); |
| 275 | } |
| 276 | |
| 277 | CodeWriter writer(this); |
| 278 | ASMJIT_PROPAGATE(writer.ensure_space(this, data_size)); |
| 279 | |
| 280 | #ifndef ASMJIT_NO_LOGGING |
| 281 | if (_logger) { |
| 282 | StringTmp<256> sb; |
| 283 | sb.append('.'); |
| 284 | Formatter::format_data_type(sb, _logger->flags(), arch(), data_type_id_by_size_table[data_size]); |
| 285 | sb.append(' '); |
| 286 | Formatter::format_label(sb, FormatFlags::kNone, this, label.id()); |
| 287 | sb.append('\n'); |
| 288 | _logger->log(sb); |
| 289 | } |
| 290 | #endif |
| 291 | |
| 292 | Error err = _code->new_reloc_entry(Out(re), RelocType::kRelToAbs); |
| 293 | if (ASMJIT_UNLIKELY(err != Error::kOk)) { |
| 294 | return report_error(err); |
| 295 | } |
| 296 | |
| 297 | re->_source_section_id = _section->section_id(); |
| 298 | re->_source_offset = offset(); |
| 299 | re->_format.reset_to_simple_value(OffsetType::kUnsignedOffset, data_size); |
| 300 | |
| 301 | if (le.is_bound()) { |
| 302 | re->_target_section_id = le.section_id(); |
| 303 | re->_payload = le.offset(); |
| 304 | } |
| 305 | else { |
| 306 | OffsetFormat of; |
| 307 | of.reset_to_simple_value(OffsetType::kUnsignedOffset, data_size); |
| 308 | |
| 309 | Fixup* fixup = _code->new_fixup(le, _section->section_id(), offset(), 0, of); |
| 310 | if (ASMJIT_UNLIKELY(!fixup)) { |
| 311 | return report_error(make_error(Error::kOutOfMemory)); |
| 312 | } |
| 313 | |
| 314 | fixup->label_or_reloc_id = re->id(); |
nothing calls this directly
no test coverage detected