authorgravatar for kubkon@jakubkonka.comJakub Konka <kubkon@jakubkonka.com> 2021-06-11 16:52:17+02:00
committergravatar for kubkon@jakubkonka.comJakub Konka <kubkon@jakubkonka.com> 2021-06-11 16:52:22+02:00
logb93fd4bb73506a8feb0b4c312c1afbf88cc9248d
treef512539ec804f7bfd23588f8bf50606a760a1454
parent961d556570e19c2fca1ba5ad1aadd843f012b7ed

zld: match all __DATA sections as __data except __const

Examples of such sections include: * in Go, you will get `__DATA,__noptrdata` or `__DATA,__go_buildinfo` which should be mapped to `__DATA,__data`

1 files changed, 11 insertions(+), 12 deletions(-)

src/link/MachO/Zld.zig+11-12
...@@ -857,24 +857,23 @@ fn getMatchingSection(self: *Zld, section: macho.section_64) ?MatchingSection {...@@ -857,24 +857,23 @@ fn getMatchingSection(self: *Zld, section: macho.section_64) ?MatchingSection {
857 .seg = self.text_segment_cmd_index.?,857 .seg = self.text_segment_cmd_index.?,
858 .sect = self.ustring_section_index.?,858 .sect = self.ustring_section_index.?,
859 };859 };
860 } else {
861 break :blk .{
862 .seg = self.text_segment_cmd_index.?,
863 .sect = self.text_const_section_index.?,
864 };
865 }860 }
866 } else if (mem.eql(u8, segname, "__DATA")) {861 break :blk .{
867 if (mem.eql(u8, sectname, "__data")) {862 .seg = self.text_segment_cmd_index.?,
868 break :blk .{863 .sect = self.text_const_section_index.?,
869 .seg = self.data_segment_cmd_index.?,864 };
870 .sect = self.data_section_index.?,865 }
871 };866 if (mem.eql(u8, segname, "__DATA")) {
872 } else if (mem.eql(u8, sectname, "__const")) {867 if (mem.eql(u8, sectname, "__const")) {
873 break :blk .{868 break :blk .{
874 .seg = self.data_const_segment_cmd_index.?,869 .seg = self.data_const_segment_cmd_index.?,
875 .sect = self.data_const_section_index.?,870 .sect = self.data_const_section_index.?,
876 };871 };
877 }872 }
873 break :blk .{
874 .seg = self.data_segment_cmd_index.?,
875 .sect = self.data_section_index.?,
876 };
878 }877 }
879 break :blk null;878 break :blk null;
880 },879 },