// arm-reloc.def -- ARM relocation definitions.

// Copyright (C) 2010-2018 Free Software Foundation, Inc.
// Written by Doug Kwan <dougkwan@google.com>.

// This file is part of gold.

// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 3 of the License, or
// (at your option) any later version.

// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.

// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
// MA 02110-1301, USA.

// The information here is based on the official ARM document "ELF for ARM
// Architecture" (Document number ARM IHI 0044C).  The first five columns of
// the table below are derived from Table 4-8 in the ARM ELF document.  Each
// relocation from Table 4-8 corresponds to one relocation definition in the
// table below.  A relocation definition has the following information:
//
// Name: This is the name of the relocation without the "R_ARM_" prefix.
//
// Type: Relocation type.  There are four.
//   - STATIC for static relocations processed by a static linker.
//   - DYNAMIC for dynamic relocations processed by a dynamic linker.
//   - PRIVATE for R_ARM_PRIVATE_<n> private relocation type.
//   - OBSOLETE for old relocation types no longer used.
//   We do not use DEPRECATED as a distinct type since we still have to
//   handle deprecated relocations so we one of the types above.
//
// Deprecated:  Whether this is a deprecated relocation type.  The linker
//   is expected to handle these though they should not be generated by fully
//   conforming tool-chains.
//
// Operation: An expression specifying how the linker should perform a
//   relocation.  If there is no operation or the operation cannot be
//   specified, it is "NONE".
//
// Implemented: Whether this is implemented by the gold.
//
// Group_index: For a group relocation type, it is one of 0, 1 or 2.  For
//   a non-group relocation type, it is -1.
//
// Overflow: Whether gold should check for overflow.  This is "No" by default
//   for relocation types DYNAMIC, PRIVATE and OBSOLETE.
//
// Overflow-----------------------------------------------------------------+
// Group index----------------------------------------------------------+   |
// Implemented-------------------------------------------------------+  |   |
// Operation-------------------------------+                         |  |   |
// Class----------------------------+      |                         |  |   |
// Deprecated--------------------+  |      |                         |  |   |
// Type----------------+         |  |      |                         |  |   |
// Name                |         |  |      |                         |  |   |
// |                   |         |  |      |                         |  |   |
RD(NONE              , STATIC  , N, MISC , NONE                   ,  Y, -1, N)
RD(PC24              , STATIC  , Y, ARM  , ((S + A) | T) - P      ,  Y, -1, Y)
RD(ABS32             , STATIC  , N, DATA , (S + A) | T            ,  Y, -1, N)
RD(REL32             , STATIC  , N, DATA , ((S + A) | T) - P      ,  Y, -1, N)
RD(LDR_PC_G0         , STATIC  , N, ARM  , S + A - P              ,  Y,  0, Y)
RD(ABS16             , STATIC  , N, DATA , S + A                  ,  Y, -1, Y)
RD(ABS12             , STATIC  , N, ARM  , S + A                  ,  Y, -1, Y)
RD(THM_ABS5          , STATIC  , N, THM16, S + A                  ,  Y, -1, Y)
RD(ABS8              , STATIC  , N, DATA , S + A                  ,  Y, -1, Y)
RD(SBREL32           , STATIC  , N, DATA , ((S + A) | T) - B(S)   ,  N, -1, N)
RD(THM_CALL          , STATIC  , N, THM32, ((S + A) | T) - P      ,  Y, -1, Y)
RD(THM_PC8           , STATIC  , N, THM16, S + A - Pa             ,  Y, -1, Y)
RD(BREL_ADJ          , DYNAMIC , N, DATA , DELTA_B(S) + A         ,  Y, -1, N)
RD(TLS_DESC          , DYNAMIC , N, DATA , NONE                   ,  Y, -1, N)
RD(THM_SWI8          , OBSOLETE, N, NONE , NONE                   ,  N, -1, N)
RD(XPC25             , OBSOLETE, N, NONE , NONE                   ,  N, -1, N)
RD(THM_XPC22         , OBSOLETE, N, NONE , NONE                   ,  N, -1, N)
RD(TLS_DTPMOD32      , DYNAMIC , N, DATA , Module(S)              ,  Y, -1, N)
RD(TLS_DTPOFF32      , DYNAMIC , N, DATA , S + A - TLS            ,  Y, -1, N)
RD(TLS_TPOFF32       , DYNAMIC , N, DATA , S + A - tp             ,  Y, -1, N)
RD(COPY              , DYNAMIC , N, MISC , NONE                   ,  Y, -1, N)
RD(GLOB_DAT          , DYNAMIC , N, DATA , (S + A) | T            ,  Y, -1, N)
RD(JUMP_SLOT         , DYNAMIC , N, DATA , (S + A) | T            ,  Y, -1, N)
RD(RELATIVE          , DYNAMIC , N, DATA , B(S) + A               ,  Y, -1, N)
RD(GOTOFF32          , STATIC  , N, DATA , ((S + A) | T) - GOT_ORG,  Y, -1, N)
RD(BASE_PREL         , STATIC  , N, DATA , B(S) + A - P           ,  Y, -1, N)
RD(GOT_BREL          , STATIC  , N, DATA , GOT(S) + A - GOT_ORG   ,  Y, -1, N)
RD(PLT32             , STATIC  , Y, ARM  , ((S + A) | T) - P      ,  Y, -1, Y)
RD(CALL              , STATIC  , N, ARM  , ((S + A) | T) - P      ,  Y, -1, Y)
RD(JUMP24            , STATIC  , N, ARM  , ((S + A) | T) - P      ,  Y, -1, Y)
RD(THM_JUMP24        , STATIC  , N, THM32, ((S + A) | T) - P      ,  Y, -1, Y)
RD(BASE_ABS          , STATIC  , N, DATA , B(S) + A               ,  Y, -1, N)
RD(ALU_PCREL_7_0     , OBSOLETE, N, NONE , NONE                   ,  N, -1, N)
RD(ALU_PCREL_15_8    , OBSOLETE, N, NONE , NONE                   ,  N, -1, N)
RD(ALU_PCREL_23_15   , OBSOLETE, N, NONE , NONE                   ,  N, -1, N)
RD(LDR_SBREL_11_0_NC , STATIC  , Y, ARM  , S + A - B(S)           ,  N, -1, N)
RD(ALU_SBREL_19_12_NC, STATIC  , Y, ARM  , S + A - B(S)           ,  N, -1, N)
RD(ALU_SBREL_27_20_CK, STATIC  , Y, ARM  , S + A - B(S)           ,  N, -1, Y)
RD(TARGET1           , STATIC  , N, MISC , NONE                   ,  Y, -1, N)
RD(SBREL31           , STATIC  , Y, DATA , ((S + A) | T) - B(S)   ,  N, -1, N)
RD(V4BX              , STATIC  , N, MISC , NONE                   ,  Y, -1, N)
RD(TARGET2           , STATIC  , N, MISC , NONE                   ,  Y, -1, N)
RD(PREL31            , STATIC  , N, DATA , ((S + A) | T) - P      ,  Y, -1, Y)
RD(MOVW_ABS_NC       , STATIC  , N, ARM  , (S + A) | T            ,  Y, -1, N)
RD(MOVT_ABS          , STATIC  , N, ARM  , S + A                  ,  Y, -1, Y)
RD(MOVW_PREL_NC      , STATIC  , N, ARM  , ((S + A) | T) - P      ,  Y, -1, N)
RD(MOVT_PREL         , STATIC  , N, ARM  , (S + A)  - P           ,  Y, -1, Y)
RD(THM_MOVW_ABS_NC   , STATIC  , N, THM32, (S + A) | T            ,  Y, -1, N)
RD(THM_MOVT_ABS      , STATIC  , N, THM32, S + A                  ,  Y, -1, N)
RD(THM_MOVW_PREL_NC  , STATIC  , N, THM32, ((S + A) | T) - P      ,  Y, -1, N)
RD(THM_MOVT_PREL     , STATIC  , N, THM32, S + A - P              ,  Y, -1, N)
RD(THM_JUMP19        , STATIC  , N, THM32, ((S + A) | T) - P      ,  Y, -1, Y)
RD(THM_JUMP6         , STATIC  , N, THM16, S + A - P              ,  Y, -1, Y)
RD(THM_ALU_PREL_11_0 , STATIC  , N, THM32, ((S + A) | T) - Pa     ,  Y, -1, Y)
RD(THM_PC12          , STATIC  , N, THM32, S + A - Pa             ,  Y, -1, Y)
RD(ABS32_NOI         , STATIC  , N, DATA , S + A                  ,  Y, -1, N)
RD(REL32_NOI         , STATIC  , N, DATA , S + A - P              ,  N, -1, N)
RD(ALU_PC_G0_NC      , STATIC  , N, ARM  , ((S + A) | T) - P      ,  Y,  0, N)
RD(ALU_PC_G0         , STATIC  , N, ARM  , ((S + A) | T) - P      ,  Y,  0, Y)
RD(ALU_PC_G1_NC      , STATIC  , N, ARM  , ((S + A) | T) - P      ,  Y,  1, N)
RD(ALU_PC_G1         , STATIC  , N, ARM  , ((S + A) | T) - P      ,  Y,  1, Y)
RD(ALU_PC_G2         , STATIC  , N, ARM  , ((S + A) | T) - P      ,  Y,  2, Y)
RD(LDR_PC_G1         , STATIC  , N, ARM  , S + A - P              ,  Y,  1, Y)
RD(LDR_PC_G2         , STATIC  , N, ARM  , S + A - P              ,  Y,  2, Y)
RD(LDRS_PC_G0        , STATIC  , N, ARM  , S + A - P              ,  Y,  0, Y)
RD(LDRS_PC_G1        , STATIC  , N, ARM  , S + A - P              ,  Y,  1, Y)
RD(LDRS_PC_G2        , STATIC  , N, ARM  , S + A - P              ,  Y,  2, Y)
RD(LDC_PC_G0         , STATIC  , N, ARM  , S + A - P              ,  Y,  0, Y)
RD(LDC_PC_G1         , STATIC  , N, ARM  , S + A - P              ,  Y,  1, Y)
RD(LDC_PC_G2         , STATIC  , N, ARM  , S + A - P              ,  Y,  2, Y)
RD(ALU_SB_G0_NC      , STATIC  , N, ARM  , ((S + A) | T) - B(S)   ,  Y,  0, N)
RD(ALU_SB_G0         , STATIC  , N, ARM  , ((S + A) | T) - B(S)   ,  Y,  0, Y)
RD(ALU_SB_G1_NC      , STATIC  , N, ARM  , ((S + A) | T) - B(S)   ,  Y,  1, N)
RD(ALU_SB_G1         , STATIC  , N, ARM  , ((S + A) | T) - B(S)   ,  Y,  1, Y)
RD(ALU_SB_G2         , STATIC  , N, ARM  , ((S + A) | T) - B(S)   ,  Y,  2, Y)
RD(LDR_SB_G0         , STATIC  , N, ARM  , S + A - B(S)           ,  Y,  0, Y)
RD(LDR_SB_G1         , STATIC  , N, ARM  , S + A - B(S)           ,  Y,  1, Y)
RD(LDR_SB_G2         , STATIC  , N, ARM  , S + A - B(S)           ,  Y,  2, Y)
RD(LDRS_SB_G0        , STATIC  , N, ARM  , S + A - B(S)           ,  Y,  0, Y)
RD(LDRS_SB_G1        , STATIC  , N, ARM  , S + A - B(S)           ,  Y,  1, Y)
RD(LDRS_SB_G2        , STATIC  , N, ARM  , S + A - B(S)           ,  Y,  2, Y)
RD(LDC_SB_G0         , STATIC  , N, ARM  , S + A - B(S)           ,  Y,  0, Y)
RD(LDC_SB_G1         , STATIC  , N, ARM  , S + A - B(S)           ,  Y,  1, Y)
RD(LDC_SB_G2         , STATIC  , N, ARM  , S + A - B(S)           ,  Y,  2, Y)
RD(MOVW_BREL_NC      , STATIC  , N, ARM  , ((S + A) | T) - B(S)   ,  Y, -1, N)
RD(MOVT_BREL         , STATIC  , N, ARM  , S + A - B(S)           ,  Y, -1, Y)
RD(MOVW_BREL         , STATIC  , N, ARM  , ((S + A) | T) - B(S)   ,  Y, -1, Y)
RD(THM_MOVW_BREL_NC  , STATIC  , N, THM32, ((S + A) | T) - B(S)   ,  Y, -1, N)
RD(THM_MOVT_BREL     , STATIC  , N, THM32, S + A - B(S)           ,  Y, -1, N)
RD(THM_MOVW_BREL     , STATIC  , N, THM32, ((S + A) | T) - B(S)   ,  Y, -1, Y)
RD(TLS_GOTDESC       , STATIC  , N, DATA , NONE                   ,  Y, -1, N)
RD(TLS_CALL          , STATIC  , N, ARM  , NONE                   ,  N, -1, Y)
RD(TLS_DESCSEQ       , STATIC  , N, ARM  , NONE                   ,  N, -1, Y)
RD(THM_TLS_CALL      , STATIC  , N, THM32, NONE                   ,  N, -1, Y)
RD(PLT32_ABS         , STATIC  , N, DATA , PLT(S) + A             ,  N, -1, N)
RD(GOT_ABS           , STATIC  , N, DATA , GOT(S) + A             ,  N, -1, N)
RD(GOT_PREL          , STATIC  , N, DATA , GOT(S) + A - P         ,  Y, -1, N)
RD(GOT_BREL12        , STATIC  , N, ARM  , GOT(S) + A - GOT_ORG   ,  N, -1, Y)
RD(GOTOFF12          , STATIC  , N, ARM  , S + A - GOT_ORG        ,  N, -1, Y)
RD(GOTRELAX          , STATIC  , N, MISC , NONE                   ,  N, -1, N)
RD(GNU_VTENTRY       , STATIC  , Y, DATA , NONE                   ,  Y, -1, N)
RD(GNU_VTINHERIT     , STATIC  , Y, DATA , NONE                   ,  Y, -1, N)
RD(THM_JUMP11        , STATIC  , N, THM16, S + A - P              ,  Y, -1, Y)
RD(THM_JUMP8         , STATIC  , N, THM16, S + A - P              ,  Y, -1, Y)
RD(TLS_GD32          , STATIC  , N, DATA , GOT(S) + A - P         ,  Y, -1, N)
RD(TLS_LDM32         , STATIC  , N, DATA , GOT(S) + A - P         ,  Y, -1, N)
RD(TLS_LDO32         , STATIC  , N, DATA , S + A - TLS            ,  Y, -1, N)
RD(TLS_IE32          , STATIC  , N, DATA , GOT(S) + A - P         ,  Y, -1, N)
RD(TLS_LE32          , STATIC  , N, DATA , S + A - tp             ,  Y, -1, N)
RD(TLS_LDO12         , STATIC  , N, ARM  , S + A - TLS            ,  N, -1, Y)
RD(TLS_LE12          , STATIC  , N, ARM  , S + A - tp             ,  N, -1, Y)
RD(TLS_IE12GP        , STATIC  , N, ARM  , GOT(S) + A - GOT_ORG   ,  N, -1, Y)
RD(PRIVATE_0         , PRIVATE , N, NONE , NONE                   ,  N, -1, N)
RD(PRIVATE_1         , PRIVATE , N, NONE , NONE                   ,  N, -1, N)
RD(PRIVATE_2         , PRIVATE , N, NONE , NONE                   ,  N, -1, N)
RD(PRIVATE_3         , PRIVATE , N, NONE , NONE                   ,  N, -1, N)
RD(PRIVATE_4         , PRIVATE , N, NONE , NONE                   ,  N, -1, N)
RD(PRIVATE_5         , PRIVATE , N, NONE , NONE                   ,  N, -1, N)
RD(PRIVATE_6         , PRIVATE , N, NONE , NONE                   ,  N, -1, N)
RD(PRIVATE_7         , PRIVATE , N, NONE , NONE                   ,  N, -1, N)
RD(PRIVATE_8         , PRIVATE , N, NONE , NONE                   ,  N, -1, N)
RD(PRIVATE_9         , PRIVATE , N, NONE , NONE                   ,  N, -1, N)
RD(PRIVATE_10        , PRIVATE , N, NONE , NONE                   ,  N, -1, N)
RD(PRIVATE_11        , PRIVATE , N, NONE , NONE                   ,  N, -1, N)
RD(PRIVATE_12        , PRIVATE , N, NONE , NONE                   ,  N, -1, N)
RD(PRIVATE_13        , PRIVATE , N, NONE , NONE                   ,  N, -1, N)
RD(PRIVATE_14        , PRIVATE , N, NONE , NONE                   ,  N, -1, N)
RD(PRIVATE_15        , PRIVATE , N, NONE , NONE                   ,  N, -1, N)
RD(ME_TOO            , OBSOLETE, N, NONE , NONE                   ,  N, -1, N)
RD(THM_TLS_DESCSEQ16 , STATIC  , N, THM16, NONE                   ,  N, -1, Y)
RD(THM_TLS_DESCSEQ32 , STATIC  , N, THM32, NONE                   ,  N, -1, Y)
