| ... | @@ -736,16 +736,13 @@ pub fn initMetadata(self: *Elf) !void { | ... | @@ -736,16 +736,13 @@ pub fn initMetadata(self: *Elf) !void { |
| 736 | | 736 | |
| 737 | if (self.phdr_zig_load_zerofill_index == null) { | 737 | if (self.phdr_zig_load_zerofill_index == null) { |
| 738 | const alignment = if (is_linux) self.page_size else @as(u16, ptr_size); | 738 | const alignment = if (is_linux) self.page_size else @as(u16, ptr_size); |
| 739 | self.phdr_zig_load_zerofill_index = try self.allocateSegment(.{ | 739 | self.phdr_zig_load_zerofill_index = try self.addPhdr(.{ |
| | 740 | .type = elf.PT_LOAD, |
| 740 | .addr = if (ptr_bit_width >= 32) 0x14000000 else 0xf000, | 741 | .addr = if (ptr_bit_width >= 32) 0x14000000 else 0xf000, |
| 741 | .memsz = 0, | 742 | .memsz = 1024, |
| 742 | .filesz = 0, | 743 | .@"align" = alignment, |
| 743 | .alignment = alignment, | | |
| 744 | .flags = elf.PF_R | elf.PF_W, | 744 | .flags = elf.PF_R | elf.PF_W, |
| 745 | }); | 745 | }); |
| 746 | const phdr = &self.phdrs.items[self.phdr_zig_load_zerofill_index.?]; | | |
| 747 | phdr.p_offset = self.phdrs.items[self.phdr_zig_load_rw_index.?].p_offset; // .bss overlaps .data | | |
| 748 | phdr.p_memsz = 1024; | | |
| 749 | } | 746 | } |
| 750 | | 747 | |
| 751 | if (self.zig_text_section_index == null) { | 748 | if (self.zig_text_section_index == null) { |
| ... | @@ -1588,16 +1585,6 @@ pub fn flushModule(self: *Elf, comp: *Compilation, prog_node: *std.Progress.Node | ... | @@ -1588,16 +1585,6 @@ pub fn flushModule(self: *Elf, comp: *Compilation, prog_node: *std.Progress.Node |
| 1588 | // Beyond this point, everything has been allocated a virtual address and we can resolve | 1585 | // Beyond this point, everything has been allocated a virtual address and we can resolve |
| 1589 | // the relocations, and commit objects to file. | 1586 | // the relocations, and commit objects to file. |
| 1590 | if (self.zig_module_index) |index| { | 1587 | if (self.zig_module_index) |index| { |
| 1591 | // .bss.zig always overlaps .data.zig in file offset, but is zero-sized in file so it doesn't | | |
| 1592 | // get mapped by the loader | | |
| 1593 | if (self.zig_data_section_index) |data_shndx| blk: { | | |
| 1594 | const bss_shndx = self.zig_bss_section_index orelse break :blk; | | |
| 1595 | const data_phndx = self.phdr_to_shdr_table.get(data_shndx).?; | | |
| 1596 | const bss_phndx = self.phdr_to_shdr_table.get(bss_shndx).?; | | |
| 1597 | self.shdrs.items[bss_shndx].sh_offset = self.shdrs.items[data_shndx].sh_offset; | | |
| 1598 | self.phdrs.items[bss_phndx].p_offset = self.phdrs.items[data_phndx].p_offset; | | |
| 1599 | } | | |
| 1600 | | | |
| 1601 | const zig_module = self.file(index).?.zig_module; | 1588 | const zig_module = self.file(index).?.zig_module; |
| 1602 | for (zig_module.atoms.items) |atom_index| { | 1589 | for (zig_module.atoms.items) |atom_index| { |
| 1603 | const atom_ptr = self.atom(atom_index) orelse continue; | 1590 | const atom_ptr = self.atom(atom_index) orelse continue; |