authorgravatar for kubkon@jakubkonka.comJakub Konka <kubkon@jakubkonka.com> 2021-09-18 22:32:09+02:00
committergravatar for kubkon@jakubkonka.comJakub Konka <kubkon@jakubkonka.com> 2021-09-19 14:02:22+02:00
log2a0c44fff3506cdc072d67374e7ffca495cebdc7
tree4ca8b536a052510bfc4cc984e66bf5ece8b2d84a
parent224d4de747d02f4b7add6a7e18512467b6d33569

elf: add amd64 relocation types

I believe these are Linux specific so they will need to be os-gated in `elf.zig` at some point, but I reckon it should be fine to have them as-is right now since the ELF linker work will mainly be done on x86-64 Linux at first.

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

lib/std/elf.zig+87
...@@ -1601,3 +1601,90 @@ pub const SHN_LIVEPATCH = 0xff20;...@@ -1601,3 +1601,90 @@ pub const SHN_LIVEPATCH = 0xff20;
1601pub const SHN_ABS = 0xfff1;1601pub const SHN_ABS = 0xfff1;
1602pub const SHN_COMMON = 0xfff2;1602pub const SHN_COMMON = 0xfff2;
1603pub const SHN_HIRESERVE = 0xffff;1603pub const SHN_HIRESERVE = 0xffff;
1604
1605/// AMD x86-64 relocations.
1606/// No reloc
1607pub const R_X86_64_NONE = 0;
1608/// Direct 64 bit
1609pub const R_X86_64_64 = 1;
1610/// PC relative 32 bit signed
1611pub const R_X86_64_PC32 = 2;
1612/// 32 bit GOT entry
1613pub const R_X86_64_GOT32 = 3;
1614/// 32 bit PLT address
1615pub const R_X86_64_PLT32 = 4;
1616/// Copy symbol at runtime
1617pub const R_X86_64_COPY = 5;
1618/// Create GOT entry
1619pub const R_X86_64_GLOB_DAT = 6;
1620/// Create PLT entry
1621pub const R_X86_64_JUMP_SLOT = 7;
1622/// Adjust by program base
1623pub const R_X86_64_RELATIVE = 8;
1624/// 32 bit signed PC relative offset to GOT
1625pub const R_X86_64_GOTPCREL = 9;
1626/// Direct 32 bit zero extended
1627pub const R_X86_64_32 = 10;
1628/// Direct 32 bit sign extended
1629pub const R_X86_64_32S = 11;
1630/// Direct 16 bit zero extended
1631pub const R_X86_64_16 = 12;
1632/// 16 bit sign extended pc relative
1633pub const R_X86_64_PC16 = 13;
1634/// Direct 8 bit sign extended
1635pub const R_X86_64_8 = 14;
1636/// 8 bit sign extended pc relative
1637pub const R_X86_64_PC8 = 15;
1638/// ID of module containing symbol
1639pub const R_X86_64_DTPMOD64 = 16;
1640/// Offset in module's TLS block
1641pub const R_X86_64_DTPOFF64 = 17;
1642/// Offset in initial TLS block
1643pub const R_X86_64_TPOFF64 = 18;
1644/// 32 bit signed PC relative offset to two GOT entries for GD symbol
1645pub const R_X86_64_TLSGD = 19;
1646/// 32 bit signed PC relative offset to two GOT entries for LD symbol
1647pub const R_X86_64_TLSLD = 20;
1648/// Offset in TLS block
1649pub const R_X86_64_DTPOFF32 = 21;
1650/// 32 bit signed PC relative offset to GOT entry for IE symbol
1651pub const R_X86_64_GOTTPOFF = 22;
1652/// Offset in initial TLS block
1653pub const R_X86_64_TPOFF32 = 23;
1654/// PC relative 64 bit
1655pub const R_X86_64_PC64 = 24;
1656/// 64 bit offset to GOT
1657pub const R_X86_64_GOTOFF64 = 25;
1658/// 32 bit signed pc relative offset to GOT
1659pub const R_X86_64_GOTPC32 = 26;
1660/// 64 bit GOT entry offset
1661pub const R_X86_64_GOT64 = 27;
1662/// 64 bit PC relative offset to GOT entry
1663pub const R_X86_64_GOTPCREL64 = 28;
1664/// 64 bit PC relative offset to GOT
1665pub const R_X86_64_GOTPC64 = 29;
1666/// Like GOT64, says PLT entry needed
1667pub const R_X86_64_GOTPLT64 = 30;
1668/// 64-bit GOT relative offset to PLT entry
1669pub const R_X86_64_PLTOFF64 = 31;
1670/// Size of symbol plus 32-bit addend
1671pub const R_X86_64_SIZE32 = 32;
1672/// Size of symbol plus 64-bit addend
1673pub const R_X86_64_SIZE64 = 33;
1674/// GOT offset for TLS descriptor
1675pub const R_X86_64_GOTPC32_TLSDESC = 34;
1676/// Marker for call through TLS descriptor
1677pub const R_X86_64_TLSDESC_CALL = 35;
1678/// TLS descriptor
1679pub const R_X86_64_TLSDESC = 36;
1680/// Adjust indirectly by program base
1681pub const R_X86_64_IRELATIVE = 37;
1682/// 64-bit adjust by program base
1683pub const R_X86_64_RELATIVE64 = 38;
1684/// 39 Reserved was R_X86_64_PC32_BND
1685/// 40 Reserved was R_X86_64_PLT32_BND
1686/// Load from 32 bit signed pc relative offset to GOT entry without REX prefix, relaxable
1687pub const R_X86_64_GOTPCRELX = 41;
1688/// Load from 32 bit signed PC relative offset to GOT entry with REX prefix, relaxable
1689pub const R_X86_64_REX_GOTPCRELX = 42;
1690pub const R_X86_64_NUM = 43;