| ... | @@ -1622,6 +1622,22 @@ const aarch64 = struct { | ... | @@ -1622,6 +1622,22 @@ const aarch64 = struct { |
| 1622 | } | 1622 | } |
| 1623 | }, | 1623 | }, |
| 1624 | | 1624 | |
| | 1625 | .TLSLE_ADD_TPREL_HI12, |
| | 1626 | .TLSLE_ADD_TPREL_LO12_NC, |
| | 1627 | => { |
| | 1628 | if (is_dyn_lib) try atom.reportPicError(symbol, rel, elf_file); |
| | 1629 | }, |
| | 1630 | |
| | 1631 | .TLSDESC_ADR_PAGE21, |
| | 1632 | .TLSDESC_LD64_LO12, |
| | 1633 | .TLSDESC_ADD_LO12, |
| | 1634 | => { |
| | 1635 | const should_relax = elf_file.base.isStatic() or (!is_dyn_lib and !symbol.flags.import); |
| | 1636 | if (!should_relax and true) { // TODO |
| | 1637 | symbol.flags.needs_tlsdesc = true; |
| | 1638 | } |
| | 1639 | }, |
| | 1640 | |
| 1625 | .ADD_ABS_LO12_NC, | 1641 | .ADD_ABS_LO12_NC, |
| 1626 | .ADR_PREL_LO21, | 1642 | .ADR_PREL_LO21, |
| 1627 | .LDST8_ABS_LO12_NC, | 1643 | .LDST8_ABS_LO12_NC, |
| ... | @@ -1629,14 +1645,9 @@ const aarch64 = struct { | ... | @@ -1629,14 +1645,9 @@ const aarch64 = struct { |
| 1629 | .LDST32_ABS_LO12_NC, | 1645 | .LDST32_ABS_LO12_NC, |
| 1630 | .LDST64_ABS_LO12_NC, | 1646 | .LDST64_ABS_LO12_NC, |
| 1631 | .LDST128_ABS_LO12_NC, | 1647 | .LDST128_ABS_LO12_NC, |
| | 1648 | .TLSDESC_CALL, |
| 1632 | => {}, | 1649 | => {}, |
| 1633 | | 1650 | |
| 1634 | .TLSLE_ADD_TPREL_HI12, | | |
| 1635 | .TLSLE_ADD_TPREL_LO12_NC, | | |
| 1636 | => { | | |
| 1637 | if (is_dyn_lib) try atom.reportPicError(symbol, rel, elf_file); | | |
| 1638 | }, | | |
| 1639 | | | |
| 1640 | else => try atom.reportUnhandledRelocError(rel, elf_file), | 1651 | else => try atom.reportUnhandledRelocError(rel, elf_file), |
| 1641 | } | 1652 | } |
| 1642 | } | 1653 | } |
| ... | @@ -1757,6 +1768,36 @@ const aarch64 = struct { | ... | @@ -1757,6 +1768,36 @@ const aarch64 = struct { |
| 1757 | aarch64_util.writeAddImmInst(@bitCast(value), code[rel.r_offset..][0..4]); | 1768 | aarch64_util.writeAddImmInst(@bitCast(value), code[rel.r_offset..][0..4]); |
| 1758 | }, | 1769 | }, |
| 1759 | | 1770 | |
| | 1771 | .TLSDESC_ADR_PAGE21 => { |
| | 1772 | assert(target.flags.has_tlsdesc); // TODO relax |
| | 1773 | const S_: i64 = @intCast(target.tlsDescAddress(elf_file)); |
| | 1774 | const saddr: u64 = @intCast(P); |
| | 1775 | const taddr: u64 = @intCast(S_ + A); |
| | 1776 | relocs_log.debug(" [{x} => {x}]", .{ P, taddr }); |
| | 1777 | const pages: u21 = @bitCast(try aarch64_util.calcNumberOfPages(saddr, taddr)); |
| | 1778 | aarch64_util.writeAdrpInst(pages, code[rel.r_offset..][0..4]); |
| | 1779 | }, |
| | 1780 | |
| | 1781 | .TLSDESC_LD64_LO12 => { |
| | 1782 | const S_: i64 = @intCast(target.tlsDescAddress(elf_file)); |
| | 1783 | const taddr: u64 = @intCast(S_ + A); |
| | 1784 | relocs_log.debug(" [{x} => {x}]", .{ P, taddr }); |
| | 1785 | const offset: u12 = try math.divExact(u12, @truncate(taddr), 8); |
| | 1786 | aarch64_util.writeLoadStoreRegInst(offset, code[rel.r_offset..][0..4]); |
| | 1787 | }, |
| | 1788 | |
| | 1789 | .TLSDESC_ADD_LO12 => { |
| | 1790 | const S_: i64 = @intCast(target.tlsDescAddress(elf_file)); |
| | 1791 | const taddr: u64 = @intCast(S_ + A); |
| | 1792 | relocs_log.debug(" [{x} => {x}]", .{ P, taddr }); |
| | 1793 | const offset: u12 = @truncate(taddr); |
| | 1794 | aarch64_util.writeAddImmInst(offset, code[rel.r_offset..][0..4]); |
| | 1795 | }, |
| | 1796 | |
| | 1797 | .TLSDESC_CALL => if (!target.flags.has_tlsdesc) { |
| | 1798 | mem.writeInt(u32, code[rel.r_offset..][0..4], aarch64_util.Instruction.nop().toU32(), .little); |
| | 1799 | }, |
| | 1800 | |
| 1760 | else => try atom.reportUnhandledRelocError(rel, elf_file), | 1801 | else => try atom.reportUnhandledRelocError(rel, elf_file), |
| 1761 | } | 1802 | } |
| 1762 | } | 1803 | } |