Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-02-21 10:00: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 #endif  /* elf-knowledge.h */