authorgravatar for kubkon@jakubkonka.comJakub Konka <kubkon@jakubkonka.com> 2023-10-15 09:08:14+02:00
committergravatar for kubkon@jakubkonka.comJakub Konka <kubkon@jakubkonka.com> 2023-10-16 19:33:06+02:00
logc71a79f618abcc547f327edcdb45f01768200dca
tree1461b60c4c9be0c39d38ab20290f61a92b939025
parent17635e4f2ae78e358a7a997b161e64de71a01191

elf: make .zig.rodata writeable


2 files changed, 3 insertions(+), 1 deletions(-)

src/link/Elf.zig+1
...@@ -770,6 +770,7 @@ pub fn initMetadata(self: *Elf) !void {...@@ -770,6 +770,7 @@ pub fn initMetadata(self: *Elf) !void {
770 self.zig_rodata_section_index = try self.allocateAllocSection(.{770 self.zig_rodata_section_index = try self.allocateAllocSection(.{
771 .name = ".zig.rodata",771 .name = ".zig.rodata",
772 .phdr_index = self.phdr_zig_load_ro_index.?,772 .phdr_index = self.phdr_zig_load_ro_index.?,
773 .flags = elf.SHF_ALLOC | elf.SHF_WRITE, // TODO rename this section to .data.rel.ro
773 });774 });
774 try self.last_atom_and_free_list_table.putNoClobber(gpa, self.zig_rodata_section_index.?, .{});775 try self.last_atom_and_free_list_table.putNoClobber(gpa, self.zig_rodata_section_index.?, .{});
775 }776 }
src/link/Elf/Atom.zig+2-1
...@@ -757,12 +757,13 @@ pub fn resolveRelocsAlloc(self: Atom, elf_file: *Elf, code: []u8) !void {...@@ -757,12 +757,13 @@ pub fn resolveRelocsAlloc(self: Atom, elf_file: *Elf, code: []u8) !void {
757 // Address of the dynamic thread pointer.757 // Address of the dynamic thread pointer.
758 const DTP = @as(i64, @intCast(elf_file.dtpAddress()));758 const DTP = @as(i64, @intCast(elf_file.dtpAddress()));
759759
760 relocs_log.debug(" {s}: {x}: [{x} => {x}] G({x}) ({s})", .{760 relocs_log.debug(" {s}: {x}: [{x} => {x}] G({x}) ZG({x}) ({s})\n", .{
761 fmtRelocType(r_type),761 fmtRelocType(r_type),
762 r_offset,762 r_offset,
763 P,763 P,
764 S + A,764 S + A,
765 G + GOT + A,765 G + GOT + A,
766 ZIG_GOT + A,
766 target.name(elf_file),767 target.name(elf_file),
767 });768 });
768769