Browse Source

Patch from Paul Mundt <lethal@linux-sh.org>:

For sh64 we need implicit access to the symtab, primarily to get at the
->st_other value. This presently isn't possible, as PERFORM_BOOTSTRAP_RELOC()
is invoked as such:

        PERFORM_BOOTSTRAP_RELOC(rpnt, reloc_addr, symbol_addr, load_addr);

while we can easily get the symtab_index value from rpnt->r_info, this still
doesn't buy us easy access to the actual table. As such, I've modified
PERFORM_BOOTSTRAP_RELOC() to take an additional SYMTAB argument. Most
architectures aren't going to care about this, but unfortunately we don't
have any other options for sh64.

The following patch fixes up the API for what we need for sh64, and updates
the other architectures appropriately.
Eric Andersen 20 years ago
parent
commit
0a0a648ed6

+ 1 - 1
ldso/ldso/arm/dl-sysdep.h

@@ -31,7 +31,7 @@
  * SYMBOL is the symbol involved in the relocation, and LOAD is the
  * load address.
  */
-#define PERFORM_BOOTSTRAP_RELOC(RELP,REL,SYMBOL,LOAD)		\
+#define PERFORM_BOOTSTRAP_RELOC(RELP,REL,SYMBOL,LOAD,SYMTAB)	\
 	switch(ELF32_R_TYPE((RELP)->r_info)){			\
 	case R_ARM_ABS32:					\
 	  *REL += SYMBOL;					\

+ 1 - 1
ldso/ldso/arm/ld_sysdep.h

@@ -31,7 +31,7 @@
  * SYMBOL is the symbol involved in the relocation, and LOAD is the
  * load address.
  */
-#define PERFORM_BOOTSTRAP_RELOC(RELP,REL,SYMBOL,LOAD)		\
+#define PERFORM_BOOTSTRAP_RELOC(RELP,REL,SYMBOL,LOAD,SYMTAB)	\
 	switch(ELF32_R_TYPE((RELP)->r_info)){			\
 	case R_ARM_ABS32:					\
 	  *REL += SYMBOL;					\

+ 1 - 1
ldso/ldso/cris/dl-sysdep.h

@@ -24,7 +24,7 @@
  * SYMBOL is the symbol involved in the relocation, and LOAD is the
  * load address.
  */
-#define PERFORM_BOOTSTRAP_RELOC(RELP, REL, SYMBOL, LOAD)		\
+#define PERFORM_BOOTSTRAP_RELOC(RELP, REL, SYMBOL, LOAD, SYMTAB)	\
 	switch (ELF32_R_TYPE((RELP)->r_info)) {				\
 		case R_CRIS_GLOB_DAT:					\
 		case R_CRIS_JUMP_SLOT:					\

+ 1 - 1
ldso/ldso/cris/ld_sysdep.h

@@ -24,7 +24,7 @@
  * SYMBOL is the symbol involved in the relocation, and LOAD is the
  * load address.
  */
-#define PERFORM_BOOTSTRAP_RELOC(RELP, REL, SYMBOL, LOAD)		\
+#define PERFORM_BOOTSTRAP_RELOC(RELP, REL, SYMBOL, LOAD, SYMTAB)	\
 	switch (ELF32_R_TYPE((RELP)->r_info)) {				\
 		case R_CRIS_GLOB_DAT:					\
 		case R_CRIS_JUMP_SLOT:					\

+ 25 - 25
ldso/ldso/i386/dl-sysdep.h

@@ -18,11 +18,11 @@
 /*
  * Initialization sequence for a GOT.
  */
-#define INIT_GOT(GOT_BASE,MODULE) \
-{				\
-  GOT_BASE[2] = (unsigned long) _dl_linux_resolve; \
-  GOT_BASE[1] = (unsigned long) MODULE; \
-}
+#define INIT_GOT(GOT_BASE,MODULE)				\
+do {								\
+  GOT_BASE[2] = (unsigned long) _dl_linux_resolve;		\
+  GOT_BASE[1] = (unsigned long) MODULE;				\
+} while(0)
 
 /*
  * Here is a macro to perform a relocation.  This is only used when
@@ -31,23 +31,23 @@
  * SYMBOL is the symbol involved in the relocation, and LOAD is the
  * load address.
  */
-#define PERFORM_BOOTSTRAP_RELOC(RELP,REL,SYMBOL,LOAD) \
-	switch(ELF32_R_TYPE((RELP)->r_info)){		\
-	case R_386_32:		\
-	  *REL += SYMBOL;		\
-	  break;		\
-	case R_386_PC32:		\
-	  *REL += SYMBOL - (unsigned long) REL;		\
-	  break;		\
-	case R_386_GLOB_DAT:		\
-	case R_386_JMP_SLOT:		\
-	  *REL = SYMBOL;		\
-	  break;		\
-	case R_386_RELATIVE:		\
-	  *REL += (unsigned long) LOAD;		\
-	  break;		\
-	default:		\
-	  _dl_exit(1);		\
+#define PERFORM_BOOTSTRAP_RELOC(RELP,REL,SYMBOL,LOAD,SYMTAB)	\
+	switch(ELF32_R_TYPE((RELP)->r_info)){			\
+	case R_386_32:						\
+	  *REL += SYMBOL;					\
+	  break;						\
+	case R_386_PC32:					\
+	  *REL += SYMBOL - (unsigned long) REL;			\
+	  break;						\
+	case R_386_GLOB_DAT:					\
+	case R_386_JMP_SLOT:					\
+	  *REL = SYMBOL;					\
+	  break;						\
+	case R_386_RELATIVE:					\
+	  *REL += (unsigned long) LOAD;				\
+	  break;						\
+	default:						\
+	  _dl_exit(1);						\
 	}
 
 
@@ -56,9 +56,9 @@
  * is done.  This routine has to exit the current function, then 
  * call the _dl_elf_main function.
  */
-#define START()		\
-	__asm__ volatile ("leave\n\t" \
-		    "jmp *%%eax\n\t"	\
+#define START()							\
+	__asm__ volatile ("leave\n\t"				\
+		    "jmp *%%eax\n\t"				\
 		    : "=a" (status) :	"a" (_dl_elf_main))
 
 

+ 25 - 25
ldso/ldso/i386/ld_sysdep.h

@@ -18,11 +18,11 @@
 /*
  * Initialization sequence for a GOT.
  */
-#define INIT_GOT(GOT_BASE,MODULE) \
-{				\
-  GOT_BASE[2] = (unsigned long) _dl_linux_resolve; \
-  GOT_BASE[1] = (unsigned long) MODULE; \
-}
+#define INIT_GOT(GOT_BASE,MODULE)				\
+do {								\
+  GOT_BASE[2] = (unsigned long) _dl_linux_resolve;		\
+  GOT_BASE[1] = (unsigned long) MODULE;				\
+} while(0)
 
 /*
  * Here is a macro to perform a relocation.  This is only used when
@@ -31,23 +31,23 @@
  * SYMBOL is the symbol involved in the relocation, and LOAD is the
  * load address.
  */
-#define PERFORM_BOOTSTRAP_RELOC(RELP,REL,SYMBOL,LOAD) \
-	switch(ELF32_R_TYPE((RELP)->r_info)){		\
-	case R_386_32:		\
-	  *REL += SYMBOL;		\
-	  break;		\
-	case R_386_PC32:		\
-	  *REL += SYMBOL - (unsigned long) REL;		\
-	  break;		\
-	case R_386_GLOB_DAT:		\
-	case R_386_JMP_SLOT:		\
-	  *REL = SYMBOL;		\
-	  break;		\
-	case R_386_RELATIVE:		\
-	  *REL += (unsigned long) LOAD;		\
-	  break;		\
-	default:		\
-	  _dl_exit(1);		\
+#define PERFORM_BOOTSTRAP_RELOC(RELP,REL,SYMBOL,LOAD,SYMTAB)	\
+	switch(ELF32_R_TYPE((RELP)->r_info)){			\
+	case R_386_32:						\
+	  *REL += SYMBOL;					\
+	  break;						\
+	case R_386_PC32:					\
+	  *REL += SYMBOL - (unsigned long) REL;			\
+	  break;						\
+	case R_386_GLOB_DAT:					\
+	case R_386_JMP_SLOT:					\
+	  *REL = SYMBOL;					\
+	  break;						\
+	case R_386_RELATIVE:					\
+	  *REL += (unsigned long) LOAD;				\
+	  break;						\
+	default:						\
+	  _dl_exit(1);						\
 	}
 
 
@@ -56,9 +56,9 @@
  * is done.  This routine has to exit the current function, then 
  * call the _dl_elf_main function.
  */
-#define START()		\
-	__asm__ volatile ("leave\n\t" \
-		    "jmp *%%eax\n\t"	\
+#define START()							\
+	__asm__ volatile ("leave\n\t"				\
+		    "jmp *%%eax\n\t"				\
 		    : "=a" (status) :	"a" (_dl_elf_main))
 
 

+ 7 - 5
ldso/ldso/ldso.c

@@ -287,7 +287,7 @@ LD_BOOT(unsigned long args)
   __asm__("\tbl _GLOBAL_OFFSET_TABLE_-4@local\n\t":"=l"(got));
 #elif defined(__mips__)
   __asm__("\tmove %0, $28\n\tsubu %0,%0,0x7ff0\n\t":"=r"(got));
-#elif defined(__sh__)
+#elif defined(__sh__) && !defined(__SH5__)
   __asm__(
 "       mov.l    1f, %0\n"
 "       mova     1f, r0\n"
@@ -583,11 +583,13 @@ LD_BOOT(unsigned long args)
 				SEND_STDERR(strtab + symtab[symtab_index].st_name);
 				SEND_STDERR("\n");
 #endif  
+				PERFORM_BOOTSTRAP_RELOC(rpnt, reloc_addr, symbol_addr, load_addr, &symtab[symtab_index]);
+			} else {
+				/*
+				 * Use this machine-specific macro to perform the actual relocation.
+				 */
+				PERFORM_BOOTSTRAP_RELOC(rpnt, reloc_addr, symbol_addr, load_addr, NULL);
 			}
-			/*
-			 * Use this machine-specific macro to perform the actual relocation.
-			 */
-			PERFORM_BOOTSTRAP_RELOC(rpnt, reloc_addr, symbol_addr, load_addr);
 		}
 	}
 

+ 1 - 1
ldso/ldso/m68k/dl-sysdep.h

@@ -22,7 +22,7 @@
    are performing, REL is the pointer to the address we are
    relocating.  SYMBOL is the symbol involved in the relocation, and
    LOAD is the load address. */
-#define PERFORM_BOOTSTRAP_RELOC(RELP,REL,SYMBOL,LOAD)		\
+#define PERFORM_BOOTSTRAP_RELOC(RELP,REL,SYMBOL,LOAD,SYMTAB)	\
   switch (ELF32_R_TYPE ((RELP)->r_info))			\
     {								\
     case R_68K_8:						\

+ 1 - 1
ldso/ldso/m68k/ld_sysdep.h

@@ -22,7 +22,7 @@
    are performing, REL is the pointer to the address we are
    relocating.  SYMBOL is the symbol involved in the relocation, and
    LOAD is the load address. */
-#define PERFORM_BOOTSTRAP_RELOC(RELP,REL,SYMBOL,LOAD)		\
+#define PERFORM_BOOTSTRAP_RELOC(RELP,REL,SYMBOL,LOAD,SYMTAB)	\
   switch (ELF32_R_TYPE ((RELP)->r_info))			\
     {								\
     case R_68K_8:						\

+ 1 - 1
ldso/ldso/mips/dl-sysdep.h

@@ -86,7 +86,7 @@ do {																	\
  * Here is a macro to perform a relocation.  This is only used when
  * bootstrapping the dynamic loader.
  */
-#define PERFORM_BOOTSTRAP_RELOC(RELP,REL,SYMBOL,LOAD)					\
+#define PERFORM_BOOTSTRAP_RELOC(RELP,REL,SYMBOL,LOAD,SYMTAB)			\
 	switch(ELF32_R_TYPE((RELP)->r_info)) {								\
 	case R_MIPS_REL32:													\
 		if (symtab_index) {												\

+ 1 - 1
ldso/ldso/mips/ld_sysdep.h

@@ -86,7 +86,7 @@ do {																	\
  * Here is a macro to perform a relocation.  This is only used when
  * bootstrapping the dynamic loader.
  */
-#define PERFORM_BOOTSTRAP_RELOC(RELP,REL,SYMBOL,LOAD)					\
+#define PERFORM_BOOTSTRAP_RELOC(RELP,REL,SYMBOL,LOAD,SYMTAB)			\
 	switch(ELF32_R_TYPE((RELP)->r_info)) {								\
 	case R_MIPS_REL32:													\
 		if (symtab_index) {												\

+ 1 - 1
ldso/ldso/powerpc/dl-sysdep.h

@@ -71,7 +71,7 @@
  * load address.
  */
 // finaladdr = LOAD ?
-#define PERFORM_BOOTSTRAP_RELOC(RELP,REL,SYMBOL,LOAD) \
+#define PERFORM_BOOTSTRAP_RELOC(RELP,REL,SYMBOL,LOAD,SYMTAB) \
 	{int type=ELF32_R_TYPE((RELP)->r_info);		\
 	if(type==R_PPC_NONE){				\
 	}else if(type==R_PPC_ADDR32){			\

+ 1 - 1
ldso/ldso/powerpc/ld_sysdep.h

@@ -71,7 +71,7 @@
  * load address.
  */
 // finaladdr = LOAD ?
-#define PERFORM_BOOTSTRAP_RELOC(RELP,REL,SYMBOL,LOAD) \
+#define PERFORM_BOOTSTRAP_RELOC(RELP,REL,SYMBOL,LOAD,SYMTAB) \
 	{int type=ELF32_R_TYPE((RELP)->r_info);		\
 	if(type==R_PPC_NONE){				\
 	}else if(type==R_PPC_ADDR32){			\

+ 1 - 1
ldso/ldso/sh/dl-sysdep.h

@@ -31,7 +31,7 @@
  * SYMBOL is the symbol involved in the relocation, and LOAD is the
  * load address.
  */
-#define PERFORM_BOOTSTRAP_RELOC(RELP,REL,SYMBOL,LOAD)		\
+#define PERFORM_BOOTSTRAP_RELOC(RELP,REL,SYMBOL,LOAD,SYMTAB)	\
 	switch(ELF32_R_TYPE((RELP)->r_info)){			\
 	case R_SH_REL32:					\
 		*(REL)  = (SYMBOL) + (RELP)->r_addend		\

+ 1 - 1
ldso/ldso/sh/ld_sysdep.h

@@ -31,7 +31,7 @@
  * SYMBOL is the symbol involved in the relocation, and LOAD is the
  * load address.
  */
-#define PERFORM_BOOTSTRAP_RELOC(RELP,REL,SYMBOL,LOAD)		\
+#define PERFORM_BOOTSTRAP_RELOC(RELP,REL,SYMBOL,LOAD,SYMTAB)	\
 	switch(ELF32_R_TYPE((RELP)->r_info)){			\
 	case R_SH_REL32:					\
 		*(REL)  = (SYMBOL) + (RELP)->r_addend		\

+ 1 - 1
ldso/ldso/sparc/dl-sysdep.h

@@ -40,7 +40,7 @@
  * Here is a macro to perform a relocation.  This is only used when
  * bootstrapping the dynamic loader.
  */
-#define PERFORM_BOOTSTRAP_RELOC(RELP,REL,SYMBOL,LOAD) \
+#define PERFORM_BOOTSTRAP_RELOC(RELP,REL,SYMBOL,LOAD,SYMTAB) \
 	switch(ELF32_R_TYPE((RELP)->r_info)) {		\
 	case R_SPARC_32:				\
 	  *REL = SYMBOL + (RELP)->r_addend;		\

+ 1 - 1
ldso/ldso/sparc/ld_sysdep.h

@@ -40,7 +40,7 @@
  * Here is a macro to perform a relocation.  This is only used when
  * bootstrapping the dynamic loader.
  */
-#define PERFORM_BOOTSTRAP_RELOC(RELP,REL,SYMBOL,LOAD) \
+#define PERFORM_BOOTSTRAP_RELOC(RELP,REL,SYMBOL,LOAD,SYMTAB) \
 	switch(ELF32_R_TYPE((RELP)->r_info)) {		\
 	case R_SPARC_32:				\
 	  *REL = SYMBOL + (RELP)->r_addend;		\