1  /* Run-time dynamic linker data structures for loaded ELF shared objects.
       2     Copyright (C) 2010-2023 Free Software Foundation, Inc.
       3     This file is part of the GNU C Library.
       4  
       5     The GNU C Library is free software; you can redistribute it and/or
       6     modify it under the terms of the GNU Lesser General Public
       7     License as published by the Free Software Foundation; either
       8     version 2.1 of the License, or (at your option) any later version.
       9  
      10     The GNU C Library is distributed in the hope that it will be useful,
      11     but WITHOUT ANY WARRANTY; without even the implied warranty of
      12     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
      13     Lesser General Public License for more details.
      14  
      15     You should have received a copy of the GNU Lesser General Public
      16     License along with the GNU C Library.  If not, see
      17     <https://www.gnu.org/licenses/>.  */
      18  
      19  #ifndef _ARM_LINUX_LDSODEFS_H
      20  #define _ARM_LINUX_LDSODEFS_H 1
      21  
      22  #include_next <ldsodefs.h>
      23  
      24  #undef VALID_ELF_HEADER
      25  #undef VALID_ELF_OSABI
      26  #undef MORE_ELF_HEADER_DATA
      27  
      28  #define EXTRA_OSABI ELFOSABI_ARM_AEABI
      29  
      30  #ifdef __ARM_PCS_VFP
      31  # define VALID_FLOAT_ABI(x) \
      32    ((EF_ARM_EABI_VERSION ((x)) != EF_ARM_EABI_VER5)	\
      33     || !((x) & EF_ARM_ABI_FLOAT_SOFT))
      34  #else
      35  # define VALID_FLOAT_ABI(x) \
      36    ((EF_ARM_EABI_VERSION ((x)) != EF_ARM_EABI_VER5)	\
      37     || !((x) & EF_ARM_ABI_FLOAT_HARD))
      38  #endif
      39  
      40  #undef VALID_ELF_HEADER
      41  #define VALID_ELF_HEADER(hdr,exp,size)		\
      42    ((memcmp (hdr, exp, size) == 0		\
      43      || memcmp (hdr, expected2, size) == 0	\
      44      || memcmp (hdr, expected3, size) == 0)	\
      45     && VALID_FLOAT_ABI (ehdr->e_flags))
      46  #define VALID_ELF_OSABI(osabi)		(osabi == ELFOSABI_SYSV		\
      47  					 || osabi == ELFOSABI_GNU	\
      48  					 || osabi == EXTRA_OSABI)
      49  #define MORE_ELF_HEADER_DATA				\
      50    static const unsigned char expected2[EI_PAD] =	\
      51    {							\
      52      [EI_MAG0] = ELFMAG0,				\
      53      [EI_MAG1] = ELFMAG1,				\
      54      [EI_MAG2] = ELFMAG2,				\
      55      [EI_MAG3] = ELFMAG3,				\
      56      [EI_CLASS] = ELFW(CLASS),				\
      57      [EI_DATA] = byteorder,				\
      58      [EI_VERSION] = EV_CURRENT,				\
      59      [EI_OSABI] = ELFOSABI_GNU				\
      60    };							\
      61    static const unsigned char expected3[EI_PAD] =	\
      62    {							\
      63      [EI_MAG0] = ELFMAG0,				\
      64      [EI_MAG1] = ELFMAG1,				\
      65      [EI_MAG2] = ELFMAG2,				\
      66      [EI_MAG3] = ELFMAG3,				\
      67      [EI_CLASS] = ELFW(CLASS),				\
      68      [EI_DATA] = byteorder,				\
      69      [EI_VERSION] = EV_CURRENT,				\
      70      [EI_OSABI] = EXTRA_OSABI				\
      71    }
      72  
      73  #endif