CodeQL / Analyze (actions) (push) Canceled after 0s
CodeQL / Analyze (python) (push) Canceled after 0s
pre-commit / pre-commit (push) Canceled after 0s
Multi-Arch CI / setup (push) Canceled after 0s
Publish build_manylinux_x86_64 images / publish_build_manylinux_x86_64 (push) Canceled after 0s
Setup (Multi-Arch) / setup (push) Canceled after 0s
Multi-Arch CI / Linux::${{ fromJSON(needs.setup.outputs.linux_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubi10 image / publish_no_rocm_image_ubi10 (push) Canceled after 0s
Multi-Arch CI / Windows::${{ fromJSON(needs.setup.outputs.windows_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Multi-Arch CI / Manifest Diff (push) Canceled after 0s
TheRock Manifest Diff Report / Generate Manifest Diff Report (push) Canceled after 0s
Multi-Arch CI / CI Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_ocl_rt images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_rocgdb images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Unit Tests / Unit Tests :: ubuntu-24.04 (push) Canceled after 0s
Unit Tests / Unit Tests :: windows-2022 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_media (push) Canceled after 0s
Unit Tests / Unit Tests Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_openmpi (push) Canceled after 0s
98 lines
3.7 KiB
C++
98 lines
3.7 KiB
C++
//===-- LCNoteWriter.cpp --------------------------------------------------===//
|
|
//
|
|
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
|
// See https://llvm.org/LICENSE.txt for license information.
|
|
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
#include "LCNoteWriter.h"
|
|
#include "Utility.h"
|
|
#include "lldb/Utility/UUID.h"
|
|
#include "llvm/BinaryFormat/MachO.h"
|
|
#include <ctype.h>
|
|
#include <stdlib.h>
|
|
|
|
void create_lc_note_binary_load_cmd(const CoreSpec &spec,
|
|
std::vector<uint8_t> &cmds,
|
|
const Binary &binary,
|
|
std::vector<uint8_t> &payload_bytes,
|
|
off_t data_offset) {
|
|
|
|
// Add the payload bytes to payload_bytes.
|
|
size_t starting_payload_size = payload_bytes.size();
|
|
add_uint32(payload_bytes, 1); // version
|
|
lldb_private::UUID uuid;
|
|
uuid.SetFromStringRef(binary.uuid);
|
|
for (size_t i = 0; i < uuid.GetBytes().size(); i++)
|
|
payload_bytes.push_back(uuid.GetBytes().data()[i]);
|
|
if (binary.value_is_slide) {
|
|
add_uint64(payload_bytes, UINT64_MAX); // address
|
|
add_uint64(payload_bytes, binary.value); // slide
|
|
} else {
|
|
add_uint64(payload_bytes, binary.value); // address
|
|
add_uint64(payload_bytes, UINT64_MAX); // slide
|
|
}
|
|
if (binary.name.empty()) {
|
|
payload_bytes.push_back(0); // name_cstring
|
|
} else {
|
|
size_t len = binary.name.size();
|
|
for (size_t i = 0; i < len; i++)
|
|
payload_bytes.push_back(binary.name[i]);
|
|
payload_bytes.push_back(0); // name_cstring
|
|
}
|
|
|
|
size_t payload_size = payload_bytes.size() - starting_payload_size;
|
|
// Pad out the entry to a 4-byte aligned size.
|
|
if (payload_bytes.size() % 4 != 0) {
|
|
size_t pad_bytes =
|
|
((payload_bytes.size() + 4 - 1) & ~(4 - 1)) - payload_bytes.size();
|
|
for (size_t i = 0; i < pad_bytes; i++)
|
|
payload_bytes.push_back(0);
|
|
}
|
|
|
|
// Add the load command bytes to cmds.
|
|
add_uint32(cmds, llvm::MachO::LC_NOTE);
|
|
add_uint32(cmds, sizeof(struct llvm::MachO::note_command));
|
|
char cmdname[16];
|
|
memset(cmdname, '\0', sizeof(cmdname));
|
|
strcpy(cmdname, "load binary");
|
|
for (int i = 0; i < 16; i++)
|
|
cmds.push_back(cmdname[i]);
|
|
add_uint64(cmds, data_offset);
|
|
add_uint64(cmds, payload_size);
|
|
}
|
|
|
|
void create_lc_note_addressable_bits(const CoreSpec &spec,
|
|
std::vector<uint8_t> &cmds,
|
|
const AddressableBits &addr_bits,
|
|
std::vector<uint8_t> &payload_bytes,
|
|
off_t data_offset) {
|
|
// Add the payload bytes to payload_bytes.
|
|
size_t starting_payload_size = payload_bytes.size();
|
|
add_uint32(payload_bytes, 4); // version
|
|
|
|
add_uint32(payload_bytes, *addr_bits.lowmem_bits); // low memory
|
|
add_uint32(payload_bytes, *addr_bits.highmem_bits); // high memory
|
|
add_uint32(payload_bytes, 0); // reserved
|
|
size_t payload_size = payload_bytes.size() - starting_payload_size;
|
|
// Pad out the entry to a 4-byte aligned size.
|
|
if (payload_bytes.size() % 4 != 0) {
|
|
size_t pad_bytes =
|
|
((payload_bytes.size() + 4 - 1) & ~(4 - 1)) - payload_bytes.size();
|
|
for (size_t i = 0; i < pad_bytes; i++)
|
|
payload_bytes.push_back(0);
|
|
}
|
|
|
|
// Add the load command bytes to cmds.
|
|
add_uint32(cmds, llvm::MachO::LC_NOTE);
|
|
add_uint32(cmds, sizeof(struct llvm::MachO::note_command));
|
|
char cmdname[16];
|
|
memset(cmdname, '\0', sizeof(cmdname));
|
|
strcpy(cmdname, "addrable bits");
|
|
for (int i = 0; i < 16; i++)
|
|
cmds.push_back(cmdname[i]);
|
|
add_uint64(cmds, data_offset);
|
|
add_uint64(cmds, payload_size);
|
|
}
|