1
1
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:
Rui Ueyama 2021-10-14 20:20:38 +09:00
parent de34da86a0
commit 4fee9df38d
2 changed files with 15 additions and 3 deletions

View File

@ -401,8 +401,18 @@ void dump_file(std::string path) {
LinkEditDataCommand &cmd = *(LinkEditDataCommand *)&lc;
std::cout << " dataoff: 0x" << cmd.dataoff
<< "\n datasize: 0x" << cmd.datasize
<< "\n data: ";
print_bytes(buf + cmd.dataoff, cmd.datasize);
<< "\n data:";
u8 *p = buf + cmd.dataoff;
u64 addr = 0;
for (;;) {
u64 delta = read_uleb(p);
if (!delta)
break;
addr += delta;
std::cout << std::hex << " 0x" << addr;
}
std::cout << "\n";
break;
}
case LC_MAIN: {

4
mold.h
View File

@ -236,10 +236,12 @@ inline i64 write_uleb(u8 *buf, u64 val) {
inline u64 read_uleb(u8 *&buf) {
u64 val = 0;
u8 shift = 0;
u8 byte;
do {
byte = *buf++;
val = (val << 7) | (byte & 0x7f);
val |= (byte & 0x7f) << shift;
shift += 7;
} while (byte & 0x80);
return val;
}