about summary refs log tree commit diff
path: root/elf
diff options
context:
space:
mode:
Diffstat (limited to 'elf')
-rw-r--r--elf/dl-load.c31
-rw-r--r--elf/dl-runtime.c4
-rw-r--r--elf/elf.h65
3 files changed, 96 insertions, 4 deletions
diff --git a/elf/dl-load.c b/elf/dl-load.c
index a103d38548..10cc074a6a 100644
--- a/elf/dl-load.c
+++ b/elf/dl-load.c
@@ -67,6 +67,18 @@ int _dl_zerofd = -1;
 #define ANONFD _dl_zerofd
 #endif
 
+/* Handle situations where we have a preferred location in memory for
+   the shared objects.  */
+#ifdef ELF_PREFERRED_ADDRESS_DATA
+ELF_PREFERRED_ADDRESS_DATA;
+#endif
+#ifndef ELF_PREFERRED_ADDRESS
+#define ELF_PREFERRED_ADDRESS(loader, maplength, mapstartpref) (mapstartpref)
+#endif
+#ifndef ELF_FIXED_ADDRESS
+#define ELF_FIXED_ADDRESS(loader, mapstart) ((void) 0)
+#endif
+
 size_t _dl_pagesize;
 
 
@@ -315,11 +327,16 @@ _dl_map_object_from_fd (char *name, int fd, char *realname,
 	   So we map the first segment without MAP_FIXED, but with its
 	   extent increased to cover all the segments.  Then we remove
 	   access from excess portion, and there is known sufficient space
-	   there to remap from the later segments.  */
+	   there to remap from the later segments.
+
+	   As a refinement, sometimes we have an address that we would
+	   prefer to map such objects at; but this is only a preference,
+	   the OS can do whatever it likes. */
  	caddr_t mapat;
-	mapat = map_segment (c->mapstart,
-			     loadcmds[nloadcmds - 1].allocend - c->mapstart,
-			     c->prot, 0, c->mapoff);
+	ElfW(Addr) mappref;
+	size_t maplength = loadcmds[nloadcmds - 1].allocend - c->mapstart;
+	mappref = ELF_PREFERRED_ADDRESS (loader, maplength, c->mapstart);
+	mapat = map_segment (mappref, maplength, c->prot, 0, c->mapoff);
 	l->l_addr = (ElfW(Addr)) mapat - c->mapstart;
 
 	/* Change protection on the excess portion to disallow all access;
@@ -332,6 +349,12 @@ _dl_map_object_from_fd (char *name, int fd, char *realname,
 		    0);
 	goto postmap;
       }
+    else
+      {
+	/* Notify ELF_PREFERRED_ADDRESS that we have to load this one
+	   fixed.  */
+	ELF_FIXED_ADDRESS (loader, c->mapstart);
+      }
 
     while (c < &loadcmds[nloadcmds])
       {
diff --git a/elf/dl-runtime.c b/elf/dl-runtime.c
index 08c605cd0f..502c35d5d2 100644
--- a/elf/dl-runtime.c
+++ b/elf/dl-runtime.c
@@ -153,7 +153,11 @@ fixup (
   *_dl_global_scope_end = NULL;
 
   /* Return the address that was written by the relocation.  */
+#ifdef ELF_FIXUP_RETURNS_ADDRESS
+  return (ElfW(Addr))(l->l_addr + reloc->r_offset);
+#else
   return *(ElfW(Addr) *) (l->l_addr + reloc->r_offset);
+#endif
 }
 
 
diff --git a/elf/elf.h b/elf/elf.h
index f6779ba16a..76f6c6865d 100644
--- a/elf/elf.h
+++ b/elf/elf.h
@@ -915,6 +915,71 @@ typedef Elf32_Addr Elf32_Conflict;
 #define R_ALPHA_JMP_SLOT	26	/* Create PLT entry */
 #define R_ALPHA_RELATIVE	27	/* Adjust by program base */
 
+
+/* PowerPC specific declarations */
+
+/* PowerPC relocations defined by the ABIs */
+#define R_PPC_NONE		0
+#define R_PPC_ADDR32		1
+#define R_PPC_ADDR24		2
+#define R_PPC_ADDR16		3
+#define R_PPC_ADDR16_LO		4
+#define R_PPC_ADDR16_HI		5
+#define R_PPC_ADDR16_HA		6
+#define R_PPC_ADDR14		7
+#define R_PPC_ADDR14_BRTAKEN	8
+#define R_PPC_ADDR14_BRNTAKEN	9
+#define R_PPC_REL24		10
+#define R_PPC_REL14		11
+#define R_PPC_REL14_BRTAKEN	12
+#define R_PPC_REL14_BRNTAKEN	13
+#define R_PPC_GOT16		14
+#define R_PPC_GOT16_LO		15
+#define R_PPC_GOT16_HI		16
+#define R_PPC_GOT16_HA		17
+#define R_PPC_PLTREL24		18
+#define R_PPC_COPY		19
+#define R_PPC_GLOB_DAT		20
+#define R_PPC_JMP_SLOT		21
+#define R_PPC_RELATIVE		22
+#define R_PPC_LOCAL24PC		23
+#define R_PPC_UADDR32		24
+#define R_PPC_UADDR16		25
+#define R_PPC_REL32		26
+#define R_PPC_PLT32		27
+#define R_PPC_PLTREL32		28
+#define R_PPC_PLT16_LO		29
+#define R_PPC_PLT16_HI		30
+#define R_PPC_PLT16_HA		31
+#define R_PPC_SDAREL16		32
+#define R_PPC_SECTOFF		33
+#define R_PPC_SECTOFF_LO	34
+#define R_PPC_SECTOFF_HI	35
+#define R_PPC_SECTOFF_HA	36
+
+/* The remaining relocs are from the Embedded ELF ABI, and are not
+   in the SVR4 ELF ABI.  */
+#define R_PPC_EMB_NADDR32	101
+#define R_PPC_EMB_NADDR16	102
+#define R_PPC_EMB_NADDR16_LO	103
+#define R_PPC_EMB_NADDR16_HI	104
+#define R_PPC_EMB_NADDR16_HA	105
+#define R_PPC_EMB_SDAI16	106
+#define R_PPC_EMB_SDA2I16	107
+#define R_PPC_EMB_SDA2REL	108
+#define R_PPC_EMB_SDA21		109
+#define R_PPC_EMB_MRKREF	110
+#define R_PPC_EMB_RELSEC16	111
+#define R_PPC_EMB_RELST_LO	112
+#define R_PPC_EMB_RELST_HI	113
+#define R_PPC_EMB_RELST_HA	114
+#define R_PPC_EMB_BIT_FLD	115
+#define R_PPC_EMB_RELSDA	116
+
+/* This is a phony reloc to handle any old fashioned TOC16 references
+   that may still be in object files.  */
+#define R_PPC_TOC16		255
+
 __END_DECLS
 
 #endif	/* elf.h */