mirror of
https://github.com/rui314/mold.git
synced 2024-09-21 09:57:18 +03:00
[Mach-O] Output "hello world" program
With this change, ld64.mold is able to emit a "hello world" program. $ ./ld64.mold -out hello $ ./hello Hello world
This commit is contained in:
parent
ded5d5e6a1
commit
76874d84ba
@ -185,10 +185,10 @@ void dump_file(std::string path) {
|
||||
<< "\n attr: 0x" << std::hex << sec[j].attr
|
||||
<< "\n";
|
||||
|
||||
// if (sec[j].size) {
|
||||
// std::cout << " contents: ";
|
||||
// print_bytes(buf + sec[j].offset, sec[j].size);
|
||||
// }
|
||||
if (sec[j].size) {
|
||||
std::cout << " contents: ";
|
||||
print_bytes(buf + sec[j].offset, sec[j].size);
|
||||
}
|
||||
|
||||
if (sec[j].reloff) {
|
||||
MachRel *rel = (MachRel *)(buf + sec[j].reloff);
|
||||
|
@ -217,7 +217,7 @@ public:
|
||||
StubsSection(OutputSegment &parent);
|
||||
void copy_buf(Context &ctx) override;
|
||||
|
||||
std::vector<u8> contents = {0x40, 0x7c, 0x25, 0xff, 0x00, 0x00};
|
||||
std::vector<u8> contents = {0xff, 0x25, 0x7c, 0x40, 0x00, 0x00};
|
||||
};
|
||||
|
||||
class StubHelperSection : public OutputSection {
|
||||
@ -226,8 +226,8 @@ public:
|
||||
void copy_buf(Context &ctx) override;
|
||||
|
||||
std::vector<u8> contents = {
|
||||
0x7d, 0x1d, 0x8d, 0x4c, 0x41, 0x00, 0x00, 0x40, 0x6d, 0x25, 0xff, 0x53,
|
||||
0x90, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x68, 0xff, 0xe6, 0xe9, 0x00,
|
||||
0x4c, 0x8d, 0x1d, 0x7d, 0x40, 0x00, 0x00, 0x41, 0x53, 0xff, 0x25, 0x6d,
|
||||
0x00, 0x00, 0x00, 0x90, 0x68, 0x00, 0x00, 0x00, 0x00, 0xe9, 0xe6, 0xff,
|
||||
0xff, 0xff,
|
||||
};
|
||||
};
|
||||
|
@ -359,6 +359,7 @@ StubsSection::StubsSection(OutputSegment &parent) : OutputSection(parent) {
|
||||
hdr.type = S_SYMBOL_STUBS;
|
||||
hdr.attr = S_ATTR_SOME_INSTRUCTIONS | S_ATTR_PURE_INSTRUCTIONS;
|
||||
hdr.size = contents.size();
|
||||
hdr.reserved2 = 6;
|
||||
}
|
||||
|
||||
void StubsSection::copy_buf(Context &ctx) {
|
||||
@ -405,6 +406,7 @@ GotSection::GotSection(OutputSegment &parent)
|
||||
hdr.p2align = __builtin_ctz(8);
|
||||
hdr.type = S_NON_LAZY_SYMBOL_POINTERS;
|
||||
hdr.size = 8;
|
||||
hdr.reserved1 = 1;
|
||||
}
|
||||
|
||||
LaSymbolPtrSection::LaSymbolPtrSection(OutputSegment &parent)
|
||||
@ -413,6 +415,7 @@ LaSymbolPtrSection::LaSymbolPtrSection(OutputSegment &parent)
|
||||
hdr.p2align = __builtin_ctz(8);
|
||||
hdr.type = S_LAZY_SYMBOL_POINTERS;
|
||||
hdr.size = contents.size();
|
||||
hdr.reserved1 = 2;
|
||||
}
|
||||
|
||||
void LaSymbolPtrSection::copy_buf(Context &ctx) {
|
||||
|
Loading…
Reference in New Issue
Block a user