patches/glibc/2.2.3/glibc-2.2.3-mips-base-addr-got.patch
author "Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
Sat Jul 28 21:34:41 2007 +0000 (2007-07-28)
changeset 301 2be7232a73ac
permissions -rw-r--r--
Bump version to 0.2.2.
yann@1
     1
From http://www.ltc.com/~brad/mips/glibc-2.2.3-mips-base-addr-got.diff
yann@1
     2
yann@1
     3
Hopefully fixes the error:
yann@1
     4
yann@1
     5
/opt/crosstool/mipsel-unknown-linux-gnu/gcc-3.2.3-glibc-2.2.3/lib/gcc-lib/mipsel-unknown-linux-gnu/3.2.3/../../../../mipsel-unknown-linux-gnu/bin/ld: target elf32-littlemips not found
yann@1
     6
collect2: ld returned 1 exit status
yann@1
     7
make[2]: *** [/home/dank/downloads/crosstool-0.24/build/mipsel-unknown-linux-gnu/gcc-3.2.3-glibc-2.2.3/build-glibc/elf/ld.so] Error 1
yann@1
     8
yann@1
     9
yann@1
    10
diff -urNbB glibc-2.2.3/sysdeps/mips/dl-machine.h glibc-2.2.3-mips/sysdeps/mips/dl-machine.h
yann@1
    11
--- glibc-2.2.3/sysdeps/mips/dl-machine.h	Mon Mar 26 23:53:28 2001
yann@1
    12
+++ glibc-2.2.3-mips/sysdeps/mips/dl-machine.h	Sun Aug 12 11:08:17 2001
yann@1
    13
@@ -61,23 +61,6 @@
yann@1
    14
    in l_info array.  */
yann@1
    15
 #define DT_MIPS(x) (DT_MIPS_##x - DT_LOPROC + DT_NUM)
yann@1
    16
 
yann@1
    17
-/*
yann@1
    18
- * MIPS libraries are usually linked to a non-zero base address.  We
yann@1
    19
- * subtract the base address from the address where we map the object
yann@1
    20
- * to.  This results in more efficient address space usage.
yann@1
    21
- *
yann@1
    22
- * FIXME: By the time when MAP_BASE_ADDR is called we don't have the
yann@1
    23
- * DYNAMIC section read.  Until this is fixed make the assumption that
yann@1
    24
- * libraries have their base address at 0x5ffe0000.  This needs to be
yann@1
    25
- * fixed before we can safely get rid of this MIPSism.
yann@1
    26
- */
yann@1
    27
-#if 0
yann@1
    28
-#define MAP_BASE_ADDR(l) ((l)->l_info[DT_MIPS(BASE_ADDRESS)] ? \
yann@1
    29
-			  (l)->l_info[DT_MIPS(BASE_ADDRESS)]->d_un.d_ptr : 0)
yann@1
    30
-#else
yann@1
    31
-#define MAP_BASE_ADDR(l) 0x5ffe0000
yann@1
    32
-#endif
yann@1
    33
-
yann@1
    34
 /* If there is a DT_MIPS_RLD_MAP entry in the dynamic section, fill it in
yann@1
    35
    with the run-time address of the r_debug structure  */
yann@1
    36
 #define ELF_MACHINE_DEBUG_SETUP(l,r) \
yann@1
    37
@@ -557,51 +540,30 @@
yann@1
    38
   /* Do nothing.  */
yann@1
    39
 }
yann@1
    40
 
yann@1
    41
+#ifndef RTLD_BOOTSTRAP
yann@1
    42
 /* Relocate GOT. */
yann@1
    43
 static inline void
yann@1
    44
 elf_machine_got_rel (struct link_map *map, int lazy)
yann@1
    45
 {
yann@1
    46
   ElfW(Addr) *got;
yann@1
    47
   ElfW(Sym) *sym;
yann@1
    48
+  const ElfW(Half) *vernum;
yann@1
    49
   int i, n, symidx;
yann@1
    50
-  /*  This function is loaded in dl-reloc as a nested function and can
yann@1
    51
-      therefore access the variables scope and strtab from
yann@1
    52
-      _dl_relocate_object.  */
yann@1
    53
-#ifdef RTLD_BOOTSTRAP
yann@1
    54
-# define RESOLVE_GOTSYM(sym,sym_index) 0
yann@1
    55
-#else
yann@1
    56
-# define RESOLVE_GOTSYM(sym,sym_index)					  \
yann@1
    57
+
yann@1
    58
+#define RESOLVE_GOTSYM(sym,vernum,sym_index)				  \
yann@1
    59
     ({									  \
yann@1
    60
       const ElfW(Sym) *ref = sym;					  \
yann@1
    61
+      const struct r_found_version *version				  \
yann@1
    62
+        = vernum ? &map->l_versions [vernum [sym_index]] : NULL;	  \
yann@1
    63
       ElfW(Addr) value;							  \
yann@1
    64
-									  \
yann@1
    65
-      switch (map->l_info[VERSYMIDX (DT_VERSYM)] != NULL)		  \
yann@1
    66
-	{								  \
yann@1
    67
-	default:							  \
yann@1
    68
-	  {								  \
yann@1
    69
-	    const ElfW(Half) *vernum =					  \
yann@1
    70
-	      (const void *) D_PTR (map, l_info[VERSYMIDX (DT_VERSYM)]);  \
yann@1
    71
-	    ElfW(Half) ndx = vernum[sym_index];				  \
yann@1
    72
-	    const struct r_found_version *version = &l->l_versions[ndx];  \
yann@1
    73
-									  \
yann@1
    74
-	    if (version->hash != 0)					  \
yann@1
    75
-	      {								  \
yann@1
    76
-		value = _dl_lookup_versioned_symbol(strtab + sym->st_name,\
yann@1
    77
-						    map,		  \
yann@1
    78
-						    &ref, scope, version, \
yann@1
    79
-						    R_MIPS_REL32, 0);	  \
yann@1
    80
-		break;							  \
yann@1
    81
-	      }								  \
yann@1
    82
-	    /* Fall through.  */					  \
yann@1
    83
-	  }								  \
yann@1
    84
-	case 0:								  \
yann@1
    85
-	  value = _dl_lookup_symbol (strtab + sym->st_name, map, &ref,	  \
yann@1
    86
-				     scope, R_MIPS_REL32, 0);		  \
yann@1
    87
-	}								  \
yann@1
    88
-									  \
yann@1
    89
+      value = RESOLVE (&ref, version, R_MIPS_REL32);			  \
yann@1
    90
       (ref)? value + ref->st_value: 0;					  \
yann@1
    91
     })
yann@1
    92
-#endif /* RTLD_BOOTSTRAP */
yann@1
    93
+
yann@1
    94
+  if (map->l_info[VERSYMIDX (DT_VERSYM)] != NULL)
yann@1
    95
+    vernum = (const void *) D_PTR (map, l_info[VERSYMIDX (DT_VERSYM)]);
yann@1
    96
+  else
yann@1
    97
+    vernum = NULL;
yann@1
    98
 
yann@1
    99
   got = (ElfW(Addr) *) D_PTR (map, l_info[DT_PLTGOT]);
yann@1
   100
 
yann@1
   101
@@ -639,10 +601,10 @@
yann@1
   102
 	      && sym->st_value && lazy)
yann@1
   103
 	    *got = sym->st_value + map->l_addr;
yann@1
   104
 	  else
yann@1
   105
-	    *got = RESOLVE_GOTSYM (sym, symidx);
yann@1
   106
+	    *got = RESOLVE_GOTSYM (sym, vernum, symidx);
yann@1
   107
 	}
yann@1
   108
       else if (sym->st_shndx == SHN_COMMON)
yann@1
   109
-	*got = RESOLVE_GOTSYM (sym, symidx);
yann@1
   110
+	*got = RESOLVE_GOTSYM (sym, vernum, symidx);
yann@1
   111
       else if (ELFW(ST_TYPE) (sym->st_info) == STT_FUNC
yann@1
   112
 	       && *got != sym->st_value
yann@1
   113
 	       && lazy)
yann@1
   114
@@ -653,7 +615,7 @@
yann@1
   115
 	    *got += map->l_addr;
yann@1
   116
 	}
yann@1
   117
       else
yann@1
   118
-	*got = RESOLVE_GOTSYM (sym, symidx);
yann@1
   119
+	*got = RESOLVE_GOTSYM (sym, vernum, symidx);
yann@1
   120
 
yann@1
   121
       ++got;
yann@1
   122
       ++sym;
yann@1
   123
@@ -661,9 +623,8 @@
yann@1
   124
     }
yann@1
   125
 
yann@1
   126
 #undef RESOLVE_GOTSYM
yann@1
   127
-
yann@1
   128
-  return;
yann@1
   129
 }
yann@1
   130
+#endif
yann@1
   131
 
yann@1
   132
 /* Set up the loaded object described by L so its stub function
yann@1
   133
    will jump to the on-demand fixup code __dl_runtime_resolve.  */
yann@1
   134
diff -urNbB glibc-2.2.3/sysdeps/mips/mips64/rtld-parms glibc-2.2.3-mips/sysdeps/mips/mips64/rtld-parms
yann@1
   135
--- glibc-2.2.3/sysdeps/mips/mips64/rtld-parms	Sat Jul 12 18:26:11 1997
yann@1
   136
+++ glibc-2.2.3-mips/sysdeps/mips/mips64/rtld-parms	Wed Dec 31 19:00:00 1969
yann@1
   137
@@ -1,3 +0,0 @@
yann@1
   138
-ifndef rtld-wordsize
yann@1
   139
-rtld-wordsize = 64
yann@1
   140
-endif
yann@1
   141
diff -urNbB glibc-2.2.3/sysdeps/mips/mipsel/rtld-parms glibc-2.2.3-mips/sysdeps/mips/mipsel/rtld-parms
yann@1
   142
--- glibc-2.2.3/sysdeps/mips/mipsel/rtld-parms	Sat Jul 12 18:26:15 1997
yann@1
   143
+++ glibc-2.2.3-mips/sysdeps/mips/mipsel/rtld-parms	Wed Dec 31 19:00:00 1969
yann@1
   144
@@ -1,3 +0,0 @@
yann@1
   145
-ifndef rtld-oformat
yann@1
   146
-rtld-oformat = elf32-littlemips
yann@1
   147
-endif
yann@1
   148
diff -urNbB glibc-2.2.3/sysdeps/mips/rtld-ldscript.in glibc-2.2.3-mips/sysdeps/mips/rtld-ldscript.in
yann@1
   149
--- glibc-2.2.3/sysdeps/mips/rtld-ldscript.in	Sat Jul 12 18:23:14 1997
yann@1
   150
+++ glibc-2.2.3-mips/sysdeps/mips/rtld-ldscript.in	Wed Dec 31 19:00:00 1969
yann@1
   151
@@ -1,106 +0,0 @@
yann@1
   152
-OUTPUT_FORMAT("@@rtld-oformat@@")
yann@1
   153
-OUTPUT_ARCH(@@rtld-arch@@)
yann@1
   154
-ENTRY(@@rtld-entry@@)
yann@1
   155
-SECTIONS
yann@1
   156
-{
yann@1
   157
-  /* Read-only sections, merged into text segment: */
yann@1
   158
-  . = @@rtld-base@@;
yann@1
   159
-  .reginfo       : { *(.reginfo) }
yann@1
   160
-  .dynamic       : { *(.dynamic) }
yann@1
   161
-  .dynstr        : { *(.dynstr)		}
yann@1
   162
-  .dynsym        : { *(.dynsym)		}
yann@1
   163
-  .hash          : { *(.hash)		}
yann@1
   164
-  .rel.text      : { *(.rel.text)		}
yann@1
   165
-  .rela.text     : { *(.rela.text) 	}
yann@1
   166
-  .rel.data      : { *(.rel.data)		}
yann@1
   167
-  .rela.data     : { *(.rela.data) 	}
yann@1
   168
-  .rel.rodata    : { *(.rel.rodata) 	}
yann@1
   169
-  .rela.rodata   : { *(.rela.rodata) 	}
yann@1
   170
-  .rel.got       : { *(.rel.got)		}
yann@1
   171
-  .rela.got      : { *(.rela.got)		}
yann@1
   172
-  .rel.ctors     : { *(.rel.ctors)	}
yann@1
   173
-  .rela.ctors    : { *(.rela.ctors)	}
yann@1
   174
-  .rel.dtors     : { *(.rel.dtors)	}
yann@1
   175
-  .rela.dtors    : { *(.rela.dtors)	}
yann@1
   176
-  .rel.init      : { *(.rel.init)	}
yann@1
   177
-  .rela.init     : { *(.rela.init)	}
yann@1
   178
-  .rel.fini      : { *(.rel.fini)	}
yann@1
   179
-  .rela.fini     : { *(.rela.fini)	}
yann@1
   180
-  .rel.bss       : { *(.rel.bss)		}
yann@1
   181
-  .rela.bss      : { *(.rela.bss)		}
yann@1
   182
-  .rel.plt       : { *(.rel.plt)		}
yann@1
   183
-  .rela.plt      : { *(.rela.plt)		}
yann@1
   184
-  .rodata    : { *(.rodata)  }
yann@1
   185
-  .rodata1   : { *(.rodata1) }
yann@1
   186
-  .init          : { *(.init)	} =0
yann@1
   187
-  .text      :
yann@1
   188
-  {
yann@1
   189
-    *(.text)
yann@1
   190
-    *(.stub)
yann@1
   191
-    /* .gnu.warning sections are handled specially by elf32.em.  */
yann@1
   192
-    *(.gnu.warning)
yann@1
   193
-  } =0
yann@1
   194
-  .fini      : { *(.fini)    } =0
yann@1
   195
-  /* Adjust the address for the data segment.  We want to adjust up to
yann@1
   196
-     the same address within the page on the next page up.  It would
yann@1
   197
-     be more correct to do this:
yann@1
   198
-       . = 0x10000000;
yann@1
   199
-     The current expression does not correctly handle the case of a
yann@1
   200
-     text segment ending precisely at the end of a page; it causes the
yann@1
   201
-     data segment to skip a page.  The above expression does not have
yann@1
   202
-     this problem, but it will currently (2/95) cause BFD to allocate
yann@1
   203
-     a single segment, combining both text and data, for this case.
yann@1
   204
-     This will prevent the text segment from being shared among
yann@1
   205
-     multiple executions of the program; I think that is more
yann@1
   206
-     important than losing a page of the virtual address space (note
yann@1
   207
-     that no actual memory is lost; the page which is skipped can not
yann@1
   208
-     be referenced).  */
yann@1
   209
-  . += 0x10000;
yann@1
   210
-  .data    :
yann@1
   211
-  {
yann@1
   212
-    *(.data)
yann@1
   213
-    CONSTRUCTORS
yann@1
   214
-  }
yann@1
   215
-  .data1   : { *(.data1) }
yann@1
   216
-  .ctors         : { *(.ctors)   }
yann@1
   217
-  .dtors         : { *(.dtors)   }
yann@1
   218
-  _gp = ALIGN(16) + 0x7ff0;
yann@1
   219
-  .got           :
yann@1
   220
-  {
yann@1
   221
-    *(.got.plt) *(.got)
yann@1
   222
-   }
yann@1
   223
-  /* We want the small data sections together, so single-instruction offsets
yann@1
   224
-     can access them all, and initialized data all before uninitialized, so
yann@1
   225
-     we can shorten the on-disk segment size.  */
yann@1
   226
-  .sdata     : { *(.sdata) }
yann@1
   227
-  .lit8 : { *(.lit8) }
yann@1
   228
-  .lit4 : { *(.lit4) }
yann@1
   229
-  .sbss      : { *(.sbss) *(.scommon) }
yann@1
   230
-  .bss       :
yann@1
   231
-  {
yann@1
   232
-   *(.dynbss)
yann@1
   233
-   *(.bss)
yann@1
   234
-   *(COMMON)
yann@1
   235
-  }
yann@1
   236
-  /* The normal linker scripts created by the binutils doesn't have the
yann@1
   237
-     symbols end and _end which breaks ld.so's dl-minimal.c.  */
yann@1
   238
-  _end = . ;
yann@1
   239
-  PROVIDE (end = .);
yann@1
   240
-  /* These are needed for ELF backends which have not yet been
yann@1
   241
-     converted to the new style linker.  */
yann@1
   242
-  .stab 0 : { *(.stab) }
yann@1
   243
-  .stabstr 0 : { *(.stabstr) }
yann@1
   244
-  /* DWARF debug sections.
yann@1
   245
-     Symbols in the .debug DWARF section are relative to the beginning of the
yann@1
   246
-     section so we begin .debug at 0.  It's not clear yet what needs to happen
yann@1
   247
-     for the others.   */
yann@1
   248
-  .debug          0 : { *(.debug) }
yann@1
   249
-  .debug_srcinfo  0 : { *(.debug_srcinfo) }
yann@1
   250
-  .debug_aranges  0 : { *(.debug_aranges) }
yann@1
   251
-  .debug_pubnames 0 : { *(.debug_pubnames) }
yann@1
   252
-  .debug_sfnames  0 : { *(.debug_sfnames) }
yann@1
   253
-  .line           0 : { *(.line) }
yann@1
   254
-  /* These must appear regardless of  .  */
yann@1
   255
-  .gptab.sdata : { *(.gptab.data) *(.gptab.sdata) }
yann@1
   256
-  .gptab.sbss : { *(.gptab.bss) *(.gptab.sbss) }
yann@1
   257
-}
yann@1
   258
diff -urNbB glibc-2.2.3/sysdeps/mips/rtld-parms glibc-2.2.3-mips/sysdeps/mips/rtld-parms
yann@1
   259
--- glibc-2.2.3/sysdeps/mips/rtld-parms	Mon Jul 21 19:04:07 1997
yann@1
   260
+++ glibc-2.2.3-mips/sysdeps/mips/rtld-parms	Wed Dec 31 19:00:00 1969
yann@1
   261
@@ -1,15 +0,0 @@
yann@1
   262
-ifndef rtld-wordsize
yann@1
   263
-rtld-wordsize = 32
yann@1
   264
-endif
yann@1
   265
-ifndef rtld-oformat
yann@1
   266
-rtld-oformat = elf$(rtld-wordsize)-bigmips
yann@1
   267
-endif
yann@1
   268
-ifndef rtld-arch
yann@1
   269
-rtld-arch = mips
yann@1
   270
-endif
yann@1
   271
-ifndef rtld-entry
yann@1
   272
-rtld-entry = __start
yann@1
   273
-endif
yann@1
   274
-ifndef rtld-base
yann@1
   275
-rtld-base = 0x0fb60000 + SIZEOF_HEADERS
yann@1
   276
-endif