| author | |
| committer | |
| log | 79e99c401ca32031d29aff77e43758ca0b67d5d9 |
| tree | f3edc8133467b6be6d7114a6fb0bec4105505c83 |
| parent | dd4d320eb9663c7a0ef8dbe3aca220a64795d683 |
| parent | d1429a8fa98f85c9fb8d2bd99b7c31eb9de38b38 |
| signature |
lib/std/elf: refactor relocation types + add RISCV relocs6 files changed, 624 insertions(+), 679 deletions(-)
lib/std/elf.zig+422-355| ... | @@ -1806,363 +1806,430 @@ pub const COMPRESS = enum(u32) { | ... | @@ -1806,363 +1806,430 @@ pub const COMPRESS = enum(u32) { |
| 1806 | }; | 1806 | }; |
| 1807 | 1807 | ||
| 1808 | /// AMD x86-64 relocations. | 1808 | /// AMD x86-64 relocations. |
| 1809 | /// No reloc | 1809 | pub const R_X86_64 = enum(u32) { |
| 1810 | pub const R_X86_64_NONE = 0; | 1810 | /// No reloc |
| 1811 | /// Direct 64 bit | 1811 | NONE = 0, |
| 1812 | pub const R_X86_64_64 = 1; | 1812 | /// Direct 64 bit |
| 1813 | /// PC relative 32 bit signed | 1813 | @"64" = 1, |
| 1814 | pub const R_X86_64_PC32 = 2; | 1814 | /// PC relative 32 bit signed |
| 1815 | /// 32 bit GOT entry | 1815 | PC32 = 2, |
| 1816 | pub const R_X86_64_GOT32 = 3; | 1816 | /// 32 bit GOT entry |
| 1817 | /// 32 bit PLT address | 1817 | GOT32 = 3, |
| 1818 | pub const R_X86_64_PLT32 = 4; | 1818 | /// 32 bit PLT address |
| 1819 | /// Copy symbol at runtime | 1819 | PLT32 = 4, |
| 1820 | pub const R_X86_64_COPY = 5; | 1820 | /// Copy symbol at runtime |
| 1821 | /// Create GOT entry | 1821 | COPY = 5, |
| 1822 | pub const R_X86_64_GLOB_DAT = 6; | 1822 | /// Create GOT entry |
| 1823 | /// Create PLT entry | 1823 | GLOB_DAT = 6, |
| 1824 | pub const R_X86_64_JUMP_SLOT = 7; | 1824 | /// Create PLT entry |
| 1825 | /// Adjust by program base | 1825 | JUMP_SLOT = 7, |
| 1826 | pub const R_X86_64_RELATIVE = 8; | 1826 | /// Adjust by program base |
| 1827 | /// 32 bit signed PC relative offset to GOT | 1827 | RELATIVE = 8, |
| 1828 | pub const R_X86_64_GOTPCREL = 9; | 1828 | /// 32 bit signed PC relative offset to GOT |
| 1829 | /// Direct 32 bit zero extended | 1829 | GOTPCREL = 9, |
| 1830 | pub const R_X86_64_32 = 10; | 1830 | /// Direct 32 bit zero extended |
| 1831 | /// Direct 32 bit sign extended | 1831 | @"32" = 10, |
| 1832 | pub const R_X86_64_32S = 11; | 1832 | /// Direct 32 bit sign extended |
| 1833 | /// Direct 16 bit zero extended | 1833 | @"32S" = 11, |
| 1834 | pub const R_X86_64_16 = 12; | 1834 | /// Direct 16 bit zero extended |
| 1835 | /// 16 bit sign extended pc relative | 1835 | @"16" = 12, |
| 1836 | pub const R_X86_64_PC16 = 13; | 1836 | /// 16 bit sign extended pc relative |
| 1837 | /// Direct 8 bit sign extended | 1837 | PC16 = 13, |
| 1838 | pub const R_X86_64_8 = 14; | 1838 | /// Direct 8 bit sign extended |
| 1839 | /// 8 bit sign extended pc relative | 1839 | @"8" = 14, |
| 1840 | pub const R_X86_64_PC8 = 15; | 1840 | /// 8 bit sign extended pc relative |
| 1841 | /// ID of module containing symbol | 1841 | PC8 = 15, |
| 1842 | pub const R_X86_64_DTPMOD64 = 16; | 1842 | /// ID of module containing symbol |
| 1843 | /// Offset in module's TLS block | 1843 | DTPMOD64 = 16, |
| 1844 | pub const R_X86_64_DTPOFF64 = 17; | 1844 | /// Offset in module's TLS block |
| 1845 | /// Offset in initial TLS block | 1845 | DTPOFF64 = 17, |
| 1846 | pub const R_X86_64_TPOFF64 = 18; | 1846 | /// Offset in initial TLS block |
| 1847 | /// 32 bit signed PC relative offset to two GOT entries for GD symbol | 1847 | TPOFF64 = 18, |
| 1848 | pub const R_X86_64_TLSGD = 19; | 1848 | /// 32 bit signed PC relative offset to two GOT entries for GD symbol |
| 1849 | /// 32 bit signed PC relative offset to two GOT entries for LD symbol | 1849 | TLSGD = 19, |
| 1850 | pub const R_X86_64_TLSLD = 20; | 1850 | /// 32 bit signed PC relative offset to two GOT entries for LD symbol |
| 1851 | /// Offset in TLS block | 1851 | TLSLD = 20, |
| 1852 | pub const R_X86_64_DTPOFF32 = 21; | 1852 | /// Offset in TLS block |
| 1853 | /// 32 bit signed PC relative offset to GOT entry for IE symbol | 1853 | DTPOFF32 = 21, |
| 1854 | pub const R_X86_64_GOTTPOFF = 22; | 1854 | /// 32 bit signed PC relative offset to GOT entry for IE symbol |
| 1855 | /// Offset in initial TLS block | 1855 | GOTTPOFF = 22, |
| 1856 | pub const R_X86_64_TPOFF32 = 23; | 1856 | /// Offset in initial TLS block |
| 1857 | /// PC relative 64 bit | 1857 | TPOFF32 = 23, |
| 1858 | pub const R_X86_64_PC64 = 24; | 1858 | /// PC relative 64 bit |
| 1859 | /// 64 bit offset to GOT | 1859 | PC64 = 24, |
| 1860 | pub const R_X86_64_GOTOFF64 = 25; | 1860 | /// 64 bit offset to GOT |
| 1861 | /// 32 bit signed pc relative offset to GOT | 1861 | GOTOFF64 = 25, |
| 1862 | pub const R_X86_64_GOTPC32 = 26; | 1862 | /// 32 bit signed pc relative offset to GOT |
| 1863 | /// 64 bit GOT entry offset | 1863 | GOTPC32 = 26, |
| 1864 | pub const R_X86_64_GOT64 = 27; | 1864 | /// 64 bit GOT entry offset |
| 1865 | /// 64 bit PC relative offset to GOT entry | 1865 | GOT64 = 27, |
| 1866 | pub const R_X86_64_GOTPCREL64 = 28; | 1866 | /// 64 bit PC relative offset to GOT entry |
| 1867 | /// 64 bit PC relative offset to GOT | 1867 | GOTPCREL64 = 28, |
| 1868 | pub const R_X86_64_GOTPC64 = 29; | 1868 | /// 64 bit PC relative offset to GOT |
| 1869 | /// Like GOT64, says PLT entry needed | 1869 | GOTPC64 = 29, |
| 1870 | pub const R_X86_64_GOTPLT64 = 30; | 1870 | /// Like GOT64, says PLT entry needed |
| 1871 | /// 64-bit GOT relative offset to PLT entry | 1871 | GOTPLT64 = 30, |
| 1872 | pub const R_X86_64_PLTOFF64 = 31; | 1872 | /// 64-bit GOT relative offset to PLT entry |
| 1873 | /// Size of symbol plus 32-bit addend | 1873 | PLTOFF64 = 31, |
| 1874 | pub const R_X86_64_SIZE32 = 32; | 1874 | /// Size of symbol plus 32-bit addend |
| 1875 | /// Size of symbol plus 64-bit addend | 1875 | SIZE32 = 32, |
| 1876 | pub const R_X86_64_SIZE64 = 33; | 1876 | /// Size of symbol plus 64-bit addend |
| 1877 | /// GOT offset for TLS descriptor | 1877 | SIZE64 = 33, |
| 1878 | pub const R_X86_64_GOTPC32_TLSDESC = 34; | 1878 | /// GOT offset for TLS descriptor |
| 1879 | /// Marker for call through TLS descriptor | 1879 | GOTPC32_TLSDESC = 34, |
| 1880 | pub const R_X86_64_TLSDESC_CALL = 35; | 1880 | /// Marker for call through TLS descriptor |
| 1881 | /// TLS descriptor | 1881 | TLSDESC_CALL = 35, |
| 1882 | pub const R_X86_64_TLSDESC = 36; | 1882 | /// TLS descriptor |
| 1883 | /// Adjust indirectly by program base | 1883 | TLSDESC = 36, |
| 1884 | pub const R_X86_64_IRELATIVE = 37; | 1884 | /// Adjust indirectly by program base |
| 1885 | /// 64-bit adjust by program base | 1885 | IRELATIVE = 37, |
| 1886 | pub const R_X86_64_RELATIVE64 = 38; | 1886 | /// 64-bit adjust by program base |
| 1887 | /// 39 Reserved was R_X86_64_PC32_BND | 1887 | RELATIVE64 = 38, |
| 1888 | /// 40 Reserved was R_X86_64_PLT32_BND | 1888 | /// 39 Reserved was PC32_BND |
| 1889 | /// Load from 32 bit signed pc relative offset to GOT entry without REX prefix, relaxable | 1889 | /// 40 Reserved was PLT32_BND |
| 1890 | pub const R_X86_64_GOTPCRELX = 41; | 1890 | /// Load from 32 bit signed pc relative offset to GOT entry without REX prefix, relaxable |
| 1891 | /// Load from 32 bit signed PC relative offset to GOT entry with REX prefix, relaxable | 1891 | GOTPCRELX = 41, |
| 1892 | pub const R_X86_64_REX_GOTPCRELX = 42; | 1892 | /// Load from 32 bit signed PC relative offset to GOT entry with REX prefix, relaxable |
| 1893 | pub const R_X86_64_NUM = 43; | 1893 | REX_GOTPCRELX = 42, |
| 1894 | _, | ||
| 1895 | }; | ||
| 1894 | 1896 | ||
| 1895 | /// AArch64 relocs. | 1897 | /// AArch64 relocs. |
| 1896 | /// No relocation. | 1898 | pub const R_AARCH64 = enum(u32) { |
| 1897 | pub const R_AARCH64_NONE = 0; | 1899 | /// No relocation. |
| 1898 | 1900 | NONE = 0, | |
| 1899 | /// ILP32 AArch64 relocs. | 1901 | /// ILP32 AArch64 relocs. |
| 1900 | /// Direct 32 bit. | 1902 | /// Direct 32 bit. |
| 1901 | pub const R_AARCH64_P32_ABS32 = 1; | 1903 | P32_ABS32 = 1, |
| 1902 | /// Copy symbol at runtime. | 1904 | /// Copy symbol at runtime. |
| 1903 | pub const R_AARCH64_P32_COPY = 180; | 1905 | P32_COPY = 180, |
| 1904 | /// Create GOT entry. | 1906 | /// Create GOT entry. |
| 1905 | pub const R_AARCH64_P32_GLOB_DAT = 181; | 1907 | P32_GLOB_DAT = 181, |
| 1906 | /// Create PLT entry. | 1908 | /// Create PLT entry. |
| 1907 | pub const R_AARCH64_P32_JUMP_SLOT = 182; | 1909 | P32_JUMP_SLOT = 182, |
| 1908 | /// Adjust by program base. | 1910 | /// Adjust by program base. |
| 1909 | pub const R_AARCH64_P32_RELATIVE = 183; | 1911 | P32_RELATIVE = 183, |
| 1910 | /// Module number, 32 bit. | 1912 | /// Module number, 32 bit. |
| 1911 | pub const R_AARCH64_P32_TLS_DTPMOD = 184; | 1913 | P32_TLS_DTPMOD = 184, |
| 1912 | /// Module-relative offset, 32 bit. | 1914 | /// Module-relative offset, 32 bit. |
| 1913 | pub const R_AARCH64_P32_TLS_DTPREL = 185; | 1915 | P32_TLS_DTPREL = 185, |
| 1914 | /// TP-relative offset, 32 bit. | 1916 | /// TP-relative offset, 32 bit. |
| 1915 | pub const R_AARCH64_P32_TLS_TPREL = 186; | 1917 | P32_TLS_TPREL = 186, |
| 1916 | /// TLS Descriptor. | 1918 | /// TLS Descriptor. |
| 1917 | pub const R_AARCH64_P32_TLSDESC = 187; | 1919 | P32_TLSDESC = 187, |
| 1918 | /// STT_GNU_IFUNC relocation. | 1920 | /// STT_GNU_IFUNC relocation. |
| 1919 | pub const R_AARCH64_P32_IRELATIVE = 188; | 1921 | P32_IRELATIVE = 188, |
| 1920 | 1922 | /// LP64 AArch64 relocs. | |
| 1921 | /// LP64 AArch64 relocs. | 1923 | /// Direct 64 bit. |
| 1922 | /// Direct 64 bit. | 1924 | ABS64 = 257, |
| 1923 | pub const R_AARCH64_ABS64 = 257; | 1925 | /// Direct 32 bit. |
| 1924 | /// Direct 32 bit. | 1926 | ABS32 = 258, |
| 1925 | pub const R_AARCH64_ABS32 = 258; | 1927 | /// Direct 16-bit. |
| 1926 | /// Direct 16-bit. | 1928 | ABS16 = 259, |
| 1927 | pub const R_AARCH64_ABS16 = 259; | 1929 | /// PC-relative 64-bit. |
| 1928 | /// PC-relative 64-bit. | 1930 | PREL64 = 260, |
| 1929 | pub const R_AARCH64_PREL64 = 260; | 1931 | /// PC-relative 32-bit. |
| 1930 | /// PC-relative 32-bit. | 1932 | PREL32 = 261, |
| 1931 | pub const R_AARCH64_PREL32 = 261; | 1933 | /// PC-relative 16-bit. |
| 1932 | /// PC-relative 16-bit. | 1934 | PREL16 = 262, |
| 1933 | pub const R_AARCH64_PREL16 = 262; | 1935 | /// Dir. MOVZ imm. from bits 15:0. |
| 1934 | /// Dir. MOVZ imm. from bits 15:0. | 1936 | MOVW_UABS_G0 = 263, |
| 1935 | pub const R_AARCH64_MOVW_UABS_G0 = 263; | 1937 | /// Likewise for MOVK; no check. |
| 1936 | /// Likewise for MOVK; no check. | 1938 | MOVW_UABS_G0_NC = 264, |
| 1937 | pub const R_AARCH64_MOVW_UABS_G0_NC = 264; | 1939 | /// Dir. MOVZ imm. from bits 31:16. |
| 1938 | /// Dir. MOVZ imm. from bits 31:16. | 1940 | MOVW_UABS_G1 = 265, |
| 1939 | pub const R_AARCH64_MOVW_UABS_G1 = 265; | 1941 | /// Likewise for MOVK; no check. |
| 1940 | /// Likewise for MOVK; no check. | 1942 | MOVW_UABS_G1_NC = 266, |
| 1941 | pub const R_AARCH64_MOVW_UABS_G1_NC = 266; | 1943 | /// Dir. MOVZ imm. from bits 47:32. |
| 1942 | /// Dir. MOVZ imm. from bits 47:32. | 1944 | MOVW_UABS_G2 = 267, |
| 1943 | pub const R_AARCH64_MOVW_UABS_G2 = 267; | 1945 | /// Likewise for MOVK; no check. |
| 1944 | /// Likewise for MOVK; no check. | 1946 | MOVW_UABS_G2_NC = 268, |
| 1945 | pub const R_AARCH64_MOVW_UABS_G2_NC = 268; | 1947 | /// Dir. MOV{K,Z} imm. from 63:48. |
| 1946 | /// Dir. MOV{K,Z} imm. from 63:48. | 1948 | MOVW_UABS_G3 = 269, |
| 1947 | pub const R_AARCH64_MOVW_UABS_G3 = 269; | 1949 | /// Dir. MOV{N,Z} imm. from 15:0. |
| 1948 | /// Dir. MOV{N,Z} imm. from 15:0. | 1950 | MOVW_SABS_G0 = 270, |
| 1949 | pub const R_AARCH64_MOVW_SABS_G0 = 270; | 1951 | /// Dir. MOV{N,Z} imm. from 31:16. |
| 1950 | /// Dir. MOV{N,Z} imm. from 31:16. | 1952 | MOVW_SABS_G1 = 271, |
| 1951 | pub const R_AARCH64_MOVW_SABS_G1 = 271; | 1953 | /// Dir. MOV{N,Z} imm. from 47:32. |
| 1952 | /// Dir. MOV{N,Z} imm. from 47:32. | 1954 | MOVW_SABS_G2 = 272, |
| 1953 | pub const R_AARCH64_MOVW_SABS_G2 = 272; | 1955 | /// PC-rel. LD imm. from bits 20:2. |
| 1954 | /// PC-rel. LD imm. from bits 20:2. | 1956 | LD_PREL_LO19 = 273, |
| 1955 | pub const R_AARCH64_LD_PREL_LO19 = 273; | 1957 | /// PC-rel. ADR imm. from bits 20:0. |
| 1956 | /// PC-rel. ADR imm. from bits 20:0. | 1958 | ADR_PREL_LO21 = 274, |
| 1957 | pub const R_AARCH64_ADR_PREL_LO21 = 274; | 1959 | /// Page-rel. ADRP imm. from 32:12. |
| 1958 | /// Page-rel. ADRP imm. from 32:12. | 1960 | ADR_PREL_PG_HI21 = 275, |
| 1959 | pub const R_AARCH64_ADR_PREL_PG_HI21 = 275; | 1961 | /// Likewise; no overflow check. |
| 1960 | /// Likewise; no overflow check. | 1962 | ADR_PREL_PG_HI21_NC = 276, |
| 1961 | pub const R_AARCH64_ADR_PREL_PG_HI21_NC = 276; | 1963 | /// Dir. ADD imm. from bits 11:0. |
| 1962 | /// Dir. ADD imm. from bits 11:0. | 1964 | ADD_ABS_LO12_NC = 277, |
| 1963 | pub const R_AARCH64_ADD_ABS_LO12_NC = 277; | 1965 | /// Likewise for LD/ST; no check. |
| 1964 | /// Likewise for LD/ST; no check. | 1966 | LDST8_ABS_LO12_NC = 278, |
| 1965 | pub const R_AARCH64_LDST8_ABS_LO12_NC = 278; | 1967 | /// PC-rel. TBZ/TBNZ imm. from 15:2. |
| 1966 | /// PC-rel. TBZ/TBNZ imm. from 15:2. | 1968 | TSTBR14 = 279, |
| 1967 | pub const R_AARCH64_TSTBR14 = 279; | 1969 | /// PC-rel. cond. br. imm. from 20:2. |
| 1968 | /// PC-rel. cond. br. imm. from 20:2. | 1970 | CONDBR19 = 280, |
| 1969 | pub const R_AARCH64_CONDBR19 = 280; | 1971 | /// PC-rel. B imm. from bits 27:2. |
| 1970 | /// PC-rel. B imm. from bits 27:2. | 1972 | JUMP26 = 282, |
| 1971 | pub const R_AARCH64_JUMP26 = 282; | 1973 | /// Likewise for CALL. |
| 1972 | /// Likewise for CALL. | 1974 | CALL26 = 283, |
| 1973 | pub const R_AARCH64_CALL26 = 283; | 1975 | /// Dir. ADD imm. from bits 11:1. |
| 1974 | /// Dir. ADD imm. from bits 11:1. | 1976 | LDST16_ABS_LO12_NC = 284, |
| 1975 | pub const R_AARCH64_LDST16_ABS_LO12_NC = 284; | 1977 | /// Likewise for bits 11:2. |
| 1976 | /// Likewise for bits 11:2. | 1978 | LDST32_ABS_LO12_NC = 285, |
| 1977 | pub const R_AARCH64_LDST32_ABS_LO12_NC = 285; | 1979 | /// Likewise for bits 11:3. |
| 1978 | /// Likewise for bits 11:3. | 1980 | LDST64_ABS_LO12_NC = 286, |
| 1979 | pub const R_AARCH64_LDST64_ABS_LO12_NC = 286; | 1981 | /// PC-rel. MOV{N,Z} imm. from 15:0. |
| 1980 | /// PC-rel. MOV{N,Z} imm. from 15:0. | 1982 | MOVW_PREL_G0 = 287, |
| 1981 | pub const R_AARCH64_MOVW_PREL_G0 = 287; | 1983 | /// Likewise for MOVK; no check. |
| 1982 | /// Likewise for MOVK; no check. | 1984 | MOVW_PREL_G0_NC = 288, |
| 1983 | pub const R_AARCH64_MOVW_PREL_G0_NC = 288; | 1985 | /// PC-rel. MOV{N,Z} imm. from 31:16. |
| 1984 | /// PC-rel. MOV{N,Z} imm. from 31:16. | 1986 | MOVW_PREL_G1 = 289, |
| 1985 | pub const R_AARCH64_MOVW_PREL_G1 = 289; | 1987 | /// Likewise for MOVK; no check. |
| 1986 | /// Likewise for MOVK; no check. | 1988 | MOVW_PREL_G1_NC = 290, |
| 1987 | pub const R_AARCH64_MOVW_PREL_G1_NC = 290; | 1989 | /// PC-rel. MOV{N,Z} imm. from 47:32. |
| 1988 | /// PC-rel. MOV{N,Z} imm. from 47:32. | 1990 | MOVW_PREL_G2 = 291, |
| 1989 | pub const R_AARCH64_MOVW_PREL_G2 = 291; | 1991 | /// Likewise for MOVK; no check. |
| 1990 | /// Likewise for MOVK; no check. | 1992 | MOVW_PREL_G2_NC = 292, |
| 1991 | pub const R_AARCH64_MOVW_PREL_G2_NC = 292; | 1993 | /// PC-rel. MOV{N,Z} imm. from 63:48. |
| 1992 | /// PC-rel. MOV{N,Z} imm. from 63:48. | 1994 | MOVW_PREL_G3 = 293, |
| 1993 | pub const R_AARCH64_MOVW_PREL_G3 = 293; | 1995 | /// Dir. ADD imm. from bits 11:4. |
| 1994 | /// Dir. ADD imm. from bits 11:4. | 1996 | LDST128_ABS_LO12_NC = 299, |
| 1995 | pub const R_AARCH64_LDST128_ABS_LO12_NC = 299; | 1997 | /// GOT-rel. off. MOV{N,Z} imm. 15:0. |
| 1996 | /// GOT-rel. off. MOV{N,Z} imm. 15:0. | 1998 | MOVW_GOTOFF_G0 = 300, |
| 1997 | pub const R_AARCH64_MOVW_GOTOFF_G0 = 300; | 1999 | /// Likewise for MOVK; no check. |
| 1998 | /// Likewise for MOVK; no check. | 2000 | MOVW_GOTOFF_G0_NC = 301, |
| 1999 | pub const R_AARCH64_MOVW_GOTOFF_G0_NC = 301; | 2001 | /// GOT-rel. o. MOV{N,Z} imm. 31:16. |
| 2000 | /// GOT-rel. o. MOV{N,Z} imm. 31:16. | 2002 | MOVW_GOTOFF_G1 = 302, |
| 2001 | pub const R_AARCH64_MOVW_GOTOFF_G1 = 302; | 2003 | /// Likewise for MOVK; no check. |
| 2002 | /// Likewise for MOVK; no check. | 2004 | MOVW_GOTOFF_G1_NC = 303, |
| 2003 | pub const R_AARCH64_MOVW_GOTOFF_G1_NC = 303; | 2005 | /// GOT-rel. o. MOV{N,Z} imm. 47:32. |
| 2004 | /// GOT-rel. o. MOV{N,Z} imm. 47:32. | 2006 | MOVW_GOTOFF_G2 = 304, |
| 2005 | pub const R_AARCH64_MOVW_GOTOFF_G2 = 304; | 2007 | /// Likewise for MOVK; no check. |
| 2006 | /// Likewise for MOVK; no check. | 2008 | MOVW_GOTOFF_G2_NC = 305, |
| 2007 | pub const R_AARCH64_MOVW_GOTOFF_G2_NC = 305; | 2009 | /// GOT-rel. o. MOV{N,Z} imm. 63:48. |
| 2008 | /// GOT-rel. o. MOV{N,Z} imm. 63:48. | 2010 | MOVW_GOTOFF_G3 = 306, |
| 2009 | pub const R_AARCH64_MOVW_GOTOFF_G3 = 306; | 2011 | /// GOT-relative 64-bit. |
| 2010 | /// GOT-relative 64-bit. | 2012 | GOTREL64 = 307, |
| 2011 | pub const R_AARCH64_GOTREL64 = 307; | 2013 | /// GOT-relative 32-bit. |
| 2012 | /// GOT-relative 32-bit. | 2014 | GOTREL32 = 308, |
| 2013 | pub const R_AARCH64_GOTREL32 = 308; | 2015 | /// PC-rel. GOT off. load imm. 20:2. |
| 2014 | /// PC-rel. GOT off. load imm. 20:2. | 2016 | GOT_LD_PREL19 = 309, |
| 2015 | pub const R_AARCH64_GOT_LD_PREL19 = 309; | 2017 | /// GOT-rel. off. LD/ST imm. 14:3. |
| 2016 | /// GOT-rel. off. LD/ST imm. 14:3. | 2018 | LD64_GOTOFF_LO15 = 310, |
| 2017 | pub const R_AARCH64_LD64_GOTOFF_LO15 = 310; | 2019 | /// P-page-rel. GOT off. ADRP 32:12. |
| 2018 | /// P-page-rel. GOT off. ADRP 32:12. | 2020 | ADR_GOT_PAGE = 311, |
| 2019 | pub const R_AARCH64_ADR_GOT_PAGE = 311; | 2021 | /// Dir. GOT off. LD/ST imm. 11:3. |
| 2020 | /// Dir. GOT off. LD/ST imm. 11:3. | 2022 | LD64_GOT_LO12_NC = 312, |
| 2021 | pub const R_AARCH64_LD64_GOT_LO12_NC = 312; | 2023 | /// GOT-page-rel. GOT off. LD/ST 14:3 |
| 2022 | /// GOT-page-rel. GOT off. LD/ST 14:3 | 2024 | LD64_GOTPAGE_LO15 = 313, |
| 2023 | pub const R_AARCH64_LD64_GOTPAGE_LO15 = 313; | 2025 | /// PC-relative ADR imm. 20:0. |
| 2024 | /// PC-relative ADR imm. 20:0. | 2026 | TLSGD_ADR_PREL21 = 512, |
| 2025 | pub const R_AARCH64_TLSGD_ADR_PREL21 = 512; | 2027 | /// page-rel. ADRP imm. 32:12. |
| 2026 | /// page-rel. ADRP imm. 32:12. | 2028 | TLSGD_ADR_PAGE21 = 513, |
| 2027 | pub const R_AARCH64_TLSGD_ADR_PAGE21 = 513; | 2029 | /// direct ADD imm. from 11:0. |
| 2028 | /// direct ADD imm. from 11:0. | 2030 | TLSGD_ADD_LO12_NC = 514, |
| 2029 | pub const R_AARCH64_TLSGD_ADD_LO12_NC = 514; | 2031 | /// GOT-rel. MOV{N,Z} 31:16. |
| 2030 | /// GOT-rel. MOV{N,Z} 31:16. | 2032 | TLSGD_MOVW_G1 = 515, |
| 2031 | pub const R_AARCH64_TLSGD_MOVW_G1 = 515; | 2033 | /// GOT-rel. MOVK imm. 15:0. |
| 2032 | /// GOT-rel. MOVK imm. 15:0. | 2034 | TLSGD_MOVW_G0_NC = 516, |
| 2033 | pub const R_AARCH64_TLSGD_MOVW_G0_NC = 516; | 2035 | /// Like 512; local dynamic model. |
| 2034 | /// Like 512; local dynamic model. | 2036 | TLSLD_ADR_PREL21 = 517, |
| 2035 | pub const R_AARCH64_TLSLD_ADR_PREL21 = 517; | 2037 | /// Like 513; local dynamic model. |
| 2036 | /// Like 513; local dynamic model. | 2038 | TLSLD_ADR_PAGE21 = 518, |
| 2037 | pub const R_AARCH64_TLSLD_ADR_PAGE21 = 518; | 2039 | /// Like 514; local dynamic model. |
| 2038 | /// Like 514; local dynamic model. | 2040 | TLSLD_ADD_LO12_NC = 519, |
| 2039 | pub const R_AARCH64_TLSLD_ADD_LO12_NC = 519; | 2041 | /// Like 515; local dynamic model. |
| 2040 | /// Like 515; local dynamic model. | 2042 | TLSLD_MOVW_G1 = 520, |
| 2041 | pub const R_AARCH64_TLSLD_MOVW_G1 = 520; | 2043 | /// Like 516; local dynamic model. |
| 2042 | /// Like 516; local dynamic model. | 2044 | TLSLD_MOVW_G0_NC = 521, |
| 2043 | pub const R_AARCH64_TLSLD_MOVW_G0_NC = 521; | 2045 | /// TLS PC-rel. load imm. 20:2. |
| 2044 | /// TLS PC-rel. load imm. 20:2. | 2046 | TLSLD_LD_PREL19 = 522, |
| 2045 | pub const R_AARCH64_TLSLD_LD_PREL19 = 522; | 2047 | /// TLS DTP-rel. MOV{N,Z} 47:32. |
| 2046 | /// TLS DTP-rel. MOV{N,Z} 47:32. | 2048 | TLSLD_MOVW_DTPREL_G2 = 523, |
| 2047 | pub const R_AARCH64_TLSLD_MOVW_DTPREL_G2 = 523; | 2049 | /// TLS DTP-rel. MOV{N,Z} 31:16. |
| 2048 | /// TLS DTP-rel. MOV{N,Z} 31:16. | 2050 | TLSLD_MOVW_DTPREL_G1 = 524, |
| 2049 | pub const R_AARCH64_TLSLD_MOVW_DTPREL_G1 = 524; | 2051 | /// Likewise; MOVK; no check. |
| 2050 | /// Likewise; MOVK; no check. | 2052 | TLSLD_MOVW_DTPREL_G1_NC = 525, |
| 2051 | pub const R_AARCH64_TLSLD_MOVW_DTPREL_G1_NC = 525; | 2053 | /// TLS DTP-rel. MOV{N,Z} 15:0. |
| 2052 | /// TLS DTP-rel. MOV{N,Z} 15:0. | 2054 | TLSLD_MOVW_DTPREL_G0 = 526, |
| 2053 | pub const R_AARCH64_TLSLD_MOVW_DTPREL_G0 = 526; | 2055 | /// Likewise; MOVK; no check. |
| 2054 | /// Likewise; MOVK; no check. | 2056 | TLSLD_MOVW_DTPREL_G0_NC = 527, |
| 2055 | pub const R_AARCH64_TLSLD_MOVW_DTPREL_G0_NC = 527; | 2057 | /// DTP-rel. ADD imm. from 23:12. |
| 2056 | /// DTP-rel. ADD imm. from 23:12. | 2058 | TLSLD_ADD_DTPREL_HI12 = 528, |
| 2057 | pub const R_AARCH64_TLSLD_ADD_DTPREL_HI12 = 528; | 2059 | /// DTP-rel. ADD imm. from 11:0. |
| 2058 | /// DTP-rel. ADD imm. from 11:0. | 2060 | TLSLD_ADD_DTPREL_LO12 = 529, |
| 2059 | pub const R_AARCH64_TLSLD_ADD_DTPREL_LO12 = 529; | 2061 | /// Likewise; no ovfl. check. |
| 2060 | /// Likewise; no ovfl. check. | 2062 | TLSLD_ADD_DTPREL_LO12_NC = 530, |
| 2061 | pub const R_AARCH64_TLSLD_ADD_DTPREL_LO12_NC = 530; | 2063 | /// DTP-rel. LD/ST imm. 11:0. |
| 2062 | /// DTP-rel. LD/ST imm. 11:0. | 2064 | TLSLD_LDST8_DTPREL_LO12 = 531, |
| 2063 | pub const R_AARCH64_TLSLD_LDST8_DTPREL_LO12 = 531; | 2065 | /// Likewise; no check. |
| 2064 | /// Likewise; no check. | 2066 | TLSLD_LDST8_DTPREL_LO12_NC = 532, |
| 2065 | pub const R_AARCH64_TLSLD_LDST8_DTPREL_LO12_NC = 532; | 2067 | /// DTP-rel. LD/ST imm. 11:1. |
| 2066 | /// DTP-rel. LD/ST imm. 11:1. | 2068 | TLSLD_LDST16_DTPREL_LO12 = 533, |
| 2067 | pub const R_AARCH64_TLSLD_LDST16_DTPREL_LO12 = 533; | 2069 | /// Likewise; no check. |
| 2068 | /// Likewise; no check. | 2070 | TLSLD_LDST16_DTPREL_LO12_NC = 534, |
| 2069 | pub const R_AARCH64_TLSLD_LDST16_DTPREL_LO12_NC = 534; | 2071 | /// DTP-rel. LD/ST imm. 11:2. |
| 2070 | /// DTP-rel. LD/ST imm. 11:2. | 2072 | TLSLD_LDST32_DTPREL_LO12 = 535, |
| 2071 | pub const R_AARCH64_TLSLD_LDST32_DTPREL_LO12 = 535; | 2073 | /// Likewise; no check. |
| 2072 | /// Likewise; no check. | 2074 | TLSLD_LDST32_DTPREL_LO12_NC = 536, |
| 2073 | pub const R_AARCH64_TLSLD_LDST32_DTPREL_LO12_NC = 536; | 2075 | /// DTP-rel. LD/ST imm. 11:3. |
| 2074 | /// DTP-rel. LD/ST imm. 11:3. | 2076 | TLSLD_LDST64_DTPREL_LO12 = 537, |
| 2075 | pub const R_AARCH64_TLSLD_LDST64_DTPREL_LO12 = 537; | 2077 | /// Likewise; no check. |
| 2076 | /// Likewise; no check. | 2078 | TLSLD_LDST64_DTPREL_LO12_NC = 538, |
| 2077 | pub const R_AARCH64_TLSLD_LDST64_DTPREL_LO12_NC = 538; | 2079 | /// GOT-rel. MOV{N,Z} 31:16. |
| 2078 | /// GOT-rel. MOV{N,Z} 31:16. | 2080 | TLSIE_MOVW_GOTTPREL_G1 = 539, |
| 2079 | pub const R_AARCH64_TLSIE_MOVW_GOTTPREL_G1 = 539; | 2081 | /// GOT-rel. MOVK 15:0. |
| 2080 | /// GOT-rel. MOVK 15:0. | 2082 | TLSIE_MOVW_GOTTPREL_G0_NC = 540, |
| 2081 | pub const R_AARCH64_TLSIE_MOVW_GOTTPREL_G0_NC = 540; | 2083 | /// Page-rel. ADRP 32:12. |
| 2082 | /// Page-rel. ADRP 32:12. | 2084 | TLSIE_ADR_GOTTPREL_PAGE21 = 541, |
| 2083 | pub const R_AARCH64_TLSIE_ADR_GOTTPREL_PAGE21 = 541; | 2085 | /// Direct LD off. 11:3. |
| 2084 | /// Direct LD off. 11:3. | 2086 | TLSIE_LD64_GOTTPREL_LO12_NC = 542, |
| 2085 | pub const R_AARCH64_TLSIE_LD64_GOTTPREL_LO12_NC = 542; | 2087 | /// PC-rel. load imm. 20:2. |
| 2086 | /// PC-rel. load imm. 20:2. | 2088 | TLSIE_LD_GOTTPREL_PREL19 = 543, |
| 2087 | pub const R_AARCH64_TLSIE_LD_GOTTPREL_PREL19 = 543; | 2089 | /// TLS TP-rel. MOV{N,Z} 47:32. |
| 2088 | /// TLS TP-rel. MOV{N,Z} 47:32. | 2090 | TLSLE_MOVW_TPREL_G2 = 544, |
| 2089 | pub const R_AARCH64_TLSLE_MOVW_TPREL_G2 = 544; | 2091 | /// TLS TP-rel. MOV{N,Z} 31:16. |
| 2090 | /// TLS TP-rel. MOV{N,Z} 31:16. | 2092 | TLSLE_MOVW_TPREL_G1 = 545, |
| 2091 | pub const R_AARCH64_TLSLE_MOVW_TPREL_G1 = 545; | 2093 | /// Likewise; MOVK; no check. |
| 2092 | /// Likewise; MOVK; no check. | 2094 | TLSLE_MOVW_TPREL_G1_NC = 546, |
| 2093 | pub const R_AARCH64_TLSLE_MOVW_TPREL_G1_NC = 546; | 2095 | /// TLS TP-rel. MOV{N,Z} 15:0. |
| 2094 | /// TLS TP-rel. MOV{N,Z} 15:0. | 2096 | TLSLE_MOVW_TPREL_G0 = 547, |
| 2095 | pub const R_AARCH64_TLSLE_MOVW_TPREL_G0 = 547; | 2097 | /// Likewise; MOVK; no check. |
| 2096 | /// Likewise; MOVK; no check. | 2098 | TLSLE_MOVW_TPREL_G0_NC = 548, |
| 2097 | pub const R_AARCH64_TLSLE_MOVW_TPREL_G0_NC = 548; | 2099 | /// TP-rel. ADD imm. 23:12. |
| 2098 | /// TP-rel. ADD imm. 23:12. | 2100 | TLSLE_ADD_TPREL_HI12 = 549, |
| 2099 | pub const R_AARCH64_TLSLE_ADD_TPREL_HI12 = 549; | 2101 | /// TP-rel. ADD imm. 11:0. |
| 2100 | /// TP-rel. ADD imm. 11:0. | 2102 | TLSLE_ADD_TPREL_LO12 = 550, |
| 2101 | pub const R_AARCH64_TLSLE_ADD_TPREL_LO12 = 550; | 2103 | /// Likewise; no ovfl. check. |
| 2102 | /// Likewise; no ovfl. check. | 2104 | TLSLE_ADD_TPREL_LO12_NC = 551, |
| 2103 | pub const R_AARCH64_TLSLE_ADD_TPREL_LO12_NC = 551; | 2105 | /// TP-rel. LD/ST off. 11:0. |
| 2104 | /// TP-rel. LD/ST off. 11:0. | 2106 | TLSLE_LDST8_TPREL_LO12 = 552, |
| 2105 | pub const R_AARCH64_TLSLE_LDST8_TPREL_LO12 = 552; | 2107 | /// Likewise; no ovfl. check. |
| 2106 | /// Likewise; no ovfl. check. | 2108 | TLSLE_LDST8_TPREL_LO12_NC = 553, |
| 2107 | pub const R_AARCH64_TLSLE_LDST8_TPREL_LO12_NC = 553; | 2109 | /// TP-rel. LD/ST off. 11:1. |
| 2108 | /// TP-rel. LD/ST off. 11:1. | 2110 | TLSLE_LDST16_TPREL_LO12 = 554, |
| 2109 | pub const R_AARCH64_TLSLE_LDST16_TPREL_LO12 = 554; | 2111 | /// Likewise; no check. |
| 2110 | /// Likewise; no check. | 2112 | TLSLE_LDST16_TPREL_LO12_NC = 555, |
| 2111 | pub const R_AARCH64_TLSLE_LDST16_TPREL_LO12_NC = 555; | 2113 | /// TP-rel. LD/ST off. 11:2. |
| 2112 | /// TP-rel. LD/ST off. 11:2. | 2114 | TLSLE_LDST32_TPREL_LO12 = 556, |
| 2113 | pub const R_AARCH64_TLSLE_LDST32_TPREL_LO12 = 556; | 2115 | /// Likewise; no check. |
| 2114 | /// Likewise; no check. | 2116 | TLSLE_LDST32_TPREL_LO12_NC = 557, |
| 2115 | pub const R_AARCH64_TLSLE_LDST32_TPREL_LO12_NC = 557; | 2117 | /// TP-rel. LD/ST off. 11:3. |
| 2116 | /// TP-rel. LD/ST off. 11:3. | 2118 | TLSLE_LDST64_TPREL_LO12 = 558, |
| 2117 | pub const R_AARCH64_TLSLE_LDST64_TPREL_LO12 = 558; | 2119 | /// Likewise; no check. |
| 2118 | /// Likewise; no check. | 2120 | TLSLE_LDST64_TPREL_LO12_NC = 559, |
| 2119 | pub const R_AARCH64_TLSLE_LDST64_TPREL_LO12_NC = 559; | 2121 | /// PC-rel. load immediate 20:2. |
| 2120 | /// PC-rel. load immediate 20:2. | 2122 | TLSDESC_LD_PREL19 = 560, |
| 2121 | pub const R_AARCH64_TLSDESC_LD_PREL19 = 560; | 2123 | /// PC-rel. ADR immediate 20:0. |
| 2122 | /// PC-rel. ADR immediate 20:0. | 2124 | TLSDESC_ADR_PREL21 = 561, |
| 2123 | pub const R_AARCH64_TLSDESC_ADR_PREL21 = 561; | 2125 | /// Page-rel. ADRP imm. 32:12. |
| 2124 | /// Page-rel. ADRP imm. 32:12. | 2126 | TLSDESC_ADR_PAGE21 = 562, |
| 2125 | pub const R_AARCH64_TLSDESC_ADR_PAGE21 = 562; | 2127 | /// Direct LD off. from 11:3. |
| 2126 | /// Direct LD off. from 11:3. | 2128 | TLSDESC_LD64_LO12 = 563, |
| 2127 | pub const R_AARCH64_TLSDESC_LD64_LO12 = 563; | 2129 | /// Direct ADD imm. from 11:0. |
| 2128 | /// Direct ADD imm. from 11:0. | 2130 | TLSDESC_ADD_LO12 = 564, |
| 2129 | pub const R_AARCH64_TLSDESC_ADD_LO12 = 564; | 2131 | /// GOT-rel. MOV{N,Z} imm. 31:16. |
| 2130 | /// GOT-rel. MOV{N,Z} imm. 31:16. | 2132 | TLSDESC_OFF_G1 = 565, |
| 2131 | pub const R_AARCH64_TLSDESC_OFF_G1 = 565; | 2133 | /// GOT-rel. MOVK imm. 15:0; no ck. |
| 2132 | /// GOT-rel. MOVK imm. 15:0; no ck. | 2134 | TLSDESC_OFF_G0_NC = 566, |
| 2133 | pub const R_AARCH64_TLSDESC_OFF_G0_NC = 566; | 2135 | /// Relax LDR. |
| 2134 | /// Relax LDR. | 2136 | TLSDESC_LDR = 567, |
| 2135 | pub const R_AARCH64_TLSDESC_LDR = 567; | 2137 | /// Relax ADD. |
| 2136 | /// Relax ADD. | 2138 | TLSDESC_ADD = 568, |
| 2137 | pub const R_AARCH64_TLSDESC_ADD = 568; | 2139 | /// Relax BLR. |
| 2138 | /// Relax BLR. | 2140 | TLSDESC_CALL = 569, |
| 2139 | pub const R_AARCH64_TLSDESC_CALL = 569; | 2141 | /// TP-rel. LD/ST off. 11:4. |
| 2140 | /// TP-rel. LD/ST off. 11:4. | 2142 | TLSLE_LDST128_TPREL_LO12 = 570, |
| 2141 | pub const R_AARCH64_TLSLE_LDST128_TPREL_LO12 = 570; | 2143 | /// Likewise; no check. |
| 2142 | /// Likewise; no check. | 2144 | TLSLE_LDST128_TPREL_LO12_NC = 571, |
| 2143 | pub const R_AARCH64_TLSLE_LDST128_TPREL_LO12_NC = 571; | 2145 | /// DTP-rel. LD/ST imm. 11:4. |
| 2144 | /// DTP-rel. LD/ST imm. 11:4. | 2146 | TLSLD_LDST128_DTPREL_LO12 = 572, |
| 2145 | pub const R_AARCH64_TLSLD_LDST128_DTPREL_LO12 = 572; | 2147 | /// Likewise; no check. |
| 2146 | /// Likewise; no check. | 2148 | TLSLD_LDST128_DTPREL_LO12_NC = 573, |
| 2147 | pub const R_AARCH64_TLSLD_LDST128_DTPREL_LO12_NC = 573; | 2149 | /// Copy symbol at runtime. |
| 2148 | /// Copy symbol at runtime. | 2150 | COPY = 1024, |
| 2149 | pub const R_AARCH64_COPY = 1024; | 2151 | /// Create GOT entry. |
| 2150 | /// Create GOT entry. | 2152 | GLOB_DAT = 1025, |
| 2151 | pub const R_AARCH64_GLOB_DAT = 1025; | 2153 | /// Create PLT entry. |
| 2152 | /// Create PLT entry. | 2154 | JUMP_SLOT = 1026, |
| 2153 | pub const R_AARCH64_JUMP_SLOT = 1026; | 2155 | /// Adjust by program base. |
| 2154 | /// Adjust by program base. | 2156 | RELATIVE = 1027, |
| 2155 | pub const R_AARCH64_RELATIVE = 1027; | 2157 | /// Module number, 64 bit. |
| 2156 | /// Module number, 64 bit. | 2158 | TLS_DTPMOD = 1028, |
| 2157 | pub const R_AARCH64_TLS_DTPMOD = 1028; | 2159 | /// Module-relative offset, 64 bit. |
| 2158 | /// Module-relative offset, 64 bit. | 2160 | TLS_DTPREL = 1029, |
| 2159 | pub const R_AARCH64_TLS_DTPREL = 1029; | 2161 | /// TP-relative offset, 64 bit. |
| 2160 | /// TP-relative offset, 64 bit. | 2162 | TLS_TPREL = 1030, |
| 2161 | pub const R_AARCH64_TLS_TPREL = 1030; | 2163 | /// TLS Descriptor. |
| 2162 | /// TLS Descriptor. | 2164 | TLSDESC = 1031, |
| 2163 | pub const R_AARCH64_TLSDESC = 1031; | 2165 | /// STT_GNU_IFUNC relocation. |
| 2164 | /// STT_GNU_IFUNC relocation. | 2166 | IRELATIVE = 1032, |
| 2165 | pub const R_AARCH64_IRELATIVE = 1032; | 2167 | _, |
| 2168 | }; | ||
| 2169 | |||
| 2170 | /// RISC-V relocations. | ||
| 2171 | pub const R_RISCV = enum(u32) { | ||
| 2172 | NONE = 0, | ||
| 2173 | @"32" = 1, | ||
| 2174 | @"64" = 2, | ||
| 2175 | RELATIVE = 3, | ||
| 2176 | COPY = 4, | ||
| 2177 | JUMP_SLOT = 5, | ||
| 2178 | TLS_DTPMOD32 = 6, | ||
| 2179 | TLS_DTPMOD64 = 7, | ||
| 2180 | TLS_DTPREL32 = 8, | ||
| 2181 | TLS_DTPREL64 = 9, | ||
| 2182 | TLS_TPREL32 = 10, | ||
| 2183 | TLS_TPREL64 = 11, | ||
| 2184 | TLSDESC = 12, | ||
| 2185 | BRANCH = 16, | ||
| 2186 | JAL = 17, | ||
| 2187 | CALL = 18, | ||
| 2188 | CALL_PLT = 19, | ||
| 2189 | GOT_HI20 = 20, | ||
| 2190 | TLS_GOT_HI20 = 21, | ||
| 2191 | TLS_GD_HI20 = 22, | ||
| 2192 | PCREL_HI20 = 23, | ||
| 2193 | PCREL_LO12_I = 24, | ||
| 2194 | PCREL_LO12_S = 25, | ||
| 2195 | HI20 = 26, | ||
| 2196 | LO12_I = 27, | ||
| 2197 | LO12_S = 28, | ||
| 2198 | TPREL_HI20 = 29, | ||
| 2199 | TPREL_LO12_I = 30, | ||
| 2200 | TPREL_LO12_S = 31, | ||
| 2201 | TPREL_ADD = 32, | ||
| 2202 | ADD8 = 33, | ||
| 2203 | ADD16 = 34, | ||
| 2204 | ADD32 = 35, | ||
| 2205 | ADD64 = 36, | ||
| 2206 | SUB8 = 37, | ||
| 2207 | SUB16 = 38, | ||
| 2208 | SUB32 = 39, | ||
| 2209 | SUB64 = 40, | ||
| 2210 | GNU_VTINHERIT = 41, | ||
| 2211 | GNU_VTENTRY = 42, | ||
| 2212 | ALIGN = 43, | ||
| 2213 | RVC_BRANCH = 44, | ||
| 2214 | RVC_JUMP = 45, | ||
| 2215 | RVC_LUI = 46, | ||
| 2216 | GPREL_I = 47, | ||
| 2217 | GPREL_S = 48, | ||
| 2218 | TPREL_I = 49, | ||
| 2219 | TPREL_S = 50, | ||
| 2220 | RELAX = 51, | ||
| 2221 | SUB6 = 52, | ||
| 2222 | SET6 = 53, | ||
| 2223 | SET8 = 54, | ||
| 2224 | SET16 = 55, | ||
| 2225 | SET32 = 56, | ||
| 2226 | @"32_PCREL" = 57, | ||
| 2227 | IRELATIVE = 58, | ||
| 2228 | PLT32 = 59, | ||
| 2229 | SET_ULEB128 = 60, | ||
| 2230 | SUB_ULEB128 = 61, | ||
| 2231 | _, | ||
| 2232 | }; | ||
| 2166 | 2233 | ||
| 2167 | pub const STV = enum(u2) { | 2234 | pub const STV = enum(u2) { |
| 2168 | DEFAULT = 0, | 2235 | DEFAULT = 0, |
src/arch/x86_64/Emit.zig+15-11| ... | @@ -43,9 +43,10 @@ pub fn emitMir(emit: *Emit) Error!void { | ... | @@ -43,9 +43,10 @@ pub fn emitMir(emit: *Emit) Error!void { |
| 43 | .linker_extern_fn => |symbol| if (emit.lower.bin_file.cast(link.File.Elf)) |elf_file| { | 43 | .linker_extern_fn => |symbol| if (emit.lower.bin_file.cast(link.File.Elf)) |elf_file| { |
| 44 | // Add relocation to the decl. | 44 | // Add relocation to the decl. |
| 45 | const atom_ptr = elf_file.symbol(symbol.atom_index).atom(elf_file).?; | 45 | const atom_ptr = elf_file.symbol(symbol.atom_index).atom(elf_file).?; |
| 46 | const r_type = @intFromEnum(std.elf.R_X86_64.PLT32); | ||
| 46 | try atom_ptr.addReloc(elf_file, .{ | 47 | try atom_ptr.addReloc(elf_file, .{ |
| 47 | .r_offset = end_offset - 4, | 48 | .r_offset = end_offset - 4, |
| 48 | .r_info = (@as(u64, @intCast(symbol.sym_index)) << 32) | std.elf.R_X86_64_PLT32, | 49 | .r_info = (@as(u64, @intCast(symbol.sym_index)) << 32) | r_type, |
| 49 | .r_addend = -4, | 50 | .r_addend = -4, |
| 50 | }); | 51 | }); |
| 51 | } else if (emit.lower.bin_file.cast(link.File.MachO)) |macho_file| { | 52 | } else if (emit.lower.bin_file.cast(link.File.MachO)) |macho_file| { |
| ... | @@ -88,18 +89,20 @@ pub fn emitMir(emit: *Emit) Error!void { | ... | @@ -88,18 +89,20 @@ pub fn emitMir(emit: *Emit) Error!void { |
| 88 | .linker_tlsld => |data| { | 89 | .linker_tlsld => |data| { |
| 89 | const elf_file = emit.lower.bin_file.cast(link.File.Elf).?; | 90 | const elf_file = emit.lower.bin_file.cast(link.File.Elf).?; |
| 90 | const atom = elf_file.symbol(data.atom_index).atom(elf_file).?; | 91 | const atom = elf_file.symbol(data.atom_index).atom(elf_file).?; |
| 92 | const r_type = @intFromEnum(std.elf.R_X86_64.TLSLD); | ||
| 91 | try atom.addReloc(elf_file, .{ | 93 | try atom.addReloc(elf_file, .{ |
| 92 | .r_offset = end_offset - 4, | 94 | .r_offset = end_offset - 4, |
| 93 | .r_info = (@as(u64, @intCast(data.sym_index)) << 32) | std.elf.R_X86_64_TLSLD, | 95 | .r_info = (@as(u64, @intCast(data.sym_index)) << 32) | r_type, |
| 94 | .r_addend = -4, | 96 | .r_addend = -4, |
| 95 | }); | 97 | }); |
| 96 | }, | 98 | }, |
| 97 | .linker_dtpoff => |data| { | 99 | .linker_dtpoff => |data| { |
| 98 | const elf_file = emit.lower.bin_file.cast(link.File.Elf).?; | 100 | const elf_file = emit.lower.bin_file.cast(link.File.Elf).?; |
| 99 | const atom = elf_file.symbol(data.atom_index).atom(elf_file).?; | 101 | const atom = elf_file.symbol(data.atom_index).atom(elf_file).?; |
| 102 | const r_type = @intFromEnum(std.elf.R_X86_64.DTPOFF32); | ||
| 100 | try atom.addReloc(elf_file, .{ | 103 | try atom.addReloc(elf_file, .{ |
| 101 | .r_offset = end_offset - 4, | 104 | .r_offset = end_offset - 4, |
| 102 | .r_info = (@as(u64, @intCast(data.sym_index)) << 32) | std.elf.R_X86_64_DTPOFF32, | 105 | .r_info = (@as(u64, @intCast(data.sym_index)) << 32) | r_type, |
| 103 | .r_addend = 0, | 106 | .r_addend = 0, |
| 104 | }); | 107 | }); |
| 105 | }, | 108 | }, |
| ... | @@ -117,11 +120,11 @@ pub fn emitMir(emit: *Emit) Error!void { | ... | @@ -117,11 +120,11 @@ pub fn emitMir(emit: *Emit) Error!void { |
| 117 | } | 120 | } |
| 118 | if (emit.lower.pic) { | 121 | if (emit.lower.pic) { |
| 119 | const r_type: u32 = if (sym.flags.needs_zig_got and !is_obj_or_static_lib) | 122 | const r_type: u32 = if (sym.flags.needs_zig_got and !is_obj_or_static_lib) |
| 120 | link.File.Elf.R_X86_64_ZIG_GOTPCREL | 123 | link.File.Elf.R_ZIG_GOTPCREL |
| 121 | else if (sym.flags.needs_got) | 124 | else if (sym.flags.needs_got) |
| 122 | std.elf.R_X86_64_GOTPCREL | 125 | @intFromEnum(std.elf.R_X86_64.GOTPCREL) |
| 123 | else | 126 | else |
| 124 | std.elf.R_X86_64_PC32; | 127 | @intFromEnum(std.elf.R_X86_64.PC32); |
| 125 | try atom.addReloc(elf_file, .{ | 128 | try atom.addReloc(elf_file, .{ |
| 126 | .r_offset = end_offset - 4, | 129 | .r_offset = end_offset - 4, |
| 127 | .r_info = (@as(u64, @intCast(data.sym_index)) << 32) | r_type, | 130 | .r_info = (@as(u64, @intCast(data.sym_index)) << 32) | r_type, |
| ... | @@ -129,20 +132,21 @@ pub fn emitMir(emit: *Emit) Error!void { | ... | @@ -129,20 +132,21 @@ pub fn emitMir(emit: *Emit) Error!void { |
| 129 | }); | 132 | }); |
| 130 | } else { | 133 | } else { |
| 131 | if (lowered_inst.encoding.mnemonic == .call and sym.flags.needs_zig_got and is_obj_or_static_lib) { | 134 | if (lowered_inst.encoding.mnemonic == .call and sym.flags.needs_zig_got and is_obj_or_static_lib) { |
| 135 | const r_type = @intFromEnum(std.elf.R_X86_64.PC32); | ||
| 132 | try atom.addReloc(elf_file, .{ | 136 | try atom.addReloc(elf_file, .{ |
| 133 | .r_offset = end_offset - 4, | 137 | .r_offset = end_offset - 4, |
| 134 | .r_info = (@as(u64, @intCast(data.sym_index)) << 32) | std.elf.R_X86_64_PC32, | 138 | .r_info = (@as(u64, @intCast(data.sym_index)) << 32) | r_type, |
| 135 | .r_addend = -4, | 139 | .r_addend = -4, |
| 136 | }); | 140 | }); |
| 137 | } else { | 141 | } else { |
| 138 | const r_type: u32 = if (sym.flags.needs_zig_got and !is_obj_or_static_lib) | 142 | const r_type: u32 = if (sym.flags.needs_zig_got and !is_obj_or_static_lib) |
| 139 | link.File.Elf.R_X86_64_ZIG_GOT32 | 143 | link.File.Elf.R_ZIG_GOT32 |
| 140 | else if (sym.flags.needs_got) | 144 | else if (sym.flags.needs_got) |
| 141 | std.elf.R_X86_64_GOT32 | 145 | @intFromEnum(std.elf.R_X86_64.GOT32) |
| 142 | else if (sym.flags.is_tls) | 146 | else if (sym.flags.is_tls) |
| 143 | std.elf.R_X86_64_TPOFF32 | 147 | @intFromEnum(std.elf.R_X86_64.TPOFF32) |
| 144 | else | 148 | else |
| 145 | std.elf.R_X86_64_32; | 149 | @intFromEnum(std.elf.R_X86_64.@"32"); |
| 146 | try atom.addReloc(elf_file, .{ | 150 | try atom.addReloc(elf_file, .{ |
| 147 | .r_offset = end_offset - 4, | 151 | .r_offset = end_offset - 4, |
| 148 | .r_info = (@as(u64, @intCast(data.sym_index)) << 32) | r_type, | 152 | .r_info = (@as(u64, @intCast(data.sym_index)) << 32) | r_type, |
src/link/Elf.zig+3-2| ... | @@ -6065,8 +6065,9 @@ const RelaSection = struct { | ... | @@ -6065,8 +6065,9 @@ const RelaSection = struct { |
| 6065 | }; | 6065 | }; |
| 6066 | const RelaSectionTable = std.AutoArrayHashMapUnmanaged(u32, RelaSection); | 6066 | const RelaSectionTable = std.AutoArrayHashMapUnmanaged(u32, RelaSection); |
| 6067 | 6067 | ||
| 6068 | pub const R_X86_64_ZIG_GOT32 = elf.R_X86_64_NUM + 1; | 6068 | // TODO: add comptime check we don't clobber any reloc for any ISA |
| 6069 | pub const R_X86_64_ZIG_GOTPCREL = elf.R_X86_64_NUM + 2; | 6069 | pub const R_ZIG_GOT32: u32 = 0xff00; |
| 6070 | pub const R_ZIG_GOTPCREL: u32 = 0xff01; | ||
| 6070 | 6071 | ||
| 6071 | fn defaultEntrySymbolName(cpu_arch: std.Target.Cpu.Arch) []const u8 { | 6072 | fn defaultEntrySymbolName(cpu_arch: std.Target.Cpu.Arch) []const u8 { |
| 6072 | return switch (cpu_arch) { | 6073 | return switch (cpu_arch) { |
src/link/Elf/Atom.zig+105-94| ... | @@ -336,7 +336,7 @@ pub fn writeRelocs(self: Atom, elf_file: *Elf, out_relocs: *std.ArrayList(elf.El | ... | @@ -336,7 +336,7 @@ pub fn writeRelocs(self: Atom, elf_file: *Elf, out_relocs: *std.ArrayList(elf.El |
| 336 | } | 336 | } |
| 337 | 337 | ||
| 338 | relocs_log.debug(" {s}: [{x} => {d}({s})] + {x}", .{ | 338 | relocs_log.debug(" {s}: [{x} => {d}({s})] + {x}", .{ |
| 339 | relocation.fmtRelocType(r_type, cpu_arch), | 339 | relocation.fmtRelocType(rel.r_type(), cpu_arch), |
| 340 | r_offset, | 340 | r_offset, |
| 341 | r_sym, | 341 | r_sym, |
| 342 | target.name(elf_file), | 342 | target.name(elf_file), |
| ... | @@ -384,7 +384,10 @@ pub fn scanRelocsRequiresCode(self: Atom, elf_file: *Elf) bool { | ... | @@ -384,7 +384,10 @@ pub fn scanRelocsRequiresCode(self: Atom, elf_file: *Elf) bool { |
| 384 | const cpu_arch = elf_file.getTarget().cpu.arch; | 384 | const cpu_arch = elf_file.getTarget().cpu.arch; |
| 385 | for (self.relocs(elf_file)) |rel| { | 385 | for (self.relocs(elf_file)) |rel| { |
| 386 | switch (cpu_arch) { | 386 | switch (cpu_arch) { |
| 387 | .x86_64 => if (rel.r_type() == elf.R_X86_64_GOTTPOFF) return true, | 387 | .x86_64 => { |
| 388 | const r_type: elf.R_X86_64 = @enumFromInt(rel.r_type()); | ||
| 389 | if (r_type == .GOTTPOFF) return true; | ||
| 390 | }, | ||
| 388 | else => {}, | 391 | else => {}, |
| 389 | } | 392 | } |
| 390 | } | 393 | } |
| ... | @@ -836,8 +839,9 @@ const x86_64 = struct { | ... | @@ -836,8 +839,9 @@ const x86_64 = struct { |
| 836 | var i: usize = 0; | 839 | var i: usize = 0; |
| 837 | while (i < rels.len) : (i += 1) { | 840 | while (i < rels.len) : (i += 1) { |
| 838 | const rel = rels[i]; | 841 | const rel = rels[i]; |
| 842 | const r_type: elf.R_X86_64 = @enumFromInt(rel.r_type()); | ||
| 839 | 843 | ||
| 840 | if (rel.r_type() == elf.R_X86_64_NONE) continue; | 844 | if (r_type == .NONE) continue; |
| 841 | 845 | ||
| 842 | const r_offset = std.math.cast(usize, rel.r_offset) orelse return error.Overflow; | 846 | const r_offset = std.math.cast(usize, rel.r_offset) orelse return error.Overflow; |
| 843 | 847 | ||
| ... | @@ -869,41 +873,41 @@ const x86_64 = struct { | ... | @@ -869,41 +873,41 @@ const x86_64 = struct { |
| 869 | 873 | ||
| 870 | // While traversing relocations, mark symbols that require special handling such as | 874 | // While traversing relocations, mark symbols that require special handling such as |
| 871 | // pointer indirection via GOT, or a stub trampoline via PLT. | 875 | // pointer indirection via GOT, or a stub trampoline via PLT. |
| 872 | switch (rel.r_type()) { | 876 | switch (r_type) { |
| 873 | elf.R_X86_64_64 => { | 877 | .@"64" => { |
| 874 | try atom.scanReloc(symbol, rel, dynAbsRelocAction(symbol, elf_file), elf_file); | 878 | try atom.scanReloc(symbol, rel, dynAbsRelocAction(symbol, elf_file), elf_file); |
| 875 | }, | 879 | }, |
| 876 | 880 | ||
| 877 | elf.R_X86_64_32, | 881 | .@"32", |
| 878 | elf.R_X86_64_32S, | 882 | .@"32S", |
| 879 | => { | 883 | => { |
| 880 | try atom.scanReloc(symbol, rel, dynAbsRelocAction(symbol, elf_file), elf_file); | 884 | try atom.scanReloc(symbol, rel, dynAbsRelocAction(symbol, elf_file), elf_file); |
| 881 | }, | 885 | }, |
| 882 | 886 | ||
| 883 | elf.R_X86_64_GOT32, | 887 | .GOT32, |
| 884 | elf.R_X86_64_GOTPC32, | 888 | .GOTPC32, |
| 885 | elf.R_X86_64_GOTPC64, | 889 | .GOTPC64, |
| 886 | elf.R_X86_64_GOTPCREL, | 890 | .GOTPCREL, |
| 887 | elf.R_X86_64_GOTPCREL64, | 891 | .GOTPCREL64, |
| 888 | elf.R_X86_64_GOTPCRELX, | 892 | .GOTPCRELX, |
| 889 | elf.R_X86_64_REX_GOTPCRELX, | 893 | .REX_GOTPCRELX, |
| 890 | => { | 894 | => { |
| 891 | symbol.flags.needs_got = true; | 895 | symbol.flags.needs_got = true; |
| 892 | }, | 896 | }, |
| 893 | 897 | ||
| 894 | elf.R_X86_64_PLT32, | 898 | .PLT32, |
| 895 | elf.R_X86_64_PLTOFF64, | 899 | .PLTOFF64, |
| 896 | => { | 900 | => { |
| 897 | if (symbol.flags.import) { | 901 | if (symbol.flags.import) { |
| 898 | symbol.flags.needs_plt = true; | 902 | symbol.flags.needs_plt = true; |
| 899 | } | 903 | } |
| 900 | }, | 904 | }, |
| 901 | 905 | ||
| 902 | elf.R_X86_64_PC32 => { | 906 | .PC32 => { |
| 903 | try atom.scanReloc(symbol, rel, pcRelocAction(symbol, elf_file), elf_file); | 907 | try atom.scanReloc(symbol, rel, pcRelocAction(symbol, elf_file), elf_file); |
| 904 | }, | 908 | }, |
| 905 | 909 | ||
| 906 | elf.R_X86_64_TLSGD => { | 910 | .TLSGD => { |
| 907 | // TODO verify followed by appropriate relocation such as PLT32 __tls_get_addr | 911 | // TODO verify followed by appropriate relocation such as PLT32 __tls_get_addr |
| 908 | 912 | ||
| 909 | if (is_static or (!symbol.flags.import and !is_dyn_lib)) { | 913 | if (is_static or (!symbol.flags.import and !is_dyn_lib)) { |
| ... | @@ -918,7 +922,7 @@ const x86_64 = struct { | ... | @@ -918,7 +922,7 @@ const x86_64 = struct { |
| 918 | } | 922 | } |
| 919 | }, | 923 | }, |
| 920 | 924 | ||
| 921 | elf.R_X86_64_TLSLD => { | 925 | .TLSLD => { |
| 922 | // TODO verify followed by appropriate relocation such as PLT32 __tls_get_addr | 926 | // TODO verify followed by appropriate relocation such as PLT32 __tls_get_addr |
| 923 | 927 | ||
| 924 | if (is_static or !is_dyn_lib) { | 928 | if (is_static or !is_dyn_lib) { |
| ... | @@ -930,7 +934,7 @@ const x86_64 = struct { | ... | @@ -930,7 +934,7 @@ const x86_64 = struct { |
| 930 | } | 934 | } |
| 931 | }, | 935 | }, |
| 932 | 936 | ||
| 933 | elf.R_X86_64_GOTTPOFF => { | 937 | .GOTTPOFF => { |
| 934 | const should_relax = blk: { | 938 | const should_relax = blk: { |
| 935 | if (is_dyn_lib or symbol.flags.import) break :blk false; | 939 | if (is_dyn_lib or symbol.flags.import) break :blk false; |
| 936 | if (!x86_64.canRelaxGotTpOff(code.?[r_offset - 3 ..])) break :blk false; | 940 | if (!x86_64.canRelaxGotTpOff(code.?[r_offset - 3 ..])) break :blk false; |
| ... | @@ -941,35 +945,37 @@ const x86_64 = struct { | ... | @@ -941,35 +945,37 @@ const x86_64 = struct { |
| 941 | } | 945 | } |
| 942 | }, | 946 | }, |
| 943 | 947 | ||
| 944 | elf.R_X86_64_GOTPC32_TLSDESC => { | 948 | .GOTPC32_TLSDESC => { |
| 945 | const should_relax = is_static or (!is_dyn_lib and !symbol.flags.import); | 949 | const should_relax = is_static or (!is_dyn_lib and !symbol.flags.import); |
| 946 | if (!should_relax) { | 950 | if (!should_relax) { |
| 947 | symbol.flags.needs_tlsdesc = true; | 951 | symbol.flags.needs_tlsdesc = true; |
| 948 | } | 952 | } |
| 949 | }, | 953 | }, |
| 950 | 954 | ||
| 951 | elf.R_X86_64_TPOFF32, | 955 | .TPOFF32, |
| 952 | elf.R_X86_64_TPOFF64, | 956 | .TPOFF64, |
| 953 | => { | 957 | => { |
| 954 | if (is_dyn_lib) try atom.reportPicError(symbol, rel, elf_file); | 958 | if (is_dyn_lib) try atom.reportPicError(symbol, rel, elf_file); |
| 955 | }, | 959 | }, |
| 956 | 960 | ||
| 957 | elf.R_X86_64_GOTOFF64, | 961 | .GOTOFF64, |
| 958 | elf.R_X86_64_DTPOFF32, | 962 | .DTPOFF32, |
| 959 | elf.R_X86_64_DTPOFF64, | 963 | .DTPOFF64, |
| 960 | elf.R_X86_64_SIZE32, | 964 | .SIZE32, |
| 961 | elf.R_X86_64_SIZE64, | 965 | .SIZE64, |
| 962 | elf.R_X86_64_TLSDESC_CALL, | 966 | .TLSDESC_CALL, |
| 963 | => {}, | 967 | => {}, |
| 964 | 968 | ||
| 965 | // Zig custom relocations | 969 | else => |x| switch (@intFromEnum(x)) { |
| 966 | Elf.R_X86_64_ZIG_GOT32, | 970 | // Zig custom relocations |
| 967 | Elf.R_X86_64_ZIG_GOTPCREL, | 971 | Elf.R_ZIG_GOT32, |
| 968 | => { | 972 | Elf.R_ZIG_GOTPCREL, |
| 969 | assert(symbol.flags.has_zig_got); | 973 | => { |
| 970 | }, | 974 | assert(symbol.flags.has_zig_got); |
| 975 | }, | ||
| 971 | 976 | ||
| 972 | else => try atom.reportUnhandledRelocError(rel, elf_file), | 977 | else => try atom.reportUnhandledRelocError(rel, elf_file), |
| 978 | }, | ||
| 973 | } | 979 | } |
| 974 | } | 980 | } |
| 975 | } | 981 | } |
| ... | @@ -983,8 +989,8 @@ const x86_64 = struct { | ... | @@ -983,8 +989,8 @@ const x86_64 = struct { |
| 983 | var i: usize = 0; | 989 | var i: usize = 0; |
| 984 | while (i < rels.len) : (i += 1) { | 990 | while (i < rels.len) : (i += 1) { |
| 985 | const rel = rels[i]; | 991 | const rel = rels[i]; |
| 986 | const r_type = rel.r_type(); | 992 | const r_type: elf.R_X86_64 = @enumFromInt(rel.r_type()); |
| 987 | if (r_type == elf.R_X86_64_NONE) continue; | 993 | if (r_type == .NONE) continue; |
| 988 | 994 | ||
| 989 | const target = switch (file_ptr) { | 995 | const target = switch (file_ptr) { |
| 990 | .zig_object => |x| elf_file.symbol(x.symbol(rel.r_sym())), | 996 | .zig_object => |x| elf_file.symbol(x.symbol(rel.r_sym())), |
| ... | @@ -1022,7 +1028,7 @@ const x86_64 = struct { | ... | @@ -1022,7 +1028,7 @@ const x86_64 = struct { |
| 1022 | const DTP = @as(i64, @intCast(elf_file.dtpAddress())); | 1028 | const DTP = @as(i64, @intCast(elf_file.dtpAddress())); |
| 1023 | 1029 | ||
| 1024 | relocs_log.debug(" {s}: {x}: [{x} => {x}] G({x}) ZG({x}) ({s})", .{ | 1030 | relocs_log.debug(" {s}: {x}: [{x} => {x}] G({x}) ZG({x}) ({s})", .{ |
| 1025 | relocation.fmtRelocType(r_type, .x86_64), | 1031 | relocation.fmtRelocType(rel.r_type(), .x86_64), |
| 1026 | r_offset, | 1032 | r_offset, |
| 1027 | P, | 1033 | P, |
| 1028 | S + A, | 1034 | S + A, |
| ... | @@ -1033,10 +1039,10 @@ const x86_64 = struct { | ... | @@ -1033,10 +1039,10 @@ const x86_64 = struct { |
| 1033 | 1039 | ||
| 1034 | try stream.seekTo(r_offset); | 1040 | try stream.seekTo(r_offset); |
| 1035 | 1041 | ||
| 1036 | switch (rel.r_type()) { | 1042 | switch (r_type) { |
| 1037 | elf.R_X86_64_NONE => unreachable, | 1043 | .NONE => unreachable, |
| 1038 | 1044 | ||
| 1039 | elf.R_X86_64_64 => { | 1045 | .@"64" => { |
| 1040 | try atom.resolveDynAbsReloc( | 1046 | try atom.resolveDynAbsReloc( |
| 1041 | target, | 1047 | target, |
| 1042 | rel, | 1048 | rel, |
| ... | @@ -1046,15 +1052,15 @@ const x86_64 = struct { | ... | @@ -1046,15 +1052,15 @@ const x86_64 = struct { |
| 1046 | ); | 1052 | ); |
| 1047 | }, | 1053 | }, |
| 1048 | 1054 | ||
| 1049 | elf.R_X86_64_PLT32, | 1055 | .PLT32, |
| 1050 | elf.R_X86_64_PC32, | 1056 | .PC32, |
| 1051 | => try cwriter.writeInt(i32, @as(i32, @intCast(S + A - P)), .little), | 1057 | => try cwriter.writeInt(i32, @as(i32, @intCast(S + A - P)), .little), |
| 1052 | 1058 | ||
| 1053 | elf.R_X86_64_GOTPCREL => try cwriter.writeInt(i32, @as(i32, @intCast(G + GOT + A - P)), .little), | 1059 | .GOTPCREL => try cwriter.writeInt(i32, @as(i32, @intCast(G + GOT + A - P)), .little), |
| 1054 | elf.R_X86_64_GOTPC32 => try cwriter.writeInt(i32, @as(i32, @intCast(GOT + A - P)), .little), | 1060 | .GOTPC32 => try cwriter.writeInt(i32, @as(i32, @intCast(GOT + A - P)), .little), |
| 1055 | elf.R_X86_64_GOTPC64 => try cwriter.writeInt(i64, GOT + A - P, .little), | 1061 | .GOTPC64 => try cwriter.writeInt(i64, GOT + A - P, .little), |
| 1056 | 1062 | ||
| 1057 | elf.R_X86_64_GOTPCRELX => { | 1063 | .GOTPCRELX => { |
| 1058 | if (!target.flags.import and !target.isIFunc(elf_file) and !target.isAbs(elf_file)) blk: { | 1064 | if (!target.flags.import and !target.isIFunc(elf_file) and !target.isAbs(elf_file)) blk: { |
| 1059 | x86_64.relaxGotpcrelx(code[r_offset - 2 ..]) catch break :blk; | 1065 | x86_64.relaxGotpcrelx(code[r_offset - 2 ..]) catch break :blk; |
| 1060 | try cwriter.writeInt(i32, @as(i32, @intCast(S + A - P)), .little); | 1066 | try cwriter.writeInt(i32, @as(i32, @intCast(S + A - P)), .little); |
| ... | @@ -1063,7 +1069,7 @@ const x86_64 = struct { | ... | @@ -1063,7 +1069,7 @@ const x86_64 = struct { |
| 1063 | try cwriter.writeInt(i32, @as(i32, @intCast(G + GOT + A - P)), .little); | 1069 | try cwriter.writeInt(i32, @as(i32, @intCast(G + GOT + A - P)), .little); |
| 1064 | }, | 1070 | }, |
| 1065 | 1071 | ||
| 1066 | elf.R_X86_64_REX_GOTPCRELX => { | 1072 | .REX_GOTPCRELX => { |
| 1067 | if (!target.flags.import and !target.isIFunc(elf_file) and !target.isAbs(elf_file)) blk: { | 1073 | if (!target.flags.import and !target.isIFunc(elf_file) and !target.isAbs(elf_file)) blk: { |
| 1068 | x86_64.relaxRexGotpcrelx(code[r_offset - 3 ..]) catch break :blk; | 1074 | x86_64.relaxRexGotpcrelx(code[r_offset - 3 ..]) catch break :blk; |
| 1069 | try cwriter.writeInt(i32, @as(i32, @intCast(S + A - P)), .little); | 1075 | try cwriter.writeInt(i32, @as(i32, @intCast(S + A - P)), .little); |
| ... | @@ -1072,16 +1078,16 @@ const x86_64 = struct { | ... | @@ -1072,16 +1078,16 @@ const x86_64 = struct { |
| 1072 | try cwriter.writeInt(i32, @as(i32, @intCast(G + GOT + A - P)), .little); | 1078 | try cwriter.writeInt(i32, @as(i32, @intCast(G + GOT + A - P)), .little); |
| 1073 | }, | 1079 | }, |
| 1074 | 1080 | ||
| 1075 | elf.R_X86_64_32 => try cwriter.writeInt(u32, @as(u32, @truncate(@as(u64, @intCast(S + A)))), .little), | 1081 | .@"32" => try cwriter.writeInt(u32, @as(u32, @truncate(@as(u64, @intCast(S + A)))), .little), |
| 1076 | elf.R_X86_64_32S => try cwriter.writeInt(i32, @as(i32, @truncate(S + A)), .little), | 1082 | .@"32S" => try cwriter.writeInt(i32, @as(i32, @truncate(S + A)), .little), |
| 1077 | 1083 | ||
| 1078 | elf.R_X86_64_TPOFF32 => try cwriter.writeInt(i32, @as(i32, @truncate(S + A - TP)), .little), | 1084 | .TPOFF32 => try cwriter.writeInt(i32, @as(i32, @truncate(S + A - TP)), .little), |
| 1079 | elf.R_X86_64_TPOFF64 => try cwriter.writeInt(i64, S + A - TP, .little), | 1085 | .TPOFF64 => try cwriter.writeInt(i64, S + A - TP, .little), |
| 1080 | 1086 | ||
| 1081 | elf.R_X86_64_DTPOFF32 => try cwriter.writeInt(i32, @as(i32, @truncate(S + A - DTP)), .little), | 1087 | .DTPOFF32 => try cwriter.writeInt(i32, @as(i32, @truncate(S + A - DTP)), .little), |
| 1082 | elf.R_X86_64_DTPOFF64 => try cwriter.writeInt(i64, S + A - DTP, .little), | 1088 | .DTPOFF64 => try cwriter.writeInt(i64, S + A - DTP, .little), |
| 1083 | 1089 | ||
| 1084 | elf.R_X86_64_TLSGD => { | 1090 | .TLSGD => { |
| 1085 | if (target.flags.has_tlsgd) { | 1091 | if (target.flags.has_tlsgd) { |
| 1086 | const S_ = @as(i64, @intCast(target.tlsGdAddress(elf_file))); | 1092 | const S_ = @as(i64, @intCast(target.tlsGdAddress(elf_file))); |
| 1087 | try cwriter.writeInt(i32, @as(i32, @intCast(S_ + A - P)), .little); | 1093 | try cwriter.writeInt(i32, @as(i32, @intCast(S_ + A - P)), .little); |
| ... | @@ -1101,7 +1107,7 @@ const x86_64 = struct { | ... | @@ -1101,7 +1107,7 @@ const x86_64 = struct { |
| 1101 | } | 1107 | } |
| 1102 | }, | 1108 | }, |
| 1103 | 1109 | ||
| 1104 | elf.R_X86_64_TLSLD => { | 1110 | .TLSLD => { |
| 1105 | if (elf_file.got.tlsld_index) |entry_index| { | 1111 | if (elf_file.got.tlsld_index) |entry_index| { |
| 1106 | const tlsld_entry = elf_file.got.entries.items[entry_index]; | 1112 | const tlsld_entry = elf_file.got.entries.items[entry_index]; |
| 1107 | const S_ = @as(i64, @intCast(tlsld_entry.address(elf_file))); | 1113 | const S_ = @as(i64, @intCast(tlsld_entry.address(elf_file))); |
| ... | @@ -1118,7 +1124,7 @@ const x86_64 = struct { | ... | @@ -1118,7 +1124,7 @@ const x86_64 = struct { |
| 1118 | } | 1124 | } |
| 1119 | }, | 1125 | }, |
| 1120 | 1126 | ||
| 1121 | elf.R_X86_64_GOTPC32_TLSDESC => { | 1127 | .GOTPC32_TLSDESC => { |
| 1122 | if (target.flags.has_tlsdesc) { | 1128 | if (target.flags.has_tlsdesc) { |
| 1123 | const S_ = @as(i64, @intCast(target.tlsDescAddress(elf_file))); | 1129 | const S_ = @as(i64, @intCast(target.tlsDescAddress(elf_file))); |
| 1124 | try cwriter.writeInt(i32, @as(i32, @intCast(S_ + A - P)), .little); | 1130 | try cwriter.writeInt(i32, @as(i32, @intCast(S_ + A - P)), .little); |
| ... | @@ -1128,12 +1134,12 @@ const x86_64 = struct { | ... | @@ -1128,12 +1134,12 @@ const x86_64 = struct { |
| 1128 | } | 1134 | } |
| 1129 | }, | 1135 | }, |
| 1130 | 1136 | ||
| 1131 | elf.R_X86_64_TLSDESC_CALL => if (!target.flags.has_tlsdesc) { | 1137 | .TLSDESC_CALL => if (!target.flags.has_tlsdesc) { |
| 1132 | // call -> nop | 1138 | // call -> nop |
| 1133 | try cwriter.writeAll(&.{ 0x66, 0x90 }); | 1139 | try cwriter.writeAll(&.{ 0x66, 0x90 }); |
| 1134 | }, | 1140 | }, |
| 1135 | 1141 | ||
| 1136 | elf.R_X86_64_GOTTPOFF => { | 1142 | .GOTTPOFF => { |
| 1137 | if (target.flags.has_gottp) { | 1143 | if (target.flags.has_gottp) { |
| 1138 | const S_ = @as(i64, @intCast(target.gotTpAddress(elf_file))); | 1144 | const S_ = @as(i64, @intCast(target.gotTpAddress(elf_file))); |
| 1139 | try cwriter.writeInt(i32, @as(i32, @intCast(S_ + A - P)), .little); | 1145 | try cwriter.writeInt(i32, @as(i32, @intCast(S_ + A - P)), .little); |
| ... | @@ -1143,13 +1149,15 @@ const x86_64 = struct { | ... | @@ -1143,13 +1149,15 @@ const x86_64 = struct { |
| 1143 | } | 1149 | } |
| 1144 | }, | 1150 | }, |
| 1145 | 1151 | ||
| 1146 | elf.R_X86_64_GOT32 => try cwriter.writeInt(i32, @as(i32, @intCast(G + GOT + A)), .little), | 1152 | .GOT32 => try cwriter.writeInt(i32, @as(i32, @intCast(G + GOT + A)), .little), |
| 1147 | 1153 | ||
| 1148 | // Zig custom relocations | 1154 | else => |x| switch (@intFromEnum(x)) { |
| 1149 | Elf.R_X86_64_ZIG_GOT32 => try cwriter.writeInt(u32, @as(u32, @intCast(ZIG_GOT + A)), .little), | 1155 | // Zig custom relocations |
| 1150 | Elf.R_X86_64_ZIG_GOTPCREL => try cwriter.writeInt(i32, @as(i32, @intCast(ZIG_GOT + A - P)), .little), | 1156 | Elf.R_ZIG_GOT32 => try cwriter.writeInt(u32, @as(u32, @intCast(ZIG_GOT + A)), .little), |
| 1157 | Elf.R_ZIG_GOTPCREL => try cwriter.writeInt(i32, @as(i32, @intCast(ZIG_GOT + A - P)), .little), | ||
| 1151 | 1158 | ||
| 1152 | else => {}, | 1159 | else => {}, |
| 1160 | }, | ||
| 1153 | } | 1161 | } |
| 1154 | } | 1162 | } |
| 1155 | } | 1163 | } |
| ... | @@ -1163,8 +1171,8 @@ const x86_64 = struct { | ... | @@ -1163,8 +1171,8 @@ const x86_64 = struct { |
| 1163 | var i: usize = 0; | 1171 | var i: usize = 0; |
| 1164 | while (i < rels.len) : (i += 1) { | 1172 | while (i < rels.len) : (i += 1) { |
| 1165 | const rel = rels[i]; | 1173 | const rel = rels[i]; |
| 1166 | const r_type = rel.r_type(); | 1174 | const r_type: elf.R_X86_64 = @enumFromInt(rel.r_type()); |
| 1167 | if (r_type == elf.R_X86_64_NONE) continue; | 1175 | if (r_type == .NONE) continue; |
| 1168 | 1176 | ||
| 1169 | const r_offset = std.math.cast(usize, rel.r_offset) orelse return error.Overflow; | 1177 | const r_offset = std.math.cast(usize, rel.r_offset) orelse return error.Overflow; |
| 1170 | 1178 | ||
| ... | @@ -1210,8 +1218,8 @@ const x86_64 = struct { | ... | @@ -1210,8 +1218,8 @@ const x86_64 = struct { |
| 1210 | // Address of the dynamic thread pointer. | 1218 | // Address of the dynamic thread pointer. |
| 1211 | const DTP = @as(i64, @intCast(elf_file.dtpAddress())); | 1219 | const DTP = @as(i64, @intCast(elf_file.dtpAddress())); |
| 1212 | 1220 | ||
| 1213 | relocs_log.debug(" {s}: {x}: [{x} => {x}] ({s})", .{ | 1221 | relocs_log.debug(" {}: {x}: [{x} => {x}] ({s})", .{ |
| 1214 | relocation.fmtRelocType(r_type, .x86_64), | 1222 | relocation.fmtRelocType(rel.r_type(), .x86_64), |
| 1215 | rel.r_offset, | 1223 | rel.r_offset, |
| 1216 | P, | 1224 | P, |
| 1217 | S + A, | 1225 | S + A, |
| ... | @@ -1221,21 +1229,21 @@ const x86_64 = struct { | ... | @@ -1221,21 +1229,21 @@ const x86_64 = struct { |
| 1221 | try stream.seekTo(r_offset); | 1229 | try stream.seekTo(r_offset); |
| 1222 | 1230 | ||
| 1223 | switch (r_type) { | 1231 | switch (r_type) { |
| 1224 | elf.R_X86_64_NONE => unreachable, | 1232 | .NONE => unreachable, |
| 1225 | elf.R_X86_64_8 => try cwriter.writeInt(u8, @as(u8, @bitCast(@as(i8, @intCast(S + A)))), .little), | 1233 | .@"8" => try cwriter.writeInt(u8, @as(u8, @bitCast(@as(i8, @intCast(S + A)))), .little), |
| 1226 | elf.R_X86_64_16 => try cwriter.writeInt(u16, @as(u16, @bitCast(@as(i16, @intCast(S + A)))), .little), | 1234 | .@"16" => try cwriter.writeInt(u16, @as(u16, @bitCast(@as(i16, @intCast(S + A)))), .little), |
| 1227 | elf.R_X86_64_32 => try cwriter.writeInt(u32, @as(u32, @bitCast(@as(i32, @intCast(S + A)))), .little), | 1235 | .@"32" => try cwriter.writeInt(u32, @as(u32, @bitCast(@as(i32, @intCast(S + A)))), .little), |
| 1228 | elf.R_X86_64_32S => try cwriter.writeInt(i32, @as(i32, @intCast(S + A)), .little), | 1236 | .@"32S" => try cwriter.writeInt(i32, @as(i32, @intCast(S + A)), .little), |
| 1229 | elf.R_X86_64_64 => try cwriter.writeInt(i64, S + A, .little), | 1237 | .@"64" => try cwriter.writeInt(i64, S + A, .little), |
| 1230 | elf.R_X86_64_DTPOFF32 => try cwriter.writeInt(i32, @as(i32, @intCast(S + A - DTP)), .little), | 1238 | .DTPOFF32 => try cwriter.writeInt(i32, @as(i32, @intCast(S + A - DTP)), .little), |
| 1231 | elf.R_X86_64_DTPOFF64 => try cwriter.writeInt(i64, S + A - DTP, .little), | 1239 | .DTPOFF64 => try cwriter.writeInt(i64, S + A - DTP, .little), |
| 1232 | elf.R_X86_64_GOTOFF64 => try cwriter.writeInt(i64, S + A - GOT, .little), | 1240 | .GOTOFF64 => try cwriter.writeInt(i64, S + A - GOT, .little), |
| 1233 | elf.R_X86_64_GOTPC64 => try cwriter.writeInt(i64, GOT + A, .little), | 1241 | .GOTPC64 => try cwriter.writeInt(i64, GOT + A, .little), |
| 1234 | elf.R_X86_64_SIZE32 => { | 1242 | .SIZE32 => { |
| 1235 | const size = @as(i64, @intCast(target.elfSym(elf_file).st_size)); | 1243 | const size = @as(i64, @intCast(target.elfSym(elf_file).st_size)); |
| 1236 | try cwriter.writeInt(u32, @as(u32, @bitCast(@as(i32, @intCast(size + A)))), .little); | 1244 | try cwriter.writeInt(u32, @as(u32, @bitCast(@as(i32, @intCast(size + A)))), .little); |
| 1237 | }, | 1245 | }, |
| 1238 | elf.R_X86_64_SIZE64 => { | 1246 | .SIZE64 => { |
| 1239 | const size = @as(i64, @intCast(target.elfSym(elf_file).st_size)); | 1247 | const size = @as(i64, @intCast(target.elfSym(elf_file).st_size)); |
| 1240 | try cwriter.writeInt(i64, @as(i64, @intCast(size + A)), .little); | 1248 | try cwriter.writeInt(i64, @as(i64, @intCast(size + A)), .little); |
| 1241 | }, | 1249 | }, |
| ... | @@ -1283,9 +1291,10 @@ const x86_64 = struct { | ... | @@ -1283,9 +1291,10 @@ const x86_64 = struct { |
| 1283 | ) !void { | 1291 | ) !void { |
| 1284 | assert(rels.len == 2); | 1292 | assert(rels.len == 2); |
| 1285 | const writer = stream.writer(); | 1293 | const writer = stream.writer(); |
| 1286 | switch (rels[1].r_type()) { | 1294 | const rel: elf.R_X86_64 = @enumFromInt(rels[1].r_type()); |
| 1287 | elf.R_X86_64_PC32, | 1295 | switch (rel) { |
| 1288 | elf.R_X86_64_PLT32, | 1296 | .PC32, |
| 1297 | .PLT32, | ||
| 1289 | => { | 1298 | => { |
| 1290 | var insts = [_]u8{ | 1299 | var insts = [_]u8{ |
| 1291 | 0x64, 0x48, 0x8b, 0x04, 0x25, 0, 0, 0, 0, // movq %fs:0,%rax | 1300 | 0x64, 0x48, 0x8b, 0x04, 0x25, 0, 0, 0, 0, // movq %fs:0,%rax |
| ... | @@ -1320,9 +1329,10 @@ const x86_64 = struct { | ... | @@ -1320,9 +1329,10 @@ const x86_64 = struct { |
| 1320 | ) !void { | 1329 | ) !void { |
| 1321 | assert(rels.len == 2); | 1330 | assert(rels.len == 2); |
| 1322 | const writer = stream.writer(); | 1331 | const writer = stream.writer(); |
| 1323 | switch (rels[1].r_type()) { | 1332 | const rel: elf.R_X86_64 = @enumFromInt(rels[1].r_type()); |
| 1324 | elf.R_X86_64_PC32, | 1333 | switch (rel) { |
| 1325 | elf.R_X86_64_PLT32, | 1334 | .PC32, |
| 1335 | .PLT32, | ||
| 1326 | => { | 1336 | => { |
| 1327 | var insts = [_]u8{ | 1337 | var insts = [_]u8{ |
| 1328 | 0x31, 0xc0, // xor %eax, %eax | 1338 | 0x31, 0xc0, // xor %eax, %eax |
| ... | @@ -1334,8 +1344,8 @@ const x86_64 = struct { | ... | @@ -1334,8 +1344,8 @@ const x86_64 = struct { |
| 1334 | try writer.writeAll(&insts); | 1344 | try writer.writeAll(&insts); |
| 1335 | }, | 1345 | }, |
| 1336 | 1346 | ||
| 1337 | elf.R_X86_64_GOTPCREL, | 1347 | .GOTPCREL, |
| 1338 | elf.R_X86_64_GOTPCRELX, | 1348 | .GOTPCRELX, |
| 1339 | => { | 1349 | => { |
| 1340 | var insts = [_]u8{ | 1350 | var insts = [_]u8{ |
| 1341 | 0x31, 0xc0, // xor %eax, %eax | 1351 | 0x31, 0xc0, // xor %eax, %eax |
| ... | @@ -1419,11 +1429,12 @@ const x86_64 = struct { | ... | @@ -1419,11 +1429,12 @@ const x86_64 = struct { |
| 1419 | ) !void { | 1429 | ) !void { |
| 1420 | assert(rels.len == 2); | 1430 | assert(rels.len == 2); |
| 1421 | const writer = stream.writer(); | 1431 | const writer = stream.writer(); |
| 1422 | switch (rels[1].r_type()) { | 1432 | const rel: elf.R_X86_64 = @enumFromInt(rels[1].r_type()); |
| 1423 | elf.R_X86_64_PC32, | 1433 | switch (rel) { |
| 1424 | elf.R_X86_64_PLT32, | 1434 | .PC32, |
| 1425 | elf.R_X86_64_GOTPCREL, | 1435 | .PLT32, |
| 1426 | elf.R_X86_64_GOTPCRELX, | 1436 | .GOTPCREL, |
| 1437 | .GOTPCRELX, | ||
| 1427 | => { | 1438 | => { |
| 1428 | var insts = [_]u8{ | 1439 | var insts = [_]u8{ |
| 1429 | 0x64, 0x48, 0x8b, 0x04, 0x25, 0, 0, 0, 0, // movq %fs:0,%rax | 1440 | 0x64, 0x48, 0x8b, 0x04, 0x25, 0, 0, 0, 0, // movq %fs:0,%rax |
src/link/Elf/eh_frame.zig+6-5| ... | @@ -541,11 +541,12 @@ const EH_PE = struct { | ... | @@ -541,11 +541,12 @@ const EH_PE = struct { |
| 541 | 541 | ||
| 542 | const x86_64 = struct { | 542 | const x86_64 = struct { |
| 543 | fn resolveReloc(rel: elf.Elf64_Rela, source: i64, target: i64, data: []u8) void { | 543 | fn resolveReloc(rel: elf.Elf64_Rela, source: i64, target: i64, data: []u8) void { |
| 544 | switch (rel.r_type()) { | 544 | const r_type: elf.R_X86_64 = @enumFromInt(rel.r_type()); |
| 545 | elf.R_X86_64_32 => std.mem.writeInt(i32, data[0..4], @as(i32, @truncate(target)), .little), | 545 | switch (r_type) { |
| 546 | elf.R_X86_64_64 => std.mem.writeInt(i64, data[0..8], target, .little), | 546 | .@"32" => std.mem.writeInt(i32, data[0..4], @as(i32, @truncate(target)), .little), |
| 547 | elf.R_X86_64_PC32 => std.mem.writeInt(i32, data[0..4], @as(i32, @intCast(target - source)), .little), | 547 | .@"64" => std.mem.writeInt(i64, data[0..8], target, .little), |
| 548 | elf.R_X86_64_PC64 => std.mem.writeInt(i64, data[0..8], target - source, .little), | 548 | .PC32 => std.mem.writeInt(i32, data[0..4], @as(i32, @intCast(target - source)), .little), |
| 549 | .PC64 => std.mem.writeInt(i64, data[0..8], target - source, .little), | ||
| 549 | else => unreachable, | 550 | else => unreachable, |
| 550 | } | 551 | } |
| 551 | } | 552 | } |
src/link/Elf/relocation.zig+73-212| ... | @@ -11,54 +11,78 @@ pub const Kind = enum { | ... | @@ -11,54 +11,78 @@ pub const Kind = enum { |
| 11 | tlsdesc, | 11 | tlsdesc, |
| 12 | }; | 12 | }; |
| 13 | 13 | ||
| 14 | const x86_64_relocs = [_]struct { Kind, u32 }{ | 14 | fn Table(comptime len: comptime_int, comptime RelType: type, comptime mapping: [len]struct { Kind, RelType }) type { |
| 15 | .{ .abs, elf.R_X86_64_64 }, | 15 | return struct { |
| 16 | .{ .copy, elf.R_X86_64_COPY }, | 16 | fn decode(r_type: u32) ?Kind { |
| 17 | .{ .rel, elf.R_X86_64_RELATIVE }, | 17 | inline for (mapping) |entry| { |
| 18 | .{ .irel, elf.R_X86_64_IRELATIVE }, | 18 | if (@intFromEnum(entry[1]) == r_type) return entry[0]; |
| 19 | .{ .glob_dat, elf.R_X86_64_GLOB_DAT }, | 19 | } |
| 20 | .{ .jump_slot, elf.R_X86_64_JUMP_SLOT }, | 20 | return null; |
| 21 | .{ .dtpmod, elf.R_X86_64_DTPMOD64 }, | 21 | } |
| 22 | .{ .dtpoff, elf.R_X86_64_DTPOFF64 }, | ||
| 23 | .{ .tpoff, elf.R_X86_64_TPOFF64 }, | ||
| 24 | .{ .tlsdesc, elf.R_X86_64_TLSDESC }, | ||
| 25 | }; | ||
| 26 | 22 | ||
| 27 | const aarch64_relocs = [_]struct { Kind, u32 }{ | 23 | fn encode(comptime kind: Kind) u32 { |
| 28 | .{ .abs, elf.R_AARCH64_ABS64 }, | 24 | inline for (mapping) |entry| { |
| 29 | .{ .copy, elf.R_AARCH64_COPY }, | 25 | if (entry[0] == kind) return @intFromEnum(entry[1]); |
| 30 | .{ .rel, elf.R_AARCH64_RELATIVE }, | 26 | } |
| 31 | .{ .irel, elf.R_AARCH64_IRELATIVE }, | 27 | unreachable; |
| 32 | .{ .glob_dat, elf.R_AARCH64_GLOB_DAT }, | 28 | } |
| 33 | .{ .jump_slot, elf.R_AARCH64_JUMP_SLOT }, | 29 | }; |
| 34 | .{ .dtpmod, elf.R_AARCH64_TLS_DTPMOD }, | 30 | } |
| 35 | .{ .dtpoff, elf.R_AARCH64_TLS_DTPREL }, | 31 | |
| 36 | .{ .tpoff, elf.R_AARCH64_TLS_TPREL }, | 32 | const x86_64_relocs = Table(10, elf.R_X86_64, .{ |
| 37 | .{ .tlsdesc, elf.R_AARCH64_TLSDESC }, | 33 | .{ .abs, .@"64" }, |
| 38 | }; | 34 | .{ .copy, .COPY }, |
| 35 | .{ .rel, .RELATIVE }, | ||
| 36 | .{ .irel, .IRELATIVE }, | ||
| 37 | .{ .glob_dat, .GLOB_DAT }, | ||
| 38 | .{ .jump_slot, .JUMP_SLOT }, | ||
| 39 | .{ .dtpmod, .DTPMOD64 }, | ||
| 40 | .{ .dtpoff, .DTPOFF64 }, | ||
| 41 | .{ .tpoff, .TPOFF64 }, | ||
| 42 | .{ .tlsdesc, .TLSDESC }, | ||
| 43 | }); | ||
| 44 | |||
| 45 | const aarch64_relocs = Table(10, elf.R_AARCH64, .{ | ||
| 46 | .{ .abs, .ABS64 }, | ||
| 47 | .{ .copy, .COPY }, | ||
| 48 | .{ .rel, .RELATIVE }, | ||
| 49 | .{ .irel, .IRELATIVE }, | ||
| 50 | .{ .glob_dat, .GLOB_DAT }, | ||
| 51 | .{ .jump_slot, .JUMP_SLOT }, | ||
| 52 | .{ .dtpmod, .TLS_DTPMOD }, | ||
| 53 | .{ .dtpoff, .TLS_DTPREL }, | ||
| 54 | .{ .tpoff, .TLS_TPREL }, | ||
| 55 | .{ .tlsdesc, .TLSDESC }, | ||
| 56 | }); | ||
| 57 | |||
| 58 | const riscv64_relocs = Table(9, elf.R_RISCV, .{ | ||
| 59 | .{ .abs, .@"64" }, | ||
| 60 | .{ .copy, .COPY }, | ||
| 61 | .{ .rel, .RELATIVE }, | ||
| 62 | .{ .irel, .IRELATIVE }, | ||
| 63 | .{ .jump_slot, .JUMP_SLOT }, | ||
| 64 | .{ .dtpmod, .TLS_DTPMOD64 }, | ||
| 65 | .{ .dtpoff, .TLS_DTPREL64 }, | ||
| 66 | .{ .tpoff, .TLS_TPREL64 }, | ||
| 67 | .{ .tlsdesc, .TLSDESC }, | ||
| 68 | }); | ||
| 39 | 69 | ||
| 40 | pub fn decode(r_type: u32, cpu_arch: std.Target.Cpu.Arch) ?Kind { | 70 | pub fn decode(r_type: u32, cpu_arch: std.Target.Cpu.Arch) ?Kind { |
| 41 | const relocs = switch (cpu_arch) { | 71 | return switch (cpu_arch) { |
| 42 | .x86_64 => &x86_64_relocs, | 72 | .x86_64 => x86_64_relocs.decode(r_type), |
| 43 | .aarch64 => &aarch64_relocs, | 73 | .aarch64 => aarch64_relocs.decode(r_type), |
| 74 | .riscv64 => riscv64_relocs.decode(r_type), | ||
| 44 | else => @panic("TODO unhandled cpu arch"), | 75 | else => @panic("TODO unhandled cpu arch"), |
| 45 | }; | 76 | }; |
| 46 | inline for (relocs) |entry| { | ||
| 47 | if (entry[1] == r_type) return entry[0]; | ||
| 48 | } | ||
| 49 | return null; | ||
| 50 | } | 77 | } |
| 51 | 78 | ||
| 52 | pub fn encode(comptime kind: Kind, cpu_arch: std.Target.Cpu.Arch) u32 { | 79 | pub fn encode(comptime kind: Kind, cpu_arch: std.Target.Cpu.Arch) u32 { |
| 53 | const relocs = switch (cpu_arch) { | 80 | return switch (cpu_arch) { |
| 54 | .x86_64 => &x86_64_relocs, | 81 | .x86_64 => x86_64_relocs.encode(kind), |
| 55 | .aarch64 => &aarch64_relocs, | 82 | .aarch64 => aarch64_relocs.encode(kind), |
| 83 | .riscv64 => riscv64_relocs.encode(kind), | ||
| 56 | else => @panic("TODO unhandled cpu arch"), | 84 | else => @panic("TODO unhandled cpu arch"), |
| 57 | }; | 85 | }; |
| 58 | inline for (relocs) |entry| { | ||
| 59 | if (entry[0] == kind) return entry[1]; | ||
| 60 | } | ||
| 61 | unreachable; | ||
| 62 | } | 86 | } |
| 63 | 87 | ||
| 64 | const FormatRelocTypeCtx = struct { | 88 | const FormatRelocTypeCtx = struct { |
| ... | @@ -82,183 +106,20 @@ fn formatRelocType( | ... | @@ -82,183 +106,20 @@ fn formatRelocType( |
| 82 | _ = unused_fmt_string; | 106 | _ = unused_fmt_string; |
| 83 | _ = options; | 107 | _ = options; |
| 84 | const r_type = ctx.r_type; | 108 | const r_type = ctx.r_type; |
| 85 | const str = switch (ctx.cpu_arch) { | 109 | switch (r_type) { |
| 86 | .x86_64 => switch (r_type) { | 110 | Elf.R_ZIG_GOT32 => try writer.writeAll("R_ZIG_GOT32"), |
| 87 | elf.R_X86_64_NONE => "R_X86_64_NONE", | 111 | Elf.R_ZIG_GOTPCREL => try writer.writeAll("R_ZIG_GOTPCREL"), |
| 88 | elf.R_X86_64_64 => "R_X86_64_64", | 112 | else => switch (ctx.cpu_arch) { |
| 89 | elf.R_X86_64_PC32 => "R_X86_64_PC32", | 113 | .x86_64 => try writer.print("R_X86_64_{s}", .{@tagName(@as(elf.R_X86_64, @enumFromInt(r_type)))}), |
| 90 | elf.R_X86_64_GOT32 => "R_X86_64_GOT32", | 114 | .aarch64 => try writer.print("R_AARCH64_{s}", .{@tagName(@as(elf.R_AARCH64, @enumFromInt(r_type)))}), |
| 91 | elf.R_X86_64_PLT32 => "R_X86_64_PLT32", | 115 | .riscv64 => try writer.print("R_RISCV_{s}", .{@tagName(@as(elf.R_RISCV, @enumFromInt(r_type)))}), |
| 92 | elf.R_X86_64_COPY => "R_X86_64_COPY", | 116 | else => unreachable, |
| 93 | elf.R_X86_64_GLOB_DAT => "R_X86_64_GLOB_DAT", | ||
| 94 | elf.R_X86_64_JUMP_SLOT => "R_X86_64_JUMP_SLOT", | ||
| 95 | elf.R_X86_64_RELATIVE => "R_X86_64_RELATIVE", | ||
| 96 | elf.R_X86_64_GOTPCREL => "R_X86_64_GOTPCREL", | ||
| 97 | elf.R_X86_64_32 => "R_X86_64_32", | ||
| 98 | elf.R_X86_64_32S => "R_X86_64_32S", | ||
| 99 | elf.R_X86_64_16 => "R_X86_64_16", | ||
| 100 | elf.R_X86_64_PC16 => "R_X86_64_PC16", | ||
| 101 | elf.R_X86_64_8 => "R_X86_64_8", | ||
| 102 | elf.R_X86_64_PC8 => "R_X86_64_PC8", | ||
| 103 | elf.R_X86_64_DTPMOD64 => "R_X86_64_DTPMOD64", | ||
| 104 | elf.R_X86_64_DTPOFF64 => "R_X86_64_DTPOFF64", | ||
| 105 | elf.R_X86_64_TPOFF64 => "R_X86_64_TPOFF64", | ||
| 106 | elf.R_X86_64_TLSGD => "R_X86_64_TLSGD", | ||
| 107 | elf.R_X86_64_TLSLD => "R_X86_64_TLSLD", | ||
| 108 | elf.R_X86_64_DTPOFF32 => "R_X86_64_DTPOFF32", | ||
| 109 | elf.R_X86_64_GOTTPOFF => "R_X86_64_GOTTPOFF", | ||
| 110 | elf.R_X86_64_TPOFF32 => "R_X86_64_TPOFF32", | ||
| 111 | elf.R_X86_64_PC64 => "R_X86_64_PC64", | ||
| 112 | elf.R_X86_64_GOTOFF64 => "R_X86_64_GOTOFF64", | ||
| 113 | elf.R_X86_64_GOTPC32 => "R_X86_64_GOTPC32", | ||
| 114 | elf.R_X86_64_GOT64 => "R_X86_64_GOT64", | ||
| 115 | elf.R_X86_64_GOTPCREL64 => "R_X86_64_GOTPCREL64", | ||
| 116 | elf.R_X86_64_GOTPC64 => "R_X86_64_GOTPC64", | ||
| 117 | elf.R_X86_64_GOTPLT64 => "R_X86_64_GOTPLT64", | ||
| 118 | elf.R_X86_64_PLTOFF64 => "R_X86_64_PLTOFF64", | ||
| 119 | elf.R_X86_64_SIZE32 => "R_X86_64_SIZE32", | ||
| 120 | elf.R_X86_64_SIZE64 => "R_X86_64_SIZE64", | ||
| 121 | elf.R_X86_64_GOTPC32_TLSDESC => "R_X86_64_GOTPC32_TLSDESC", | ||
| 122 | elf.R_X86_64_TLSDESC_CALL => "R_X86_64_TLSDESC_CALL", | ||
| 123 | elf.R_X86_64_TLSDESC => "R_X86_64_TLSDESC", | ||
| 124 | elf.R_X86_64_IRELATIVE => "R_X86_64_IRELATIVE", | ||
| 125 | elf.R_X86_64_RELATIVE64 => "R_X86_64_RELATIVE64", | ||
| 126 | elf.R_X86_64_GOTPCRELX => "R_X86_64_GOTPCRELX", | ||
| 127 | elf.R_X86_64_REX_GOTPCRELX => "R_X86_64_REX_GOTPCRELX", | ||
| 128 | elf.R_X86_64_NUM => "R_X86_64_NUM", | ||
| 129 | else => "R_X86_64_UNKNOWN", | ||
| 130 | }, | ||
| 131 | .aarch64 => switch (r_type) { | ||
| 132 | elf.R_AARCH64_NONE => "R_AARCH64_NONE", | ||
| 133 | elf.R_AARCH64_ABS64 => "R_AARCH64_ABS64", | ||
| 134 | elf.R_AARCH64_ABS32 => "R_AARCH64_ABS32", | ||
| 135 | elf.R_AARCH64_ABS16 => "R_AARCH64_ABS16", | ||
| 136 | elf.R_AARCH64_PREL64 => "R_AARCH64_PREL64", | ||
| 137 | elf.R_AARCH64_PREL32 => "R_AARCH64_PREL32", | ||
| 138 | elf.R_AARCH64_PREL16 => "R_AARCH64_PREL16", | ||
| 139 | elf.R_AARCH64_MOVW_UABS_G0 => "R_AARCH64_MOVW_UABS_G0", | ||
| 140 | elf.R_AARCH64_MOVW_UABS_G0_NC => "R_AARCH64_MOVW_UABS_G0_NC", | ||
| 141 | elf.R_AARCH64_MOVW_UABS_G1 => "R_AARCH64_MOVW_UABS_G1", | ||
| 142 | elf.R_AARCH64_MOVW_UABS_G1_NC => "R_AARCH64_MOVW_UABS_G1_NC", | ||
| 143 | elf.R_AARCH64_MOVW_UABS_G2 => "R_AARCH64_MOVW_UABS_G2", | ||
| 144 | elf.R_AARCH64_MOVW_UABS_G2_NC => "R_AARCH64_MOVW_UABS_G2_NC", | ||
| 145 | elf.R_AARCH64_MOVW_UABS_G3 => "R_AARCH64_MOVW_UABS_G3", | ||
| 146 | elf.R_AARCH64_MOVW_SABS_G0 => "R_AARCH64_MOVW_SABS_G0", | ||
| 147 | elf.R_AARCH64_MOVW_SABS_G1 => "R_AARCH64_MOVW_SABS_G1", | ||
| 148 | elf.R_AARCH64_MOVW_SABS_G2 => "R_AARCH64_MOVW_SABS_G2", | ||
| 149 | elf.R_AARCH64_LD_PREL_LO19 => "R_AARCH64_LD_PREL_LO19", | ||
| 150 | elf.R_AARCH64_ADR_PREL_LO21 => "R_AARCH64_ADR_PREL_LO21", | ||
| 151 | elf.R_AARCH64_ADR_PREL_PG_HI21 => "R_AARCH64_ADR_PREL_PG_HI21", | ||
| 152 | elf.R_AARCH64_ADR_PREL_PG_HI21_NC => "R_AARCH64_ADR_PREL_PG_HI21_NC", | ||
| 153 | elf.R_AARCH64_ADD_ABS_LO12_NC => "R_AARCH64_ADD_ABS_LO12_NC", | ||
| 154 | elf.R_AARCH64_LDST8_ABS_LO12_NC => "R_AARCH64_LDST8_ABS_LO12_NC", | ||
| 155 | elf.R_AARCH64_TSTBR14 => "R_AARCH64_TSTBR14", | ||
| 156 | elf.R_AARCH64_CONDBR19 => "R_AARCH64_CONDBR19", | ||
| 157 | elf.R_AARCH64_JUMP26 => "R_AARCH64_JUMP26", | ||
| 158 | elf.R_AARCH64_CALL26 => "R_AARCH64_CALL26", | ||
| 159 | elf.R_AARCH64_LDST16_ABS_LO12_NC => "R_AARCH64_LDST16_ABS_LO12_NC", | ||
| 160 | elf.R_AARCH64_LDST32_ABS_LO12_NC => "R_AARCH64_LDST32_ABS_LO12_NC", | ||
| 161 | elf.R_AARCH64_LDST64_ABS_LO12_NC => "R_AARCH64_LDST64_ABS_LO12_NC", | ||
| 162 | elf.R_AARCH64_MOVW_PREL_G0 => "R_AARCH64_MOVW_PREL_G0", | ||
| 163 | elf.R_AARCH64_MOVW_PREL_G0_NC => "R_AARCH64_MOVW_PREL_G0_NC", | ||
| 164 | elf.R_AARCH64_MOVW_PREL_G1 => "R_AARCH64_MOVW_PREL_G1", | ||
| 165 | elf.R_AARCH64_MOVW_PREL_G1_NC => "R_AARCH64_MOVW_PREL_G1_NC", | ||
| 166 | elf.R_AARCH64_MOVW_PREL_G2 => "R_AARCH64_MOVW_PREL_G2", | ||
| 167 | elf.R_AARCH64_MOVW_PREL_G2_NC => "R_AARCH64_MOVW_PREL_G2_NC", | ||
| 168 | elf.R_AARCH64_MOVW_PREL_G3 => "R_AARCH64_MOVW_PREL_G3", | ||
| 169 | elf.R_AARCH64_LDST128_ABS_LO12_NC => "R_AARCH64_LDST128_ABS_LO12_NC", | ||
| 170 | elf.R_AARCH64_MOVW_GOTOFF_G0 => "R_AARCH64_MOVW_GOTOFF_G0", | ||
| 171 | elf.R_AARCH64_MOVW_GOTOFF_G0_NC => "R_AARCH64_MOVW_GOTOFF_G0_NC", | ||
| 172 | elf.R_AARCH64_MOVW_GOTOFF_G1 => "R_AARCH64_MOVW_GOTOFF_G1", | ||
| 173 | elf.R_AARCH64_MOVW_GOTOFF_G1_NC => "R_AARCH64_MOVW_GOTOFF_G1_NC", | ||
| 174 | elf.R_AARCH64_MOVW_GOTOFF_G2 => "R_AARCH64_MOVW_GOTOFF_G2", | ||
| 175 | elf.R_AARCH64_MOVW_GOTOFF_G2_NC => "R_AARCH64_MOVW_GOTOFF_G2_NC", | ||
| 176 | elf.R_AARCH64_MOVW_GOTOFF_G3 => "R_AARCH64_MOVW_GOTOFF_G3", | ||
| 177 | elf.R_AARCH64_GOTREL64 => "R_AARCH64_GOTREL64", | ||
| 178 | elf.R_AARCH64_GOTREL32 => "R_AARCH64_GOTREL32", | ||
| 179 | elf.R_AARCH64_GOT_LD_PREL19 => "R_AARCH64_GOT_LD_PREL19", | ||
| 180 | elf.R_AARCH64_LD64_GOTOFF_LO15 => "R_AARCH64_LD64_GOTOFF_LO15", | ||
| 181 | elf.R_AARCH64_ADR_GOT_PAGE => "R_AARCH64_ADR_GOT_PAGE", | ||
| 182 | elf.R_AARCH64_LD64_GOT_LO12_NC => "R_AARCH64_LD64_GOT_LO12_NC", | ||
| 183 | elf.R_AARCH64_LD64_GOTPAGE_LO15 => "R_AARCH64_LD64_GOTPAGE_LO15", | ||
| 184 | elf.R_AARCH64_TLSGD_ADR_PREL21 => "R_AARCH64_TLSGD_ADR_PREL21", | ||
| 185 | elf.R_AARCH64_TLSGD_ADR_PAGE21 => "R_AARCH64_TLSGD_ADR_PAGE21", | ||
| 186 | elf.R_AARCH64_TLSGD_ADD_LO12_NC => "R_AARCH64_TLSGD_ADD_LO12_NC", | ||
| 187 | elf.R_AARCH64_TLSGD_MOVW_G1 => "R_AARCH64_TLSGD_MOVW_G1", | ||
| 188 | elf.R_AARCH64_TLSGD_MOVW_G0_NC => "R_AARCH64_TLSGD_MOVW_G0_NC", | ||
| 189 | elf.R_AARCH64_TLSLD_ADR_PREL21 => "R_AARCH64_TLSLD_ADR_PREL21", | ||
| 190 | elf.R_AARCH64_TLSLD_ADR_PAGE21 => "R_AARCH64_TLSLD_ADR_PAGE21", | ||
| 191 | elf.R_AARCH64_TLSLD_ADD_LO12_NC => "R_AARCH64_TLSLD_ADD_LO12_NC", | ||
| 192 | elf.R_AARCH64_TLSLD_MOVW_G1 => "R_AARCH64_TLSLD_MOVW_G1", | ||
| 193 | elf.R_AARCH64_TLSLD_MOVW_G0_NC => "R_AARCH64_TLSLD_MOVW_G0_NC", | ||
| 194 | elf.R_AARCH64_TLSLD_LD_PREL19 => "R_AARCH64_TLSLD_LD_PREL19", | ||
| 195 | elf.R_AARCH64_TLSLD_MOVW_DTPREL_G2 => "R_AARCH64_TLSLD_MOVW_DTPREL_G2", | ||
| 196 | elf.R_AARCH64_TLSLD_MOVW_DTPREL_G1 => "R_AARCH64_TLSLD_MOVW_DTPREL_G1", | ||
| 197 | elf.R_AARCH64_TLSLD_MOVW_DTPREL_G1_NC => "R_AARCH64_TLSLD_MOVW_DTPREL_G1_NC", | ||
| 198 | elf.R_AARCH64_TLSLD_MOVW_DTPREL_G0 => "R_AARCH64_TLSLD_MOVW_DTPREL_G0", | ||
| 199 | elf.R_AARCH64_TLSLD_MOVW_DTPREL_G0_NC => "R_AARCH64_TLSLD_MOVW_DTPREL_G0_NC", | ||
| 200 | elf.R_AARCH64_TLSLD_ADD_DTPREL_HI12 => "R_AARCH64_TLSLD_ADD_DTPREL_HI12", | ||
| 201 | elf.R_AARCH64_TLSLD_ADD_DTPREL_LO12 => "R_AARCH64_TLSLD_ADD_DTPREL_LO12", | ||
| 202 | elf.R_AARCH64_TLSLD_ADD_DTPREL_LO12_NC => "R_AARCH64_TLSLD_ADD_DTPREL_LO12_NC", | ||
| 203 | elf.R_AARCH64_TLSLD_LDST8_DTPREL_LO12 => "R_AARCH64_TLSLD_LDST8_DTPREL_LO12", | ||
| 204 | elf.R_AARCH64_TLSLD_LDST8_DTPREL_LO12_NC => "R_AARCH64_TLSLD_LDST8_DTPREL_LO12_NC", | ||
| 205 | elf.R_AARCH64_TLSLD_LDST16_DTPREL_LO12 => "R_AARCH64_TLSLD_LDST16_DTPREL_LO12", | ||
| 206 | elf.R_AARCH64_TLSLD_LDST16_DTPREL_LO12_NC => "R_AARCH64_TLSLD_LDST16_DTPREL_LO12_NC", | ||
| 207 | elf.R_AARCH64_TLSLD_LDST32_DTPREL_LO12 => "R_AARCH64_TLSLD_LDST32_DTPREL_LO12", | ||
| 208 | elf.R_AARCH64_TLSLD_LDST32_DTPREL_LO12_NC => "R_AARCH64_TLSLD_LDST32_DTPREL_LO12_NC", | ||
| 209 | elf.R_AARCH64_TLSLD_LDST64_DTPREL_LO12 => "R_AARCH64_TLSLD_LDST64_DTPREL_LO12", | ||
| 210 | elf.R_AARCH64_TLSLD_LDST64_DTPREL_LO12_NC => "R_AARCH64_TLSLD_LDST64_DTPREL_LO12_NC", | ||
| 211 | elf.R_AARCH64_TLSIE_MOVW_GOTTPREL_G1 => "R_AARCH64_TLSIE_MOVW_GOTTPREL_G1", | ||
| 212 | elf.R_AARCH64_TLSIE_MOVW_GOTTPREL_G0_NC => "R_AARCH64_TLSIE_MOVW_GOTTPREL_G0_NC", | ||
| 213 | elf.R_AARCH64_TLSIE_ADR_GOTTPREL_PAGE21 => "R_AARCH64_TLSIE_ADR_GOTTPREL_PAGE21", | ||
| 214 | elf.R_AARCH64_TLSIE_LD64_GOTTPREL_LO12_NC => "R_AARCH64_TLSIE_LD64_GOTTPREL_LO12_NC", | ||
| 215 | elf.R_AARCH64_TLSIE_LD_GOTTPREL_PREL19 => "R_AARCH64_TLSIE_LD_GOTTPREL_PREL19", | ||
| 216 | elf.R_AARCH64_TLSLE_MOVW_TPREL_G2 => "R_AARCH64_TLSLE_MOVW_TPREL_G2", | ||
| 217 | elf.R_AARCH64_TLSLE_MOVW_TPREL_G1 => "R_AARCH64_TLSLE_MOVW_TPREL_G1", | ||
| 218 | elf.R_AARCH64_TLSLE_MOVW_TPREL_G1_NC => "R_AARCH64_TLSLE_MOVW_TPREL_G1_NC", | ||
| 219 | elf.R_AARCH64_TLSLE_MOVW_TPREL_G0 => "R_AARCH64_TLSLE_MOVW_TPREL_G0", | ||
| 220 | elf.R_AARCH64_TLSLE_MOVW_TPREL_G0_NC => "R_AARCH64_TLSLE_MOVW_TPREL_G0_NC", | ||
| 221 | elf.R_AARCH64_TLSLE_ADD_TPREL_HI12 => "R_AARCH64_TLSLE_ADD_TPREL_HI12", | ||
| 222 | elf.R_AARCH64_TLSLE_ADD_TPREL_LO12 => "R_AARCH64_TLSLE_ADD_TPREL_LO12", | ||
| 223 | elf.R_AARCH64_TLSLE_ADD_TPREL_LO12_NC => "R_AARCH64_TLSLE_ADD_TPREL_LO12_NC", | ||
| 224 | elf.R_AARCH64_TLSLE_LDST8_TPREL_LO12 => "R_AARCH64_TLSLE_LDST8_TPREL_LO12", | ||
| 225 | elf.R_AARCH64_TLSLE_LDST8_TPREL_LO12_NC => "R_AARCH64_TLSLE_LDST8_TPREL_LO12_NC", | ||
| 226 | elf.R_AARCH64_TLSLE_LDST16_TPREL_LO12 => "R_AARCH64_TLSLE_LDST16_TPREL_LO12", | ||
| 227 | elf.R_AARCH64_TLSLE_LDST16_TPREL_LO12_NC => "R_AARCH64_TLSLE_LDST16_TPREL_LO12_NC", | ||
| 228 | elf.R_AARCH64_TLSLE_LDST32_TPREL_LO12 => "R_AARCH64_TLSLE_LDST32_TPREL_LO12", | ||
| 229 | elf.R_AARCH64_TLSLE_LDST32_TPREL_LO12_NC => "R_AARCH64_TLSLE_LDST32_TPREL_LO12_NC", | ||
| 230 | elf.R_AARCH64_TLSLE_LDST64_TPREL_LO12 => "R_AARCH64_TLSLE_LDST64_TPREL_LO12", | ||
| 231 | elf.R_AARCH64_TLSLE_LDST64_TPREL_LO12_NC => "R_AARCH64_TLSLE_LDST64_TPREL_LO12_NC", | ||
| 232 | elf.R_AARCH64_TLSDESC_LD_PREL19 => "R_AARCH64_TLSDESC_LD_PREL19", | ||
| 233 | elf.R_AARCH64_TLSDESC_ADR_PREL21 => "R_AARCH64_TLSDESC_ADR_PREL21", | ||
| 234 | elf.R_AARCH64_TLSDESC_ADR_PAGE21 => "R_AARCH64_TLSDESC_ADR_PAGE21", | ||
| 235 | elf.R_AARCH64_TLSDESC_LD64_LO12 => "R_AARCH64_TLSDESC_LD64_LO12", | ||
| 236 | elf.R_AARCH64_TLSDESC_ADD_LO12 => "R_AARCH64_TLSDESC_ADD_LO12", | ||
| 237 | elf.R_AARCH64_TLSDESC_OFF_G1 => "R_AARCH64_TLSDESC_OFF_G1", | ||
| 238 | elf.R_AARCH64_TLSDESC_OFF_G0_NC => "R_AARCH64_TLSDESC_OFF_G0_NC", | ||
| 239 | elf.R_AARCH64_TLSDESC_LDR => "R_AARCH64_TLSDESC_LDR", | ||
| 240 | elf.R_AARCH64_TLSDESC_ADD => "R_AARCH64_TLSDESC_ADD", | ||
| 241 | elf.R_AARCH64_TLSDESC_CALL => "R_AARCH64_TLSDESC_CALL", | ||
| 242 | elf.R_AARCH64_TLSLE_LDST128_TPREL_LO12 => "R_AARCH64_TLSLE_LDST128_TPREL_LO12", | ||
| 243 | elf.R_AARCH64_TLSLE_LDST128_TPREL_LO12_NC => "R_AARCH64_TLSLE_LDST128_TPREL_LO12_NC", | ||
| 244 | elf.R_AARCH64_TLSLD_LDST128_DTPREL_LO12 => "R_AARCH64_TLSLD_LDST128_DTPREL_LO12", | ||
| 245 | elf.R_AARCH64_TLSLD_LDST128_DTPREL_LO12_NC => "R_AARCH64_TLSLD_LDST128_DTPREL_LO12_NC", | ||
| 246 | elf.R_AARCH64_COPY => "R_AARCH64_COPY", | ||
| 247 | elf.R_AARCH64_GLOB_DAT => "R_AARCH64_GLOB_DAT", | ||
| 248 | elf.R_AARCH64_JUMP_SLOT => "R_AARCH64_JUMP_SLOT", | ||
| 249 | elf.R_AARCH64_RELATIVE => "R_AARCH64_RELATIVE", | ||
| 250 | elf.R_AARCH64_TLS_DTPMOD => "R_AARCH64_TLS_DTPMOD", | ||
| 251 | elf.R_AARCH64_TLS_DTPREL => "R_AARCH64_TLS_DTPREL", | ||
| 252 | elf.R_AARCH64_TLS_TPREL => "R_AARCH64_TLS_TPREL", | ||
| 253 | elf.R_AARCH64_TLSDESC => "R_AARCH64_TLSDESC", | ||
| 254 | elf.R_AARCH64_IRELATIVE => "R_AARCH64_IRELATIVE", | ||
| 255 | else => "R_AARCH64_UNKNOWN", | ||
| 256 | }, | 117 | }, |
| 257 | else => unreachable, | 118 | } |
| 258 | }; | ||
| 259 | try writer.print("{s}", .{str}); | ||
| 260 | } | 119 | } |
| 261 | 120 | ||
| 262 | const assert = std.debug.assert; | 121 | const assert = std.debug.assert; |
| 263 | const elf = std.elf; | 122 | const elf = std.elf; |
| 264 | const std = @import("std"); | 123 | const std = @import("std"); |
| 124 | |||
| 125 | const Elf = @import("../Elf.zig"); |