mirror of
https://github.com/rui314/mold.git
synced 2024-11-13 09:39:13 +03:00
[Mach-O] wip
This commit is contained in:
parent
f7d3fda88a
commit
d76c6966b0
@ -248,7 +248,7 @@ void dump_file(std::string path) {
|
||||
std::cout << "LC_SEGMENT_64\n";
|
||||
SegmentCommand &cmd = *(SegmentCommand *)&lc;
|
||||
std::cout << " cmdsize: " << cmd.cmdsize
|
||||
<< "\n segname: " << cmd.segname
|
||||
<< "\n segname: " << cmd.get_segname()
|
||||
<< "\n vmaddr: 0x" << std::hex << cmd.vmaddr
|
||||
<< "\n vmsize: 0x" << cmd.vmsize
|
||||
<< "\n fileoff: 0x" << cmd.fileoff
|
||||
@ -261,8 +261,8 @@ void dump_file(std::string path) {
|
||||
|
||||
MachSection *sec = (MachSection *)((u8 *)&lc + sizeof(cmd));
|
||||
for (i64 j = 0; j < cmd.nsects; j++) {
|
||||
std::cout << " section:\n sectname: " << sec[j].sectname
|
||||
<< "\n segname: " << sec[j].segname
|
||||
std::cout << " section:\n sectname: " << sec[j].get_sectname()
|
||||
<< "\n segname: " << sec[j].get_segname()
|
||||
<< "\n addr: 0x" << std::hex << sec[j].addr
|
||||
<< "\n size: 0x" << sec[j].size
|
||||
<< "\n offset: 0x" << sec[j].offset
|
||||
@ -292,7 +292,8 @@ void dump_file(std::string path) {
|
||||
}
|
||||
}
|
||||
|
||||
if (sec[j].segname == "__TEXT"sv && sec[j].sectname == "__unwind_info"sv)
|
||||
if (sec[j].get_segname() == "__TEXT" &&
|
||||
sec[j].get_sectname() == "__unwind_info"sv)
|
||||
dump_unwind_info(buf, sec[j]);
|
||||
}
|
||||
break;
|
||||
|
@ -5,7 +5,8 @@
|
||||
namespace mold::macho {
|
||||
|
||||
std::ostream &operator<<(std::ostream &out, const InputSection &sec) {
|
||||
out << sec.file << "(" << sec.hdr.segname << "," << sec.hdr.sectname << ")";
|
||||
out << sec.file << "(" << sec.hdr.get_segname() << ","
|
||||
<< sec.hdr.get_sectname() << ")";
|
||||
return out;
|
||||
}
|
||||
|
||||
|
@ -1,6 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include <cstdint>
|
||||
#include <string_view>
|
||||
|
||||
namespace mold::macho {
|
||||
|
||||
@ -316,6 +317,10 @@ struct LoadCommand {
|
||||
};
|
||||
|
||||
struct SegmentCommand {
|
||||
std::string_view get_segname() const {
|
||||
return {segname, strnlen(segname, sizeof(segname))};
|
||||
}
|
||||
|
||||
u32 cmd;
|
||||
u32 cmdsize;
|
||||
char segname[16];
|
||||
@ -330,6 +335,14 @@ struct SegmentCommand {
|
||||
};
|
||||
|
||||
struct MachSection {
|
||||
std::string_view get_segname() const {
|
||||
return {segname, strnlen(segname, sizeof(segname))};
|
||||
}
|
||||
|
||||
std::string_view get_sectname() const {
|
||||
return {sectname, strnlen(sectname, sizeof(sectname))};
|
||||
}
|
||||
|
||||
char sectname[16];
|
||||
char segname[16];
|
||||
u64 addr;
|
||||
|
Loading…
Reference in New Issue
Block a user