| ... | @@ -89,7 +89,7 @@ pub const DynamicSection = struct { | ... | @@ -89,7 +89,7 @@ pub const DynamicSection = struct { |
| 89 | if (elf_file.verneed_section_index != null) nentries += 2; // VERNEED | 89 | if (elf_file.verneed_section_index != null) nentries += 2; // VERNEED |
| 90 | if (dt.getFlags(elf_file) != null) nentries += 1; // FLAGS | 90 | if (dt.getFlags(elf_file) != null) nentries += 1; // FLAGS |
| 91 | if (dt.getFlags1(elf_file) != null) nentries += 1; // FLAGS_1 | 91 | if (dt.getFlags1(elf_file) != null) nentries += 1; // FLAGS_1 |
| 92 | if (!elf_file.base.isDynLib()) nentries += 1; // DEBUG | 92 | if (!elf_file.isEffectivelyDynLib()) nentries += 1; // DEBUG |
| 93 | nentries += 1; // NULL | 93 | nentries += 1; // NULL |
| 94 | return nentries * @sizeOf(elf.Elf64_Dyn); | 94 | return nentries * @sizeOf(elf.Elf64_Dyn); |
| 95 | } | 95 | } |
| ... | @@ -216,7 +216,7 @@ pub const DynamicSection = struct { | ... | @@ -216,7 +216,7 @@ pub const DynamicSection = struct { |
| 216 | } | 216 | } |
| 217 | | 217 | |
| 218 | // DEBUG | 218 | // DEBUG |
| 219 | if (!elf_file.base.isDynLib()) try writer.writeStruct(elf.Elf64_Dyn{ .d_tag = elf.DT_DEBUG, .d_val = 0 }); | 219 | if (!elf_file.isEffectivelyDynLib()) try writer.writeStruct(elf.Elf64_Dyn{ .d_tag = elf.DT_DEBUG, .d_val = 0 }); |
| 220 | | 220 | |
| 221 | // NULL | 221 | // NULL |
| 222 | try writer.writeStruct(elf.Elf64_Dyn{ .d_tag = elf.DT_NULL, .d_val = 0 }); | 222 | try writer.writeStruct(elf.Elf64_Dyn{ .d_tag = elf.DT_NULL, .d_val = 0 }); |
| ... | @@ -256,7 +256,7 @@ pub const ZigGotSection = struct { | ... | @@ -256,7 +256,7 @@ pub const ZigGotSection = struct { |
| 256 | entry.* = sym_index; | 256 | entry.* = sym_index; |
| 257 | const symbol = elf_file.symbol(sym_index); | 257 | const symbol = elf_file.symbol(sym_index); |
| 258 | symbol.flags.has_zig_got = true; | 258 | symbol.flags.has_zig_got = true; |
| 259 | if (elf_file.base.isDynLib() or (elf_file.base.isExe() and comp.config.pie)) { | 259 | if (elf_file.isEffectivelyDynLib() or (elf_file.base.isExe() and comp.config.pie)) { |
| 260 | zig_got.flags.needs_rela = true; | 260 | zig_got.flags.needs_rela = true; |
| 261 | } | 261 | } |
| 262 | if (symbol.extra(elf_file)) |extra| { | 262 | if (symbol.extra(elf_file)) |extra| { |
| ... | @@ -495,7 +495,7 @@ pub const GotSection = struct { | ... | @@ -495,7 +495,7 @@ pub const GotSection = struct { |
| 495 | const symbol = elf_file.symbol(sym_index); | 495 | const symbol = elf_file.symbol(sym_index); |
| 496 | symbol.flags.has_got = true; | 496 | symbol.flags.has_got = true; |
| 497 | if (symbol.flags.import or symbol.isIFunc(elf_file) or | 497 | if (symbol.flags.import or symbol.isIFunc(elf_file) or |
| 498 | ((elf_file.base.isDynLib() or (elf_file.base.isExe() and comp.config.pie)) and !symbol.isAbs(elf_file))) | 498 | ((elf_file.isEffectivelyDynLib() or (elf_file.base.isExe() and comp.config.pie)) and !symbol.isAbs(elf_file))) |
| 499 | { | 499 | { |
| 500 | got.flags.needs_rela = true; | 500 | got.flags.needs_rela = true; |
| 501 | } | 501 | } |
| ... | @@ -528,7 +528,7 @@ pub const GotSection = struct { | ... | @@ -528,7 +528,7 @@ pub const GotSection = struct { |
| 528 | entry.symbol_index = sym_index; | 528 | entry.symbol_index = sym_index; |
| 529 | const symbol = elf_file.symbol(sym_index); | 529 | const symbol = elf_file.symbol(sym_index); |
| 530 | symbol.flags.has_tlsgd = true; | 530 | symbol.flags.has_tlsgd = true; |
| 531 | if (symbol.flags.import or elf_file.base.isDynLib()) got.flags.needs_rela = true; | 531 | if (symbol.flags.import or elf_file.isEffectivelyDynLib()) got.flags.needs_rela = true; |
| 532 | if (symbol.extra(elf_file)) |extra| { | 532 | if (symbol.extra(elf_file)) |extra| { |
| 533 | var new_extra = extra; | 533 | var new_extra = extra; |
| 534 | new_extra.tlsgd = index; | 534 | new_extra.tlsgd = index; |
| ... | @@ -545,7 +545,7 @@ pub const GotSection = struct { | ... | @@ -545,7 +545,7 @@ pub const GotSection = struct { |
| 545 | entry.symbol_index = sym_index; | 545 | entry.symbol_index = sym_index; |
| 546 | const symbol = elf_file.symbol(sym_index); | 546 | const symbol = elf_file.symbol(sym_index); |
| 547 | symbol.flags.has_gottp = true; | 547 | symbol.flags.has_gottp = true; |
| 548 | if (symbol.flags.import or elf_file.base.isDynLib()) got.flags.needs_rela = true; | 548 | if (symbol.flags.import or elf_file.isEffectivelyDynLib()) got.flags.needs_rela = true; |
| 549 | if (symbol.extra(elf_file)) |extra| { | 549 | if (symbol.extra(elf_file)) |extra| { |
| 550 | var new_extra = extra; | 550 | var new_extra = extra; |
| 551 | new_extra.gottp = index; | 551 | new_extra.gottp = index; |
| ... | @@ -580,7 +580,7 @@ pub const GotSection = struct { | ... | @@ -580,7 +580,7 @@ pub const GotSection = struct { |
| 580 | | 580 | |
| 581 | pub fn write(got: GotSection, elf_file: *Elf, writer: anytype) !void { | 581 | pub fn write(got: GotSection, elf_file: *Elf, writer: anytype) !void { |
| 582 | const comp = elf_file.base.comp; | 582 | const comp = elf_file.base.comp; |
| 583 | const is_dyn_lib = elf_file.base.isDynLib(); | 583 | const is_dyn_lib = elf_file.isEffectivelyDynLib(); |
| 584 | const apply_relocs = true; // TODO add user option for this | 584 | const apply_relocs = true; // TODO add user option for this |
| 585 | | 585 | |
| 586 | for (got.entries.items) |entry| { | 586 | for (got.entries.items) |entry| { |
| ... | @@ -595,7 +595,7 @@ pub const GotSection = struct { | ... | @@ -595,7 +595,7 @@ pub const GotSection = struct { |
| 595 | if (symbol.?.flags.import) break :blk 0; | 595 | if (symbol.?.flags.import) break :blk 0; |
| 596 | if (symbol.?.isIFunc(elf_file)) | 596 | if (symbol.?.isIFunc(elf_file)) |
| 597 | break :blk if (apply_relocs) value else 0; | 597 | break :blk if (apply_relocs) value else 0; |
| 598 | if ((elf_file.base.isDynLib() or (elf_file.base.isExe() and comp.config.pie)) and | 598 | if ((elf_file.isEffectivelyDynLib() or (elf_file.base.isExe() and comp.config.pie)) and |
| 599 | !symbol.?.isAbs(elf_file)) | 599 | !symbol.?.isAbs(elf_file)) |
| 600 | { | 600 | { |
| 601 | break :blk if (apply_relocs) value else 0; | 601 | break :blk if (apply_relocs) value else 0; |
| ... | @@ -653,7 +653,7 @@ pub const GotSection = struct { | ... | @@ -653,7 +653,7 @@ pub const GotSection = struct { |
| 653 | pub fn addRela(got: GotSection, elf_file: *Elf) !void { | 653 | pub fn addRela(got: GotSection, elf_file: *Elf) !void { |
| 654 | const comp = elf_file.base.comp; | 654 | const comp = elf_file.base.comp; |
| 655 | const gpa = comp.gpa; | 655 | const gpa = comp.gpa; |
| 656 | const is_dyn_lib = elf_file.base.isDynLib(); | 656 | const is_dyn_lib = elf_file.isEffectivelyDynLib(); |
| 657 | const cpu_arch = elf_file.getTarget().cpu.arch; | 657 | const cpu_arch = elf_file.getTarget().cpu.arch; |
| 658 | try elf_file.rela_dyn.ensureUnusedCapacity(gpa, got.numRela(elf_file)); | 658 | try elf_file.rela_dyn.ensureUnusedCapacity(gpa, got.numRela(elf_file)); |
| 659 | | 659 | |
| ... | @@ -683,7 +683,7 @@ pub const GotSection = struct { | ... | @@ -683,7 +683,7 @@ pub const GotSection = struct { |
| 683 | }); | 683 | }); |
| 684 | continue; | 684 | continue; |
| 685 | } | 685 | } |
| 686 | if ((elf_file.base.isDynLib() or (elf_file.base.isExe() and comp.config.pie)) and | 686 | if ((elf_file.isEffectivelyDynLib() or (elf_file.base.isExe() and comp.config.pie)) and |
| 687 | !symbol.?.isAbs(elf_file)) | 687 | !symbol.?.isAbs(elf_file)) |
| 688 | { | 688 | { |
| 689 | elf_file.addRelaDynAssumeCapacity(.{ | 689 | elf_file.addRelaDynAssumeCapacity(.{ |
| ... | @@ -758,7 +758,7 @@ pub const GotSection = struct { | ... | @@ -758,7 +758,7 @@ pub const GotSection = struct { |
| 758 | | 758 | |
| 759 | pub fn numRela(got: GotSection, elf_file: *Elf) usize { | 759 | pub fn numRela(got: GotSection, elf_file: *Elf) usize { |
| 760 | const comp = elf_file.base.comp; | 760 | const comp = elf_file.base.comp; |
| 761 | const is_dyn_lib = elf_file.base.isDynLib(); | 761 | const is_dyn_lib = elf_file.isEffectivelyDynLib(); |
| 762 | var num: usize = 0; | 762 | var num: usize = 0; |
| 763 | for (got.entries.items) |entry| { | 763 | for (got.entries.items) |entry| { |
| 764 | const symbol = switch (entry.tag) { | 764 | const symbol = switch (entry.tag) { |
| ... | @@ -767,7 +767,7 @@ pub const GotSection = struct { | ... | @@ -767,7 +767,7 @@ pub const GotSection = struct { |
| 767 | }; | 767 | }; |
| 768 | switch (entry.tag) { | 768 | switch (entry.tag) { |
| 769 | .got => if (symbol.?.flags.import or symbol.?.isIFunc(elf_file) or | 769 | .got => if (symbol.?.flags.import or symbol.?.isIFunc(elf_file) or |
| 770 | ((elf_file.base.isDynLib() or (elf_file.base.isExe() and comp.config.pie)) and | 770 | ((elf_file.isEffectivelyDynLib() or (elf_file.base.isExe() and comp.config.pie)) and |
| 771 | !symbol.?.isAbs(elf_file))) | 771 | !symbol.?.isAbs(elf_file))) |
| 772 | { | 772 | { |
| 773 | num += 1; | 773 | num += 1; |