MCPcopy Create free account
hub / github.com/danoon2/Boxedwine / new_section

Method new_section

lib/asmjit/asmjit/core/codeholder.cpp:506–551  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

504// =====================
505
506Error CodeHolder::new_section(Out<Section*> section_out, const char* name, size_t name_size, SectionFlags flags, uint32_t alignment, int32_t order) noexcept {
507 *section_out = nullptr;
508
509 if (ASMJIT_UNLIKELY(!Support::is_zero_or_power_of_2(alignment))) {
510 return make_error(Error::kInvalidArgument);
511 }
512
513 if (name_size == SIZE_MAX) {
514 name_size = strlen(name);
515 }
516
517 if (ASMJIT_UNLIKELY(name_size > Globals::kMaxSectionNameSize)) {
518 return make_error(Error::kInvalidSectionName);
519 }
520
521 uint32_t section_id = _sections._size;
522 if (ASMJIT_UNLIKELY(section_id == Globals::kInvalidId)) {
523 return make_error(Error::kTooManySections);
524 }
525
526 ASMJIT_PROPAGATE(_sections.reserve_additional(_arena));
527 ASMJIT_PROPAGATE(_sections_by_order.reserve_additional(_arena));
528
529 Section* section = _arena.alloc_oneshot<Section>();
530 if (ASMJIT_UNLIKELY(!section)) {
531 return make_error(Error::kOutOfMemory);
532 }
533
534 if (alignment == 0u) {
535 alignment = 1u;
536 }
537
538 Section_init_data(section, section_id, flags, alignment, order);
539 Section_init_buffer(section);
540 memcpy(section->_name.str, name, name_size);
541
542 Section** insert_position = std::lower_bound(_sections_by_order.begin(), _sections_by_order.end(), section, [](const Section* a, const Section* b) {
543 return std::make_tuple(a->order(), a->section_id()) < std::make_tuple(b->order(), b->section_id());
544 });
545
546 _sections.append_unchecked(section);
547 _sections_by_order.insert_unchecked((size_t)(insert_position - _sections_by_order.data()), section);
548
549 *section_out = section;
550 return Error::kOk;
551}
552
553Section* CodeHolder::section_by_name(const char* name, size_t name_size) const noexcept {
554 if (name_size == SIZE_MAX) {

Callers 2

mainFunction · 0.80
UNITFunction · 0.80

Calls 13

is_zero_or_power_of_2Function · 0.85
make_errorFunction · 0.85
Section_init_dataFunction · 0.85
Section_init_bufferFunction · 0.85
memcpyFunction · 0.85
reserve_additionalMethod · 0.80
orderMethod · 0.80
append_uncheckedMethod · 0.80
insert_uncheckedMethod · 0.80
beginMethod · 0.45
endMethod · 0.45
section_idMethod · 0.45

Tested by 1

mainFunction · 0.64