| ... | ... | @@ -2263,6 +2263,11 @@ pub fn initBuiltins(coff: *Coff) !void { |
| 2263 | 2263 | } |
| 2264 | 2264 | |
| 2265 | 2265 | defer coff.flushSectionMerges() catch unreachable; |
| 2266 | if (coff.isImage()) { |
| 2267 | // In images, the .tls section is a read-only template |
| 2268 | try coff.section_merges.put(gpa, .@".tls", .@".rdata"); |
| 2269 | } |
| 2270 | |
| 2266 | 2271 | if (coff.isImage() and target.isMinGW() and comp.config.link_libc) { |
| 2267 | 2272 | try coff.symbols.ensureUnusedCapacity(gpa, 8); |
| 2268 | 2273 | try coff.globals.ensureUnusedCapacity(gpa, 2); |
| ... | ... | @@ -3543,20 +3548,13 @@ fn objectSectionMapIndex( |
| 3543 | 3548 | ) !Node.ObjectSectionMapIndex { |
| 3544 | 3549 | const gpa = coff.base.comp.gpa; |
| 3545 | 3550 | const name_slice = name.toSlice(coff); |
| 3546 | | // TODO: Should this be a section merge instead? |
| 3547 | | const effective_attributes = if (coff.isImage() and std.mem.startsWith(u8, name_slice, ".tls")) attr: { |
| 3548 | | // In images, the .tls section is a read-only template |
| 3549 | | var attr = attributes; |
| 3550 | | attr.write = false; |
| 3551 | | break :attr attr; |
| 3552 | | } else attributes; |
| 3553 | 3551 | |
| 3554 | 3552 | const object_section_gop = try coff.object_section_table.getOrPut(gpa, name); |
| 3555 | 3553 | const osmi: Node.ObjectSectionMapIndex = @fromBackingInt(@intCast(object_section_gop.index)); |
| 3556 | 3554 | const sym = if (!object_section_gop.found_existing) sym: { |
| 3557 | 3555 | try coff.ensureUnusedStringCapacity(name_slice.len); |
| 3558 | 3556 | const parent_name = coff.getOrPutStringAssumeCapacity(coff.objectSectionParentName(name_slice)); |
| 3559 | | const parent = (try coff.pseudoSectionMapIndex(parent_name, alignment, effective_attributes)).symbol(coff); |
| 3557 | const parent = (try coff.pseudoSectionMapIndex(parent_name, alignment, attributes)).symbol(coff); |
| 3560 | 3558 | try coff.nodes.ensureUnusedCapacity(gpa, 1); |
| 3561 | 3559 | try coff.symbols.ensureUnusedCapacity(gpa, 1); |
| 3562 | 3560 | const parent_ni = parent.node(coff); |
| ... | ... | @@ -3608,7 +3606,7 @@ fn objectSectionMapIndex( |
| 3608 | 3606 | name, |
| 3609 | 3607 | .object, |
| 3610 | 3608 | .fromFlags(sym.section_number.header(coff).flags), |
| 3611 | | effective_attributes, |
| 3609 | attributes, |
| 3612 | 3610 | ); |
| 3613 | 3611 | |
| 3614 | 3612 | return osmi; |