Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-09-16 08:55:00

0001 /* Accumulation of various pieces of knowledge about ELF.
0002    Copyright (C) 2000-2012, 2014, 2016 Red Hat, Inc.
0003    This file is part of elfutils.
0004    Written by Ulrich Drepper <drepper@redhat.com>, 2000.
0005 
0006    This file is free software; you can redistribute it and/or modify
0007    it under the terms of either
0008 
0009      * the GNU Lesser General Public License as published by the Free
0010        Software Foundation; either version 3 of the License, or (at
0011        your option) any later version
0012 
0013    or
0014 
0015      * the GNU General Public License as published by the Free
0016        Software Foundation; either version 2 of the License, or (at
0017        your option) any later version
0018 
0019    or both in parallel, as here.
0020 
0021    elfutils is distributed in the hope that it will be useful, but
0022    WITHOUT ANY WARRANTY; without even the implied warranty of
0023    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
0024    General Public License for more details.
0025 
0026    You should have received copies of the GNU General Public License and
0027    the GNU Lesser General Public License along with this program.  If
0028    not, see <http://www.gnu.org/licenses/>.  */
0029 
0030 #ifndef _ELF_KNOWLEDGE_H
0031 #define _ELF_KNOWLEDGE_H    1
0032 
0033 #include <stdbool.h>
0034 
0035 
0036 /* Test whether a section can be stripped or not.  */
0037 #define SECTION_STRIP_P(shdr, name, remove_comment) \
0038   /* Sections which are allocated are not removed.  */                \
0039   (((shdr)->sh_flags & SHF_ALLOC) == 0                        \
0040    /* We never remove .note sections.  */                     \
0041    && (shdr)->sh_type != SHT_NOTE                         \
0042    && (((shdr)->sh_type) != SHT_PROGBITS                      \
0043        /* Never remove .gnu.warning.* sections.  */               \
0044        || (name != NULL                               \
0045        && strncmp (name, ".gnu.warning.", sizeof ".gnu.warning." - 1) != 0\
0046        /* We remove .comment sections only if explicitly told to do so. */\
0047        && (remove_comment                             \
0048            || strcmp (name, ".comment") != 0))))
0049 
0050 
0051 /* Test whether `sh_info' field in section header contains a section
0052    index.  There are two kinds of sections doing this:
0053 
0054    - the sections containing relocation information reference in this
0055      field the section to which the relocations apply;
0056 
0057    - section with the SHF_INFO_LINK flag set to signal that `sh_info'
0058      references a section.  This allows correct handling of unknown
0059      sections.  */
0060 #define SH_INFO_LINK_P(Shdr) \
0061   ((Shdr)->sh_type == SHT_REL || (Shdr)->sh_type == SHT_RELA              \
0062    || ((Shdr)->sh_flags & SHF_INFO_LINK) != 0)
0063 
0064 
0065 /* Size of an entry in the hash table.  The ELF specification says all
0066    entries are regardless of platform 32-bits in size.  Early 64-bit
0067    ports (namely Alpha for Linux) got this wrong.  The wording was not
0068    clear.
0069 
0070    Several years later the ABI for the 64-bit S390s was developed.
0071    Many things were copied from the IA-64 ABI (which uses the correct
0072    32-bit entry size) but it does get the SHT_HASH entry size wrong by
0073    using a 64-bit entry size.  So now we need this macro to special
0074    case both the alpha and s390x ABIs.  */
0075 #define SH_ENTSIZE_HASH(Ehdr) \
0076   ((Ehdr)->e_machine == EM_ALPHA                          \
0077    || ((Ehdr)->e_machine == EM_S390                       \
0078        && (Ehdr)->e_ident[EI_CLASS] == ELFCLASS64) ? 8 : 4)
0079 
0080 /* GNU Annobin notes are not fully standardized and abuses the owner name.  */
0081 
0082 #define ELF_NOTE_GNU_BUILD_ATTRIBUTE_PREFIX "GA"
0083 
0084 #define NT_GNU_BUILD_ATTRIBUTE_OPEN 0x100
0085 #define NT_GNU_BUILD_ATTRIBUTE_FUNC 0x101
0086 
0087 #define GNU_BUILD_ATTRIBUTE_TYPE_NUMERIC    '*'
0088 #define GNU_BUILD_ATTRIBUTE_TYPE_STRING     '$'
0089 #define GNU_BUILD_ATTRIBUTE_TYPE_BOOL_TRUE  '+'
0090 #define GNU_BUILD_ATTRIBUTE_TYPE_BOOL_FALSE '!'
0091 
0092 #define GNU_BUILD_ATTRIBUTE_VERSION 1
0093 #define GNU_BUILD_ATTRIBUTE_STACK_PROT  2
0094 #define GNU_BUILD_ATTRIBUTE_RELRO   3
0095 #define GNU_BUILD_ATTRIBUTE_STACK_SIZE  4
0096 #define GNU_BUILD_ATTRIBUTE_TOOL    5
0097 #define GNU_BUILD_ATTRIBUTE_ABI     6
0098 #define GNU_BUILD_ATTRIBUTE_PIC     7
0099 #define GNU_BUILD_ATTRIBUTE_SHORT_ENUM  8
0100 
0101 /* Hexagon specific declarations.  */
0102 
0103 /* Processor specific flags for the Ehdr e_flags field.  */
0104 #define EF_HEXAGON_MACH_V2   0x00000001 /* Hexagon V2 */
0105 #define EF_HEXAGON_MACH_V3   0x00000002 /* Hexagon V3 */
0106 #define EF_HEXAGON_MACH_V4   0x00000003 /* Hexagon V4 */
0107 #define EF_HEXAGON_MACH_V5   0x00000004 /* Hexagon V5 */
0108 #define EF_HEXAGON_MACH_V55  0x00000005 /* Hexagon V55 */
0109 #define EF_HEXAGON_MACH_V60  0x00000060 /* Hexagon V60 */
0110 #define EF_HEXAGON_MACH_V61  0x00000061 /* Hexagon V61 */
0111 #define EF_HEXAGON_MACH_V62  0x00000062 /* Hexagon V62 */
0112 #define EF_HEXAGON_MACH_V65  0x00000065 /* Hexagon V65 */
0113 #define EF_HEXAGON_MACH_V66  0x00000066 /* Hexagon V66 */
0114 #define EF_HEXAGON_MACH_V67  0x00000067 /* Hexagon V67 */
0115 #define EF_HEXAGON_MACH_V67T 0x00008067 /* Hexagon V67T */
0116 #define EF_HEXAGON_MACH_V68  0x00000068 /* Hexagon V68 */
0117 #define EF_HEXAGON_MACH_V69  0x00000069 /* Hexagon V68 */
0118 #define EF_HEXAGON_MACH_V71  0x00000071 /* Hexagon V71 */
0119 #define EF_HEXAGON_MACH_V71T 0x00008071 /* Hexagon V71T */
0120 #define EF_HEXAGON_MACH_V73  0x00000073 /* Hexagon V73 */
0121 #define EF_HEXAGON_MACH      0x000003ff /* Hexagon V.. */
0122 #define EF_HEXAGON_TINY      0x00008000 /* Hexagon V..T */
0123 
0124 /* Special section indices.  */
0125 #define SHN_HEXAGON_SCOMMON    0xff00 /* Other access sizes */
0126 #define SHN_HEXAGON_SCOMMON_1  0xff01 /* Byte-sized access */
0127 #define SHN_HEXAGON_SCOMMON_2  0xff02 /* Half-word-sized access */
0128 #define SHN_HEXAGON_SCOMMON_4  0xff03 /* Word-sized access */
0129 #define SHN_HEXAGON_SCOMMON_8  0xff04 /* Double-word-size access */
0130 
0131 /* Hexagon specific relocs.  */
0132 #define R_HEX_NONE                0
0133 #define R_HEX_B22_PCREL           1
0134 #define R_HEX_B15_PCREL           2
0135 #define R_HEX_B7_PCREL            3
0136 #define R_HEX_LO16                4
0137 #define R_HEX_HI16                5
0138 #define R_HEX_32                  6
0139 #define R_HEX_16                  7
0140 #define R_HEX_8                   8
0141 #define R_HEX_GPREL16_0           9
0142 #define R_HEX_GPREL16_1           10
0143 #define R_HEX_GPREL16_2           11
0144 #define R_HEX_GPREL16_3           12
0145 #define R_HEX_HL16                13
0146 #define R_HEX_B13_PCREL           14
0147 #define R_HEX_B9_PCREL            15
0148 #define R_HEX_B32_PCREL_X         16
0149 #define R_HEX_32_6_X              17
0150 #define R_HEX_B22_PCREL_X         18
0151 #define R_HEX_B15_PCREL_X         19
0152 #define R_HEX_B13_PCREL_X         20
0153 #define R_HEX_B9_PCREL_X          21
0154 #define R_HEX_B7_PCREL_X          22
0155 #define R_HEX_16_X                23
0156 #define R_HEX_12_X                24
0157 #define R_HEX_11_X                25
0158 #define R_HEX_10_X                26
0159 #define R_HEX_9_X                 27
0160 #define R_HEX_8_X                 28
0161 #define R_HEX_7_X                 29
0162 #define R_HEX_6_X                 30
0163 #define R_HEX_32_PCREL            31
0164 #define R_HEX_COPY                32
0165 #define R_HEX_GLOB_DAT            33
0166 #define R_HEX_JMP_SLOT            34
0167 #define R_HEX_RELATIVE            35
0168 #define R_HEX_PLT_B22_PCREL       36
0169 #define R_HEX_GOTREL_LO16         37
0170 #define R_HEX_GOTREL_HI16         38
0171 #define R_HEX_GOTREL_32           39
0172 #define R_HEX_GOT_LO16            40
0173 #define R_HEX_GOT_HI16            41
0174 #define R_HEX_GOT_32              42
0175 #define R_HEX_GOT_16              43
0176 #define R_HEX_DTPMOD_32           44
0177 #define R_HEX_DTPREL_LO16         45
0178 #define R_HEX_DTPREL_HI16         46
0179 #define R_HEX_DTPREL_32           47
0180 #define R_HEX_DTPREL_16           48
0181 #define R_HEX_GD_PLT_B22_PCREL    49
0182 #define R_HEX_GD_GOT_LO16         50
0183 #define R_HEX_GD_GOT_HI16         51
0184 #define R_HEX_GD_GOT_32           52
0185 #define R_HEX_GD_GOT_16           53
0186 #define R_HEX_IE_LO16             54
0187 #define R_HEX_IE_HI16             55
0188 #define R_HEX_IE_32               56
0189 #define R_HEX_IE_GOT_LO16         57
0190 #define R_HEX_IE_GOT_HI16         58
0191 #define R_HEX_IE_GOT_32           59
0192 #define R_HEX_IE_GOT_16           60
0193 #define R_HEX_TPREL_LO16          61
0194 #define R_HEX_TPREL_HI16          62
0195 #define R_HEX_TPREL_32            63
0196 #define R_HEX_TPREL_16            64
0197 #define R_HEX_6_PCREL_X           65
0198 #define R_HEX_GOTREL_32_6_X       66
0199 #define R_HEX_GOTREL_16_X         67
0200 #define R_HEX_GOTREL_11_X         68
0201 #define R_HEX_GOT_32_6_X          69
0202 #define R_HEX_GOT_16_X            70
0203 #define R_HEX_GOT_11_X            71
0204 #define R_HEX_DTPREL_32_6_X       72
0205 #define R_HEX_DTPREL_16_X         73
0206 #define R_HEX_DTPREL_11_X         74
0207 #define R_HEX_GD_GOT_32_6_X       75
0208 #define R_HEX_GD_GOT_16_X         76
0209 #define R_HEX_GD_GOT_11_X         77
0210 #define R_HEX_IE_32_6_X           78
0211 #define R_HEX_IE_16_X             79
0212 #define R_HEX_IE_GOT_32_6_X       80
0213 #define R_HEX_IE_GOT_16_X         81
0214 #define R_HEX_IE_GOT_11_X         82
0215 #define R_HEX_TPREL_32_6_X        83
0216 #define R_HEX_TPREL_16_X          84
0217 #define R_HEX_TPREL_11_X          85
0218 #define R_HEX_LD_PLT_B22_PCREL    86
0219 #define R_HEX_LD_GOT_LO16         87
0220 #define R_HEX_LD_GOT_HI16         88
0221 #define R_HEX_LD_GOT_32           89
0222 #define R_HEX_LD_GOT_16           90
0223 #define R_HEX_LD_GOT_32_6_X       91
0224 #define R_HEX_LD_GOT_16_X         92
0225 #define R_HEX_LD_GOT_11_X         93
0226 #define R_HEX_23_REG              94
0227 #define R_HEX_GD_PLT_B22_PCREL_X  95
0228 #define R_HEX_GD_PLT_B32_PCREL_X  96
0229 #define R_HEX_LD_PLT_B22_PCREL_X  97
0230 #define R_HEX_LD_PLT_B32_PCREL_X  98
0231 #define R_HEX_27_REG              99
0232 
0233 #endif  /* elf-knowledge.h */