| ... | ... | @@ -634,8 +634,17 @@ pub const GotSection = struct { |
| 634 | 634 | } |
| 635 | 635 | }, |
| 636 | 636 | .tlsdesc => { |
| 637 | | try writeInt(0, elf_file, writer); |
| 638 | | try writeInt(0, elf_file, writer); |
| 637 | if (symbol.?.flags.import) { |
| 638 | try writeInt(0, elf_file, writer); |
| 639 | try writeInt(0, elf_file, writer); |
| 640 | } else { |
| 641 | try writeInt(0, elf_file, writer); |
| 642 | const offset = if (apply_relocs) |
| 643 | @as(i64, @intCast(symbol.?.address(.{}, elf_file))) - @as(i64, @intCast(elf_file.tlsAddress())) |
| 644 | else |
| 645 | 0; |
| 646 | try writeInt(offset, elf_file, writer); |
| 647 | } |
| 639 | 648 | }, |
| 640 | 649 | } |
| 641 | 650 | } |
| ... | ... | @@ -738,8 +747,9 @@ pub const GotSection = struct { |
| 738 | 747 | const offset = symbol.?.tlsDescAddress(elf_file); |
| 739 | 748 | elf_file.addRelaDynAssumeCapacity(.{ |
| 740 | 749 | .offset = offset, |
| 741 | | .sym = extra.?.dynamic, |
| 750 | .sym = if (symbol.?.flags.import) extra.?.dynamic else 0, |
| 742 | 751 | .type = relocation.encode(.tlsdesc, cpu_arch), |
| 752 | .addend = if (symbol.?.flags.import) 0 else @intCast(symbol.?.address(.{}, elf_file) - elf_file.tlsAddress()), |
| 743 | 753 | }); |
| 744 | 754 | }, |
| 745 | 755 | } |