Skip to content

Commit

Permalink
[Mach-O] Programmatically construct export trie
Browse files Browse the repository at this point in the history
  • Loading branch information
rui314 committed Sep 19, 2021
1 parent 43e513d commit 9881a61
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions macho/output-chunks.cc
Original file line number Diff line number Diff line change
Expand Up @@ -544,14 +544,14 @@ void ExportEncoder::write_trie(u8 *start) {
}

void ExportEncoder::write_trie(u8 *start, TrieNode &node) {
u8 *buf = start;
u8 *buf = start + node.offset;

if (node.is_leaf) {
buf += write_uleb(buf, uleb_size(node.flags) + uleb_size(node.addr));
buf += write_uleb(buf, node.flags);
buf += write_uleb(buf, node.addr);
} else {
*buf++ = 1;
*buf++ = 0;
}

u8 *num_children = buf++;
Expand All @@ -573,8 +573,10 @@ void ExportEncoder::write_trie(u8 *start, TrieNode &node) {
OutputExportSection::OutputExportSection(OutputSegment &parent)
: OutputSection(parent) {
is_hidden = true;
enc.add("__mh_execute_header", 0, 0x100000000);
hdr.size = enc.finish();
enc.add("__mh_execute_header", 0, 0);
enc.add("_hello", 0, 0x3f50);
enc.add("_main", 0, 0x3f70);
hdr.size = align_to(enc.finish(), 8);
}

void OutputExportSection::copy_buf(Context &ctx) {
Expand Down

0 comments on commit 9881a61

Please sign in to comment.