aboutsummaryrefslogtreecommitdiffstats
path: root/src/dso.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/dso.c')
-rw-r--r--src/dso.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/src/dso.c b/src/dso.c
index c59d81f..1025c77 100644
--- a/src/dso.c
+++ b/src/dso.c
@@ -1141,6 +1141,25 @@ adjust_old_to_new (DSO *dso, GElf_Addr addr)
return addr;
}
+/* Return true is DSO is position independent executable.
+
+ There is no simple way to distinct between shared library
+ and PIE executable. Use presence of interpreter as a heuristic. */
+
+int dso_is_pie(DSO *dso)
+{
+ int i;
+
+ if (dso->ehdr.e_type != ET_DYN)
+ return 0;
+
+ for (i = 0; i < dso->ehdr.e_phnum; ++i)
+ if (dso->phdr[i].p_type == PT_INTERP)
+ return 1;
+
+ return 0;
+}
+
GElf_Addr
adjust_new_to_old (DSO *dso, GElf_Addr addr)
{