authorgravatar for kubkon@jakubkonka.comJakub Konka <kubkon@jakubkonka.com> 2024-03-08 14:43:23+01:00
committergravatar for kubkon@jakubkonka.comJakub Konka <kubkon@jakubkonka.com> 2024-03-08 22:46:18+01:00
logb34310356725fb1b955b6bec11da235efdc96bab
treed585dd804ebf9dbc740c2cb9c4e19dfc4f36b041
parent7258d143e355f6bd92797cdb193c2b1ad2a1650d

elf+aarch64: handle gottp and .tls_common


1 files changed, 23 insertions(+), 0 deletions(-)

src/link/Elf/Atom.zig+23
......@@ -1628,6 +1628,12 @@ const aarch64 = struct {
16281628 if (is_dyn_lib) try atom.reportPicError(symbol, rel, elf_file);
16291629 },
16301630
1631 .TLSIE_ADR_GOTTPREL_PAGE21,
1632 .TLSIE_LD64_GOTTPREL_LO12_NC,
1633 => {
1634 symbol.flags.needs_gottp = true;
1635 },
1636
16311637 .TLSDESC_ADR_PAGE21,
16321638 .TLSDESC_LD64_LO12,
16331639 .TLSDESC_ADD_LO12,
......@@ -1769,6 +1775,23 @@ const aarch64 = struct {
17691775 aarch64_util.writeAddImmInst(@bitCast(value), code);
17701776 },
17711777
1778 .TLSIE_ADR_GOTTPREL_PAGE21 => {
1779 const S_: i64 = @intCast(target.gotTpAddress(elf_file));
1780 const saddr: u64 = @intCast(P);
1781 const taddr: u64 = @intCast(S_ + A);
1782 relocs_log.debug(" [{x} => {x}]", .{ P, taddr });
1783 const pages: u21 = @bitCast(try aarch64_util.calcNumberOfPages(saddr, taddr));
1784 aarch64_util.writeAdrpInst(pages, code);
1785 },
1786
1787 .TLSIE_LD64_GOTTPREL_LO12_NC => {
1788 const S_: i64 = @intCast(target.gotTpAddress(elf_file));
1789 const taddr: u64 = @intCast(S_ + A);
1790 relocs_log.debug(" [{x} => {x}]", .{ P, taddr });
1791 const offset: u12 = try math.divExact(u12, @truncate(taddr), 8);
1792 aarch64_util.writeLoadStoreRegInst(offset, code);
1793 },
1794
17721795 .TLSDESC_ADR_PAGE21 => {
17731796 if (target.flags.has_tlsdesc) {
17741797 const S_: i64 = @intCast(target.tlsDescAddress(elf_file));