[PATCH 09/12] metag: Add support for loading shared objects into core memories.
Markos Chandras
markos.chandras at gmail.com
Thu Feb 21 10:12:06 UTC 2013
From: Markos Chandras <markos.chandras at imgtec.com>
Signed-off-by: Markos Chandras <markos.chandras at imgtec.com>
---
ldso/ldso/metag/dl-inlines.h | 38 ++++++++++++++++++++++++++++++++++++++
ldso/ldso/metag/dl-sysdep.h | 25 +++++++++++++++++++++++++
2 files changed, 63 insertions(+)
create mode 100644 ldso/ldso/metag/dl-inlines.h
diff --git a/ldso/ldso/metag/dl-inlines.h b/ldso/ldso/metag/dl-inlines.h
new file mode 100644
index 0000000..ff1a6e1
--- /dev/null
+++ b/ldso/ldso/metag/dl-inlines.h
@@ -0,0 +1,38 @@
+/*
+ * Copyright (C) 2013, Imagination Technologies Ltd.
+ * All rights reserved
+ */
+
+static __always_inline int
+__dl_is_special_segment (Elf32_Ehdr *epnt,
+ Elf32_Phdr *ppnt)
+{
+ if (ppnt->p_type != PT_LOAD &&
+ ppnt->p_type != PT_DYNAMIC)
+ return 0;
+
+ if (ppnt->p_vaddr >= 0x80000000 &&
+ ppnt->p_vaddr < 0x82060000)
+ return 1;
+
+ if (ppnt->p_vaddr >= 0xe0200000 &&
+ ppnt->p_vaddr < 0xe0260000)
+ return 1;
+
+ return 0;
+}
+
+static __always_inline char *
+__dl_map_segment (Elf32_Ehdr *epnt,
+ Elf32_Phdr *ppnt,
+ int infile,
+ int flags)
+{
+ char *addr = (char *)ppnt->p_vaddr;
+
+ if (_DL_PREAD (infile, addr, ppnt->p_filesz, ppnt->p_offset) != ppnt->p_filesz) {
+ return 0;
+ }
+
+ return addr;
+}
diff --git a/ldso/ldso/metag/dl-sysdep.h b/ldso/ldso/metag/dl-sysdep.h
index b162f88..48059a3 100644
--- a/ldso/ldso/metag/dl-sysdep.h
+++ b/ldso/ldso/metag/dl-sysdep.h
@@ -116,3 +116,28 @@ elf_machine_relative(Elf32_Addr load_off, const Elf32_Addr rel_addr,
}
#define DL_MALLOC_ALIGN 8
+
+#define HAVE_DL_INLINES_H
+
+#define DL_IS_SPECIAL_SEGMENT(EPNT, PPNT) \
+ __dl_is_special_segment(EPNT, PPNT)
+#define DL_MAP_SEGMENT(EPNT, PPNT, INFILE, FLAGS) \
+ __dl_map_segment (EPNT, PPNT, INFILE, FLAGS)
+
+#define DL_CHECK_LIB_TYPE(epnt, piclib, _dl_progname, libname) \
+do \
+{ \
+ ElfW(Phdr) *ppnt_; \
+ char *header_ = (char *)epnt; \
+ ppnt_ = (ElfW(Phdr) *)(intptr_t) & header_[epnt->e_phoff]; \
+ if (ppnt_->p_vaddr >= 0x80000000 && \
+ ppnt_->p_vaddr < 0x82060000) \
+ (piclib) = 2; \
+ if (ppnt_->p_vaddr >= 0xe0200000 && \
+ ppnt_->p_vaddr < 0xe0260000) \
+ (piclib) = 2; \
+} \
+while (0)
+
+#define _DL_PREAD(FD, BUF, SIZE, OFFSET) \
+ (_dl_pread((FD), (BUF), (SIZE), (OFFSET)))
--
1.8.1.2
More information about the uClibc
mailing list