| ... | ... | @@ -481,8 +481,7 @@ fn updateMetadata(self: *Zld) !void { |
| 481 | 481 | .reserved3 = 0, |
| 482 | 482 | }); |
| 483 | 483 | } |
| 484 | | } else if (mem.eql(u8, segname, "__DATA")) { |
| 485 | | if (!mem.eql(u8, sectname, "__const")) continue; |
| 484 | } else if (mem.eql(u8, segname, "__DATA") or mem.eql(u8, segname, "__DATA_CONST")) { |
| 486 | 485 | if (self.data_const_section_index != null) continue; |
| 487 | 486 | |
| 488 | 487 | self.data_const_section_index = @intCast(u16, data_const_seg.sections.items.len); |
| ... | ... | @@ -503,7 +502,6 @@ fn updateMetadata(self: *Zld) !void { |
| 503 | 502 | } |
| 504 | 503 | }, |
| 505 | 504 | macho.S_CSTRING_LITERALS => { |
| 506 | | if (!mem.eql(u8, segname, "__TEXT")) continue; |
| 507 | 505 | if (self.cstring_section_index != null) continue; |
| 508 | 506 | |
| 509 | 507 | self.cstring_section_index = @intCast(u16, text_seg.sections.items.len); |
| ... | ... | @@ -523,7 +521,6 @@ fn updateMetadata(self: *Zld) !void { |
| 523 | 521 | }); |
| 524 | 522 | }, |
| 525 | 523 | macho.S_MOD_INIT_FUNC_POINTERS => { |
| 526 | | if (!mem.eql(u8, segname, "__DATA")) continue; |
| 527 | 524 | if (self.mod_init_func_section_index != null) continue; |
| 528 | 525 | |
| 529 | 526 | self.mod_init_func_section_index = @intCast(u16, data_const_seg.sections.items.len); |
| ... | ... | @@ -543,7 +540,6 @@ fn updateMetadata(self: *Zld) !void { |
| 543 | 540 | }); |
| 544 | 541 | }, |
| 545 | 542 | macho.S_MOD_TERM_FUNC_POINTERS => { |
| 546 | | if (!mem.eql(u8, segname, "__DATA")) continue; |
| 547 | 543 | if (self.mod_term_func_section_index != null) continue; |
| 548 | 544 | |
| 549 | 545 | self.mod_term_func_section_index = @intCast(u16, data_const_seg.sections.items.len); |
| ... | ... | @@ -563,7 +559,6 @@ fn updateMetadata(self: *Zld) !void { |
| 563 | 559 | }); |
| 564 | 560 | }, |
| 565 | 561 | macho.S_ZEROFILL => { |
| 566 | | if (!mem.eql(u8, segname, "__DATA")) continue; |
| 567 | 562 | if (mem.eql(u8, sectname, "__common")) { |
| 568 | 563 | if (self.common_section_index != null) continue; |
| 569 | 564 | |
| ... | ... | @@ -603,7 +598,6 @@ fn updateMetadata(self: *Zld) !void { |
| 603 | 598 | } |
| 604 | 599 | }, |
| 605 | 600 | macho.S_THREAD_LOCAL_VARIABLES => { |
| 606 | | if (!mem.eql(u8, segname, "__DATA")) continue; |
| 607 | 601 | if (self.tlv_section_index != null) continue; |
| 608 | 602 | |
| 609 | 603 | self.tlv_section_index = @intCast(u16, data_seg.sections.items.len); |
| ... | ... | @@ -623,7 +617,6 @@ fn updateMetadata(self: *Zld) !void { |
| 623 | 617 | }); |
| 624 | 618 | }, |
| 625 | 619 | macho.S_THREAD_LOCAL_REGULAR => { |
| 626 | | if (!mem.eql(u8, segname, "__DATA")) continue; |
| 627 | 620 | if (self.tlv_data_section_index != null) continue; |
| 628 | 621 | |
| 629 | 622 | self.tlv_data_section_index = @intCast(u16, data_seg.sections.items.len); |
| ... | ... | @@ -643,7 +636,6 @@ fn updateMetadata(self: *Zld) !void { |
| 643 | 636 | }); |
| 644 | 637 | }, |
| 645 | 638 | macho.S_THREAD_LOCAL_ZEROFILL => { |
| 646 | | if (!mem.eql(u8, segname, "__DATA")) continue; |
| 647 | 639 | if (self.tlv_bss_section_index != null) continue; |
| 648 | 640 | |
| 649 | 641 | self.tlv_bss_section_index = @intCast(u16, data_seg.sections.items.len); |
| ... | ... | @@ -863,6 +855,12 @@ fn getMatchingSection(self: *Zld, section: macho.section_64) ?MatchingSection { |
| 863 | 855 | .sect = self.text_const_section_index.?, |
| 864 | 856 | }; |
| 865 | 857 | } |
| 858 | if (mem.eql(u8, segname, "__DATA_CONST")) { |
| 859 | break :blk .{ |
| 860 | .seg = self.data_const_segment_cmd_index.?, |
| 861 | .sect = self.data_const_section_index.?, |
| 862 | }; |
| 863 | } |
| 866 | 864 | if (mem.eql(u8, segname, "__DATA")) { |
| 867 | 865 | if (mem.eql(u8, sectname, "__const")) { |
| 868 | 866 | break :blk .{ |
| ... | ... | @@ -1900,7 +1898,12 @@ fn relocTargetAddr(self: *Zld, object: *const Object, target: reloc.Relocation.T |
| 1900 | 1898 | } |
| 1901 | 1899 | }, |
| 1902 | 1900 | .section => |sect_id| { |
| 1901 | log.debug(" | section offset", .{}); |
| 1903 | 1902 | const source_sect = object.sections.items[sect_id]; |
| 1903 | log.debug(" | section '{s},{s}'", .{ |
| 1904 | parseName(&source_sect.inner.segname), |
| 1905 | parseName(&source_sect.inner.sectname), |
| 1906 | }); |
| 1904 | 1907 | const target_map = source_sect.target_map orelse unreachable; |
| 1905 | 1908 | const target_seg = self.load_commands.items[target_map.segment_id].Segment; |
| 1906 | 1909 | const target_sect = target_seg.sections.items[target_map.section_id]; |