Remove support for non-PIE executables
Don't support the dynamic linker loading ET_EXEC executables. Only
support ET_DYN executables.
Bug: 14566672
Change-Id: Ia1f2bfffe7ea867c1cd62e67d7fd637c60c0728d
diff --git a/linker/linker.cpp b/linker/linker.cpp
index 08231ea..1f32f6d 100755
--- a/linker/linker.cpp
+++ b/linker/linker.cpp
@@ -2071,6 +2071,12 @@
si->dynamic = NULL;
si->ref_count = 1;
+ ElfW(Ehdr)* elf_hdr = reinterpret_cast<ElfW(Ehdr)*>(si->base);
+ if (elf_hdr->e_type != ET_DYN) {
+ __libc_format_fd(2, "error: only position independent executables (PIE) are supported.\n");
+ exit(EXIT_FAILURE);
+ }
+
// Use LD_LIBRARY_PATH and LD_PRELOAD (but only if we aren't setuid/setgid).
parse_LD_LIBRARY_PATH(ldpath_env);
parse_LD_PRELOAD(ldpreload_env);