summaryrefslogtreecommitdiff
path: root/ldso/include
diff options
context:
space:
mode:
Diffstat (limited to 'ldso/include')
-rw-r--r--ldso/include/dl-defs.h33
-rw-r--r--ldso/include/dl-elf.h2
2 files changed, 34 insertions, 1 deletions
diff --git a/ldso/include/dl-defs.h b/ldso/include/dl-defs.h
index db65f78f6..932f6ac53 100644
--- a/ldso/include/dl-defs.h
+++ b/ldso/include/dl-defs.h
@@ -75,6 +75,14 @@ typedef struct {
# define DL_LOADADDR_TYPE ElfW(Addr)
#endif
+/* When DL_LOADADDR_TYPE is not a scalar value, or some different
+ * computation is needed to relocate an address, define this.
+ */
+#ifndef DL_RELOC_ADDR
+# define DL_RELOC_ADDR(LOADADDR, ADDR) \
+ ((LOADADDR) + (ADDR))
+#endif
+
/* Initialize a LOADADDR representing the loader itself. It's only
* called from DL_BOOT, so additional arguments passed to it may be
* referenced.
@@ -84,6 +92,24 @@ typedef struct {
((LOADADDR) = (BASEADDR))
#endif
+/* Define if any declarations/definitions of local variables are
+ * needed in a function that calls DT_INIT_LOADADDR or
+ * DL_INIT_LOADADDR_HDR. Declarations must be properly terminated
+ * with a semicolon, and non-declaration statements are forbidden.
+ */
+#ifndef DL_INIT_LOADADDR_EXTRA_DECLS
+# define DL_INIT_LOADADDR_EXTRA_DECLS /* int i; */
+#endif
+
+/* Prepare a DL_LOADADDR_TYPE data structure for incremental
+ * initialization with DL_INIT_LOADADDR_HDR, given pointers to a base
+ * load address and to program headers.
+ */
+#ifndef DL_INIT_LOADADDR
+# define DL_INIT_LOADADDR(LOADADDR, BASEADDR, PHDR, PHDRCNT) \
+ ((LOADADDR) = (BASEADDR))
+#endif
+
/* Initialize a LOADADDR representing the program. It's called from
* DL_BOOT only.
*/
@@ -92,6 +118,13 @@ typedef struct {
((LOADADDR) = (DL_LOADADDR_TYPE)(BASEADDR))
#endif
+/* Convert a DL_LOADADDR_TYPE to an identifying pointer. Used mostly
+ * for debugging.
+ */
+#ifndef DL_LOADADDR_BASE
+# define DL_LOADADDR_BASE(LOADADDR) (LOADADDR)
+#endif
+
/* Test whether a given ADDR is more likely to be within the memory
* region mapped to TPNT (a struct elf_resolve *) than to TFROM.
* Everywhere that this is used, TFROM is initially NULL, and whenever
diff --git a/ldso/include/dl-elf.h b/ldso/include/dl-elf.h
index 7b609d592..9d8da0d13 100644
--- a/ldso/include/dl-elf.h
+++ b/ldso/include/dl-elf.h
@@ -141,7 +141,7 @@ void __dl_parse_dynamic_info(ElfW(Dyn) *dpnt, unsigned long dynamic_info[],
#define ADJUST_DYN_INFO(tag, load_off) \
do { \
if (dynamic_info[tag]) \
- dynamic_info[tag] += load_off; \
+ dynamic_info[tag] = (unsigned long) DL_RELOC_ADDR(load_off, dynamic_info[tag]); \
} while(0)
ADJUST_DYN_INFO(DT_HASH, load_off);
ADJUST_DYN_INFO(DT_PLTGOT, load_off);