Commit 49b3986417
Changed files (2)
src
link
MachO
src/link/MachO/Object.zig
@@ -94,7 +94,7 @@ pub const Section = struct {
pub fn isCode(self: Section) bool {
const attr = self.sectionAttrs();
- return attr & macho.S_ATTR_PURE_INSTRUCTIONS != 0 and attr & macho.S_ATTR_SOME_INSTRUCTIONS != 0;
+ return attr & macho.S_ATTR_PURE_INSTRUCTIONS != 0 or attr & macho.S_ATTR_SOME_INSTRUCTIONS != 0;
}
pub fn isDebug(self: Section) bool {
src/link/MachO/Zld.zig
@@ -367,6 +367,7 @@ fn mapAndUpdateSections(
offset,
offset + size,
});
+ log.debug(" | flags 0x{x}", .{source_sect.inner.flags});
source_sect.target_map = .{
.segment_id = target_seg_id,
@@ -740,6 +741,21 @@ fn getMatchingSection(self: *Zld, sect: Object.Section) !?MatchingSection {
.seg = self.text_segment_cmd_index.?,
.sect = self.objc_methlist_section_index.?,
};
+ } else if (mem.eql(u8, sectname, "__rodata") or
+ mem.eql(u8, sectname, "__typelink") or
+ mem.eql(u8, sectname, "__itablink") or
+ mem.eql(u8, sectname, "__gosymtab") or
+ mem.eql(u8, sectname, "__gopclntab"))
+ {
+ if (self.data_const_section_index == null) {
+ self.data_const_section_index = @intCast(u16, data_const_seg.sections.items.len);
+ try data_const_seg.addSection(self.allocator, "__const", .{});
+ }
+
+ break :blk .{
+ .seg = self.data_const_segment_cmd_index.?,
+ .sect = self.data_const_section_index.?,
+ };
} else {
if (self.text_const_section_index == null) {
self.text_const_section_index = @intCast(u16, text_seg.sections.items.len);