aboutsummaryrefslogtreecommitdiff
path: root/sysdeps/unix/sysv/linux/i386/readelflib.c
diff options
context:
space:
mode:
Diffstat (limited to 'sysdeps/unix/sysv/linux/i386/readelflib.c')
-rw-r--r--sysdeps/unix/sysv/linux/i386/readelflib.c66
1 files changed, 39 insertions, 27 deletions
diff --git a/sysdeps/unix/sysv/linux/i386/readelflib.c b/sysdeps/unix/sysv/linux/i386/readelflib.c
index bdd5e70bc8..fab830ef5b 100644
--- a/sysdeps/unix/sysv/linux/i386/readelflib.c
+++ b/sysdeps/unix/sysv/linux/i386/readelflib.c
@@ -32,40 +32,52 @@ process_elf_file (const char *file_name, const char *lib, int *flag,
size_t file_length)
{
ElfW(Ehdr) *elf_header = (ElfW(Ehdr) *) file_contents;
- int ret;
+ int ret, file_flag = 0;
- if (elf_header->e_ident [EI_CLASS] == ELFCLASS32)
- return process_elf32_file (file_name, lib, flag, osversion, soname,
- file_contents, file_length);
- else
+ switch (elf_header->e_machine)
{
- switch (elf_header->e_machine)
+ case EM_X86_64:
+ if (elf_header->e_ident[EI_CLASS] == ELFCLASS64)
+ /* X86-64 64bit libraries are always libc.so.6+. */
+ file_flag = FLAG_X8664_LIB64|FLAG_ELF_LIBC6;
+ else
+ /* X32 libraries are always libc.so.6+. */
+ file_flag = FLAG_X8664_LIBX32|FLAG_ELF_LIBC6;
+ break;
+#ifndef SKIP_EM_IA_64
+ case EM_IA_64:
+ if (elf_header->e_ident[EI_CLASS] == ELFCLASS64)
{
- case EM_IA_64:
- case EM_X86_64:
+ /* IA64 64bit libraries are always libc.so.6+. */
+ file_flag = FLAG_IA64_LIB64|FLAG_ELF_LIBC6;
break;
- default:
- error (0, 0, _("%s is for unknown machine %d.\n"),
- file_name, elf_header->e_machine);
- return 1;
}
+ goto failed;
+#endif
+ case EM_386:
+ if (elf_header->e_ident[EI_CLASS] == ELFCLASS32)
+ break;
+ /* Fall through. */
+ default:
+#ifndef SKIP_EM_IA_64
+failed:
+#endif
+ error (0, 0, _("%s is for unknown machine %d.\n"),
+ file_name, elf_header->e_machine);
+ return 1;
+ }
- ret = process_elf64_file (file_name, lib, flag, osversion, soname,
- file_contents, file_length);
- /* IA64/X86-64 64bit libraries are always libc.so.6+. */
- if (!ret)
- switch (elf_header->e_machine)
- {
- case EM_IA_64:
- *flag = FLAG_IA64_LIB64|FLAG_ELF_LIBC6;
- break;
- case EM_X86_64:
- *flag = FLAG_X8664_LIB64|FLAG_ELF_LIBC6;
- break;
- }
+ if (elf_header->e_ident[EI_CLASS] == ELFCLASS32)
+ ret = process_elf32_file (file_name, lib, flag, osversion, soname,
+ file_contents, file_length);
+ else
+ ret = process_elf64_file (file_name, lib, flag, osversion, soname,
+ file_contents, file_length);
- return ret;
- }
+ if (!ret && file_flag)
+ *flag = file_flag;
+
+ return ret;
}
#undef __ELF_NATIVE_CLASS