Blame sysdeps/unix/sysv/linux/arm/readelflib.c

Packit Service 82fcde
/* Copyright (C) 1999-2018 Free Software Foundation, Inc.
Packit Service 82fcde
   This file is part of the GNU C Library.
Packit Service 82fcde
   Contributed by Andreas Jaeger <aj@suse.de>, 1999 and
Packit Service 82fcde
		  Jakub Jelinek <jakub@redhat.com>, 1999.
Packit Service 82fcde
Packit Service 82fcde
   The GNU C Library is free software; you can redistribute it and/or
Packit Service 82fcde
   modify it under the terms of the GNU Lesser General Public
Packit Service 82fcde
   License as published by the Free Software Foundation; either
Packit Service 82fcde
   version 2.1 of the License, or (at your option) any later version.
Packit Service 82fcde
Packit Service 82fcde
   The GNU C Library is distributed in the hope that it will be useful,
Packit Service 82fcde
   but WITHOUT ANY WARRANTY; without even the implied warranty of
Packit Service 82fcde
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
Packit Service 82fcde
   Lesser General Public License for more details.
Packit Service 82fcde
Packit Service 82fcde
   You should have received a copy of the GNU Lesser General Public
Packit Service 82fcde
   License along with the GNU C Library; if not, see
Packit Service 82fcde
   <http://www.gnu.org/licenses/>.  */
Packit Service 82fcde
Packit Service 82fcde
Packit Service 82fcde
int process_elf32_file (const char *file_name, const char *lib, int *flag,
Packit Service 82fcde
			unsigned int *osversion, char **soname,
Packit Service 82fcde
			void *file_contents, size_t file_length);
Packit Service 82fcde
int process_elf64_file (const char *file_name, const char *lib, int *flag,
Packit Service 82fcde
			unsigned int *osversion, char **soname,
Packit Service 82fcde
			void *file_contents, size_t file_length);
Packit Service 82fcde
Packit Service 82fcde
/* Returns 0 if everything is ok, != 0 in case of error.  */
Packit Service 82fcde
int
Packit Service 82fcde
process_elf_file (const char *file_name, const char *lib, int *flag,
Packit Service 82fcde
		  unsigned int *osversion, char **soname, void *file_contents,
Packit Service 82fcde
		  size_t file_length)
Packit Service 82fcde
{
Packit Service 82fcde
  ElfW(Ehdr) *elf_header = (ElfW(Ehdr) *) file_contents;
Packit Service 82fcde
  int ret;
Packit Service 82fcde
Packit Service 82fcde
  if (elf_header->e_ident [EI_CLASS] == ELFCLASS32)
Packit Service 82fcde
    {
Packit Service 82fcde
      Elf32_Ehdr *elf32_header = (Elf32_Ehdr *) elf_header;
Packit Service 82fcde
Packit Service 82fcde
      ret = process_elf32_file (file_name, lib, flag, osversion, soname,
Packit Service 82fcde
				file_contents, file_length);
Packit Service 82fcde
Packit Service 82fcde
      if (!ret && EF_ARM_EABI_VERSION (elf32_header->e_flags) == EF_ARM_EABI_VER5)
Packit Service 82fcde
	{
Packit Service 82fcde
	  if (elf32_header->e_flags & EF_ARM_ABI_FLOAT_HARD)
Packit Service 82fcde
	    *flag = FLAG_ARM_LIBHF|FLAG_ELF_LIBC6;
Packit Service 82fcde
	  else if (elf32_header->e_flags & EF_ARM_ABI_FLOAT_SOFT)
Packit Service 82fcde
	    *flag = FLAG_ARM_LIBSF|FLAG_ELF_LIBC6;
Packit Service 82fcde
	  else
Packit Service 82fcde
	    /* We must assume the unmarked objects are compatible
Packit Service 82fcde
	       with all ABI variants. Such objects may have been
Packit Service 82fcde
	       generated in a transitional period when the ABI
Packit Service 82fcde
	       tags were not added to all objects.  */
Packit Service 82fcde
	    *flag = FLAG_ELF_LIBC6;
Packit Service 82fcde
	}
Packit Service 82fcde
    }
Packit Service 82fcde
  else
Packit Service 82fcde
    {
Packit Service 82fcde
      ret = process_elf64_file (file_name, lib, flag, osversion, soname,
Packit Service 82fcde
				file_contents, file_length);
Packit Service 82fcde
      /* AArch64 libraries are always libc.so.6+.  */
Packit Service 82fcde
      if (!ret)
Packit Service 82fcde
	*flag = FLAG_AARCH64_LIB64|FLAG_ELF_LIBC6;
Packit Service 82fcde
    }
Packit Service 82fcde
  return ret;
Packit Service 82fcde
}
Packit Service 82fcde
Packit Service 82fcde
#undef __ELF_NATIVE_CLASS
Packit Service 82fcde
#undef process_elf_file
Packit Service 82fcde
#define process_elf_file process_elf32_file
Packit Service 82fcde
#define __ELF_NATIVE_CLASS 32
Packit Service 82fcde
#include "elf/readelflib.c"
Packit Service 82fcde
Packit Service 82fcde
#undef __ELF_NATIVE_CLASS
Packit Service 82fcde
#undef process_elf_file
Packit Service 82fcde
#define process_elf_file process_elf64_file
Packit Service 82fcde
#define __ELF_NATIVE_CLASS 64
Packit Service 82fcde
#include "elf/readelflib.c"