Commit d771c0a7a1

Jakub Konka <kubkon@jakubkonka.com>
2023-11-15 19:07:09
elf: create .got.plt unconditionally
1 parent 6f3bbd5
Changed files (1)
src
link
src/link/Elf.zig
@@ -3394,6 +3394,14 @@ fn initSections(self: *Elf) !void {
         });
     }
 
+    self.got_plt_section_index = try self.addSection(.{
+        .name = ".got.plt",
+        .type = elf.SHT_PROGBITS,
+        .flags = elf.SHF_ALLOC | elf.SHF_WRITE,
+        .addralign = @alignOf(u64),
+        .offset = std.math.maxInt(u64),
+    });
+
     const needs_rela_dyn = blk: {
         if (self.got.flags.needs_rela or self.got.flags.needs_tlsld or
             self.zig_got.flags.needs_rela or self.copy_rel.symbols.items.len > 0) break :blk true;
@@ -3424,13 +3432,6 @@ fn initSections(self: *Elf) !void {
             .addralign = 16,
             .offset = std.math.maxInt(u64),
         });
-        self.got_plt_section_index = try self.addSection(.{
-            .name = ".got.plt",
-            .type = elf.SHT_PROGBITS,
-            .flags = elf.SHF_ALLOC | elf.SHF_WRITE,
-            .addralign = @alignOf(u64),
-            .offset = std.math.maxInt(u64),
-        });
         self.rela_plt_section_index = try self.addSection(.{
             .name = ".rela.plt",
             .type = elf.SHT_RELA,