| ... | ... | @@ -442,6 +442,25 @@ fn updateMetadata(self: *Zld) !void { |
| 442 | 442 | const flags = source_sect.flags; |
| 443 | 443 | |
| 444 | 444 | switch (flags) { |
| 445 | macho.S_REGULAR | macho.S_ATTR_PURE_INSTRUCTIONS | macho.S_ATTR_SOME_INSTRUCTIONS => { |
| 446 | if (self.text_section_index != null) continue; |
| 447 | |
| 448 | self.text_section_index = @intCast(u16, text_seg.sections.items.len); |
| 449 | try text_seg.addSection(self.allocator, .{ |
| 450 | .sectname = makeStaticString("__text"), |
| 451 | .segname = makeStaticString("__TEXT"), |
| 452 | .addr = 0, |
| 453 | .size = 0, |
| 454 | .offset = 0, |
| 455 | .@"align" = 0, |
| 456 | .reloff = 0, |
| 457 | .nreloc = 0, |
| 458 | .flags = macho.S_REGULAR | macho.S_ATTR_PURE_INSTRUCTIONS | macho.S_ATTR_SOME_INSTRUCTIONS, |
| 459 | .reserved1 = 0, |
| 460 | .reserved2 = 0, |
| 461 | .reserved3 = 0, |
| 462 | }); |
| 463 | }, |
| 445 | 464 | macho.S_REGULAR, macho.S_4BYTE_LITERALS, macho.S_8BYTE_LITERALS, macho.S_16BYTE_LITERALS => { |
| 446 | 465 | if (mem.eql(u8, segname, "__TEXT")) { |
| 447 | 466 | if (mem.eql(u8, sectname, "__ustring")) { |
| ... | ... | @@ -654,8 +673,32 @@ fn updateMetadata(self: *Zld) !void { |
| 654 | 673 | .reserved3 = 0, |
| 655 | 674 | }); |
| 656 | 675 | }, |
| 676 | macho.S_COALESCED | |
| 677 | macho.S_ATTR_NO_TOC | |
| 678 | macho.S_ATTR_STRIP_STATIC_SYMS | |
| 679 | macho.S_ATTR_LIVE_SUPPORT => { |
| 680 | log.debug("TODO __eh_frame section: type 0x{x}, name '{s},{s}'", .{ |
| 681 | flags, segname, sectname, |
| 682 | }); |
| 683 | continue; |
| 684 | }, |
| 685 | macho.S_REGULAR | macho.S_ATTR_DEBUG => { |
| 686 | if (mem.eql(u8, "__LD", segname) and mem.eql(u8, "__compact_unwind", sectname)) { |
| 687 | log.debug("TODO compact unwind section: type 0x{x}, name '{s},{s}'", .{ |
| 688 | flags, segname, sectname, |
| 689 | }); |
| 690 | } |
| 691 | continue; |
| 692 | }, |
| 657 | 693 | else => { |
| 658 | | log.debug("unhandled section type 0x{x} for '{s}/{s}'", .{ flags, segname, sectname }); |
| 694 | if (mem.eql(u8, "__LLVM", segname) and mem.eql(u8, "__asm", sectname)) { |
| 695 | log.debug("TODO LLVM bitcode section: type 0x{x}, name '{s},{s}'", .{ |
| 696 | flags, segname, sectname, |
| 697 | }); |
| 698 | continue; |
| 699 | } |
| 700 | log.err("unhandled section type 0x{x} for '{s},{s}'", .{ flags, segname, sectname }); |
| 701 | return error.UnhandledSection; |
| 659 | 702 | }, |
| 660 | 703 | } |
| 661 | 704 | } |