Blame libelf/elf-knowledge.h

Packit 032894
/* Accumulation of various pieces of knowledge about ELF.
Packit 032894
   Copyright (C) 2000-2012, 2014, 2016 Red Hat, Inc.
Packit 032894
   This file is part of elfutils.
Packit 032894
   Written by Ulrich Drepper <drepper@redhat.com>, 2000.
Packit 032894
Packit 032894
   This file is free software; you can redistribute it and/or modify
Packit 032894
   it under the terms of either
Packit 032894
Packit 032894
     * the GNU Lesser General Public License as published by the Free
Packit 032894
       Software Foundation; either version 3 of the License, or (at
Packit 032894
       your option) any later version
Packit 032894
Packit 032894
   or
Packit 032894
Packit 032894
     * the GNU General Public License as published by the Free
Packit 032894
       Software Foundation; either version 2 of the License, or (at
Packit 032894
       your option) any later version
Packit 032894
Packit 032894
   or both in parallel, as here.
Packit 032894
Packit 032894
   elfutils is distributed in the hope that it will be useful, but
Packit 032894
   WITHOUT ANY WARRANTY; without even the implied warranty of
Packit 032894
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
Packit 032894
   General Public License for more details.
Packit 032894
Packit 032894
   You should have received copies of the GNU General Public License and
Packit 032894
   the GNU Lesser General Public License along with this program.  If
Packit 032894
   not, see <http://www.gnu.org/licenses/>.  */
Packit 032894
Packit 032894
#ifndef _ELF_KNOWLEDGE_H
Packit 032894
#define _ELF_KNOWLEDGE_H	1
Packit 032894
Packit 032894
#include <stdbool.h>
Packit 032894
Packit 032894
Packit 032894
/* Test whether a section can be stripped or not.  */
Packit 032894
#define SECTION_STRIP_P(shdr, name, remove_comment) \
Packit 032894
  /* Sections which are allocated are not removed.  */			      \
Packit 032894
  (((shdr)->sh_flags & SHF_ALLOC) == 0					      \
Packit 032894
   /* We never remove .note sections.  */				      \
Packit 032894
   && (shdr)->sh_type != SHT_NOTE					      \
Packit 032894
   && (((shdr)->sh_type) != SHT_PROGBITS				      \
Packit 032894
       /* Never remove .gnu.warning.* sections.  */			      \
Packit 032894
       || (name != NULL							      \
Packit 032894
	   && strncmp (name, ".gnu.warning.", sizeof ".gnu.warning." - 1) != 0\
Packit 032894
	   /* We remove .comment sections only if explicitly told to do so. */\
Packit 032894
	   && (remove_comment						      \
Packit 032894
	       || strcmp (name, ".comment") != 0))))
Packit 032894
Packit 032894
Packit 032894
/* Test whether `sh_info' field in section header contains a section
Packit 032894
   index.  There are two kinds of sections doing this:
Packit 032894
Packit 032894
   - the sections containing relocation information reference in this
Packit 032894
     field the section to which the relocations apply;
Packit 032894
Packit 032894
   - section with the SHF_INFO_LINK flag set to signal that `sh_info'
Packit 032894
     references a section.  This allows correct handling of unknown
Packit 032894
     sections.  */
Packit 032894
#define SH_INFO_LINK_P(Shdr) \
Packit 032894
  ((Shdr)->sh_type == SHT_REL || (Shdr)->sh_type == SHT_RELA		      \
Packit 032894
   || ((Shdr)->sh_flags & SHF_INFO_LINK) != 0)
Packit 032894
Packit 032894
Packit 032894
/* Size of an entry in the hash table.  The ELF specification says all
Packit 032894
   entries are regardless of platform 32-bits in size.  Early 64-bit
Packit 032894
   ports (namely Alpha for Linux) got this wrong.  The wording was not
Packit 032894
   clear.
Packit 032894
Packit 032894
   Several years later the ABI for the 64-bit S390s was developed.
Packit 032894
   Many things were copied from the IA-64 ABI (which uses the correct
Packit 032894
   32-bit entry size) but what do these people do?  They use 64-bit
Packit 032894
   entries.  It is really shocking to see what kind of morons are out
Packit 032894
   there.  And even worse: they are allowed to design ABIs.  */
Packit 032894
#define SH_ENTSIZE_HASH(Ehdr) \
Packit 032894
  ((Ehdr)->e_machine == EM_ALPHA					      \
Packit 032894
   || ((Ehdr)->e_machine == EM_S390					      \
Packit 032894
       && (Ehdr)->e_ident[EI_CLASS] == ELFCLASS64) ? 8 : 4)
Packit 032894
Packit 032894
/* GNU Annobin notes are not fully standardized and abuses the owner name.  */
Packit 032894
Packit 032894
#define ELF_NOTE_GNU_BUILD_ATTRIBUTE_PREFIX "GA"
Packit 032894
Packit 032894
#define NT_GNU_BUILD_ATTRIBUTE_OPEN 0x100
Packit 032894
#define NT_GNU_BUILD_ATTRIBUTE_FUNC 0x101
Packit 032894
Packit 032894
#define GNU_BUILD_ATTRIBUTE_TYPE_NUMERIC	'*'
Packit 032894
#define GNU_BUILD_ATTRIBUTE_TYPE_STRING		'$'
Packit 032894
#define GNU_BUILD_ATTRIBUTE_TYPE_BOOL_TRUE	'+'
Packit 032894
#define GNU_BUILD_ATTRIBUTE_TYPE_BOOL_FALSE	'!'
Packit 032894
Packit 032894
#define GNU_BUILD_ATTRIBUTE_VERSION	1
Packit 032894
#define GNU_BUILD_ATTRIBUTE_STACK_PROT	2
Packit 032894
#define GNU_BUILD_ATTRIBUTE_RELRO	3
Packit 032894
#define GNU_BUILD_ATTRIBUTE_STACK_SIZE	4
Packit 032894
#define GNU_BUILD_ATTRIBUTE_TOOL	5
Packit 032894
#define GNU_BUILD_ATTRIBUTE_ABI		6
Packit 032894
#define GNU_BUILD_ATTRIBUTE_PIC		7
Packit 032894
#define GNU_BUILD_ATTRIBUTE_SHORT_ENUM	8
Packit 032894
Packit 032894
#endif	/* elf-knowledge.h */