1 /*
2  * Copyright (C) 2013 The Android Open Source Project
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
8  *  * Redistributions of source code must retain the above copyright
9  *    notice, this list of conditions and the following disclaimer.
10  *  * Redistributions in binary form must reproduce the above copyright
11  *    notice, this list of conditions and the following disclaimer in
12  *    the documentation and/or other materials provided with the
13  *    distribution.
14  *
15  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
16  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
17  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
18  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
19  * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
20  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
21  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
22  * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
23  * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
24  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
25  * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26  * SUCH DAMAGE.
27  */
28 
29 #ifndef _AARCH64_ELF_MACHDEP_H_
30 #define _AARCH64_ELF_MACHDEP_H_
31 
32 #if defined(__AARCH64EB__)
33 #define ELF64_MACHDEP_ENDIANNESS    ELFDATA2MSB
34 #else
35 #define ELF64_MACHDEP_ENDIANNESS    ELFDATA2LSB
36 #endif
37 
38 #define ELF64_MACHDEP_ID_CASES                      \
39     case EM_AARCH64:                                \
40         break;
41 
42 #define ELF64_MACHDEP_ID    EM_AARCH64
43 
44 #define ARCH_ELFSIZE        64  /* MD native binary size */
45 
46 /* Null relocations */
47 #define R_ARM_NONE                      0
48 #define R_AARCH64_NONE                  256
49 
50 /* Static Data relocations */
51 #define R_AARCH64_ABS64                 257
52 #define R_AARCH64_ABS32                 258
53 #define R_AARCH64_ABS16                 259
54 #define R_AARCH64_PREL64                260
55 #define R_AARCH64_PREL32                261
56 #define R_AARCH64_PREL16                262
57 
58 #define R_AARCH64_MOVW_UABS_G0          263
59 #define R_AARCH64_MOVW_UABS_G0_NC       264
60 #define R_AARCH64_MOVW_UABS_G1          265
61 #define R_AARCH64_MOVW_UABS_G1_NC       266
62 #define R_AARCH64_MOVW_UABS_G2          267
63 #define R_AARCH64_MOVW_UABS_G2_NC       268
64 #define R_AARCH64_MOVW_UABS_G3          269
65 #define R_AARCH64_MOVW_SABS_G0          270
66 #define R_AARCH64_MOVW_SABS_G1          271
67 #define R_AARCH64_MOVW_SABS_G2          272
68 
69 /* PC-relative addresses */
70 #define R_AARCH64_LD_PREL_LO19          273
71 #define R_AARCH64_ADR_PREL_LO21         274
72 #define R_AARCH64_ADR_PREL_PG_HI21      275
73 #define R_AARCH64_ADR_PREL_PG_HI21_NC   276
74 #define R_AARCH64_ADD_ABS_LO12_NC       277
75 #define R_AARCH64_LDST8_ABS_LO12_NC     278
76 
77 /* Control-flow relocations */
78 #define R_AARCH64_TSTBR14               279
79 #define R_AARCH64_CONDBR19              280
80 #define R_AARCH64_JUMP26                282
81 #define R_AARCH64_CALL26                283
82 #define R_AARCH64_LDST16_ABS_LO12_NC    284
83 #define R_AARCH64_LDST32_ABS_LO12_NC    285
84 #define R_AARCH64_LDST64_ABS_LO12_NC    286
85 #define R_AARCH64_LDST128_ABS_LO12_NC   299
86 
87 #define R_AARCH64_MOVW_PREL_G0          287
88 #define R_AARCH64_MOVW_PREL_G0_NC       288
89 #define R_AARCH64_MOVW_PREL_G1          289
90 #define R_AARCH64_MOVW_PREL_G1_NC       290
91 #define R_AARCH64_MOVW_PREL_G2          291
92 #define R_AARCH64_MOVW_PREL_G2_NC       292
93 #define R_AARCH64_MOVW_PREL_G3          293
94 
95 /* Dynamic relocations */
96 #define R_AARCH64_COPY                  1024
97 #define R_AARCH64_GLOB_DAT              1025    /* Create GOT entry.  */
98 #define R_AARCH64_JUMP_SLOT             1026    /* Create PLT entry.  */
99 #define R_AARCH64_RELATIVE              1027    /* Adjust by program base.  */
100 #define R_AARCH64_TLS_TPREL64           1030
101 #define R_AARCH64_TLS_DTPREL32          1031
102 #define R_AARCH64_IRELATIVE             1032
103 
104 #define R_TYPE(name)        __CONCAT(R_AARCH64_,name)
105 
106 #endif /* _AARCH64_ELF_MACHDEP_H_ */
107