patches/glibc/2.2.3/glibc-2.2.3-mips-base-addr-got.patch
changeset 301 2be7232a73ac
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/patches/glibc/2.2.3/glibc-2.2.3-mips-base-addr-got.patch	Sat Jul 28 21:34:41 2007 +0000
     1.3 @@ -0,0 +1,276 @@
     1.4 +From http://www.ltc.com/~brad/mips/glibc-2.2.3-mips-base-addr-got.diff
     1.5 +
     1.6 +Hopefully fixes the error:
     1.7 +
     1.8 +/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
     1.9 +collect2: ld returned 1 exit status
    1.10 +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
    1.11 +
    1.12 +
    1.13 +diff -urNbB glibc-2.2.3/sysdeps/mips/dl-machine.h glibc-2.2.3-mips/sysdeps/mips/dl-machine.h
    1.14 +--- glibc-2.2.3/sysdeps/mips/dl-machine.h	Mon Mar 26 23:53:28 2001
    1.15 ++++ glibc-2.2.3-mips/sysdeps/mips/dl-machine.h	Sun Aug 12 11:08:17 2001
    1.16 +@@ -61,23 +61,6 @@
    1.17 +    in l_info array.  */
    1.18 + #define DT_MIPS(x) (DT_MIPS_##x - DT_LOPROC + DT_NUM)
    1.19 + 
    1.20 +-/*
    1.21 +- * MIPS libraries are usually linked to a non-zero base address.  We
    1.22 +- * subtract the base address from the address where we map the object
    1.23 +- * to.  This results in more efficient address space usage.
    1.24 +- *
    1.25 +- * FIXME: By the time when MAP_BASE_ADDR is called we don't have the
    1.26 +- * DYNAMIC section read.  Until this is fixed make the assumption that
    1.27 +- * libraries have their base address at 0x5ffe0000.  This needs to be
    1.28 +- * fixed before we can safely get rid of this MIPSism.
    1.29 +- */
    1.30 +-#if 0
    1.31 +-#define MAP_BASE_ADDR(l) ((l)->l_info[DT_MIPS(BASE_ADDRESS)] ? \
    1.32 +-			  (l)->l_info[DT_MIPS(BASE_ADDRESS)]->d_un.d_ptr : 0)
    1.33 +-#else
    1.34 +-#define MAP_BASE_ADDR(l) 0x5ffe0000
    1.35 +-#endif
    1.36 +-
    1.37 + /* If there is a DT_MIPS_RLD_MAP entry in the dynamic section, fill it in
    1.38 +    with the run-time address of the r_debug structure  */
    1.39 + #define ELF_MACHINE_DEBUG_SETUP(l,r) \
    1.40 +@@ -557,51 +540,30 @@
    1.41 +   /* Do nothing.  */
    1.42 + }
    1.43 + 
    1.44 ++#ifndef RTLD_BOOTSTRAP
    1.45 + /* Relocate GOT. */
    1.46 + static inline void
    1.47 + elf_machine_got_rel (struct link_map *map, int lazy)
    1.48 + {
    1.49 +   ElfW(Addr) *got;
    1.50 +   ElfW(Sym) *sym;
    1.51 ++  const ElfW(Half) *vernum;
    1.52 +   int i, n, symidx;
    1.53 +-  /*  This function is loaded in dl-reloc as a nested function and can
    1.54 +-      therefore access the variables scope and strtab from
    1.55 +-      _dl_relocate_object.  */
    1.56 +-#ifdef RTLD_BOOTSTRAP
    1.57 +-# define RESOLVE_GOTSYM(sym,sym_index) 0
    1.58 +-#else
    1.59 +-# define RESOLVE_GOTSYM(sym,sym_index)					  \
    1.60 ++
    1.61 ++#define RESOLVE_GOTSYM(sym,vernum,sym_index)				  \
    1.62 +     ({									  \
    1.63 +       const ElfW(Sym) *ref = sym;					  \
    1.64 ++      const struct r_found_version *version				  \
    1.65 ++        = vernum ? &map->l_versions [vernum [sym_index]] : NULL;	  \
    1.66 +       ElfW(Addr) value;							  \
    1.67 +-									  \
    1.68 +-      switch (map->l_info[VERSYMIDX (DT_VERSYM)] != NULL)		  \
    1.69 +-	{								  \
    1.70 +-	default:							  \
    1.71 +-	  {								  \
    1.72 +-	    const ElfW(Half) *vernum =					  \
    1.73 +-	      (const void *) D_PTR (map, l_info[VERSYMIDX (DT_VERSYM)]);  \
    1.74 +-	    ElfW(Half) ndx = vernum[sym_index];				  \
    1.75 +-	    const struct r_found_version *version = &l->l_versions[ndx];  \
    1.76 +-									  \
    1.77 +-	    if (version->hash != 0)					  \
    1.78 +-	      {								  \
    1.79 +-		value = _dl_lookup_versioned_symbol(strtab + sym->st_name,\
    1.80 +-						    map,		  \
    1.81 +-						    &ref, scope, version, \
    1.82 +-						    R_MIPS_REL32, 0);	  \
    1.83 +-		break;							  \
    1.84 +-	      }								  \
    1.85 +-	    /* Fall through.  */					  \
    1.86 +-	  }								  \
    1.87 +-	case 0:								  \
    1.88 +-	  value = _dl_lookup_symbol (strtab + sym->st_name, map, &ref,	  \
    1.89 +-				     scope, R_MIPS_REL32, 0);		  \
    1.90 +-	}								  \
    1.91 +-									  \
    1.92 ++      value = RESOLVE (&ref, version, R_MIPS_REL32);			  \
    1.93 +       (ref)? value + ref->st_value: 0;					  \
    1.94 +     })
    1.95 +-#endif /* RTLD_BOOTSTRAP */
    1.96 ++
    1.97 ++  if (map->l_info[VERSYMIDX (DT_VERSYM)] != NULL)
    1.98 ++    vernum = (const void *) D_PTR (map, l_info[VERSYMIDX (DT_VERSYM)]);
    1.99 ++  else
   1.100 ++    vernum = NULL;
   1.101 + 
   1.102 +   got = (ElfW(Addr) *) D_PTR (map, l_info[DT_PLTGOT]);
   1.103 + 
   1.104 +@@ -639,10 +601,10 @@
   1.105 + 	      && sym->st_value && lazy)
   1.106 + 	    *got = sym->st_value + map->l_addr;
   1.107 + 	  else
   1.108 +-	    *got = RESOLVE_GOTSYM (sym, symidx);
   1.109 ++	    *got = RESOLVE_GOTSYM (sym, vernum, symidx);
   1.110 + 	}
   1.111 +       else if (sym->st_shndx == SHN_COMMON)
   1.112 +-	*got = RESOLVE_GOTSYM (sym, symidx);
   1.113 ++	*got = RESOLVE_GOTSYM (sym, vernum, symidx);
   1.114 +       else if (ELFW(ST_TYPE) (sym->st_info) == STT_FUNC
   1.115 + 	       && *got != sym->st_value
   1.116 + 	       && lazy)
   1.117 +@@ -653,7 +615,7 @@
   1.118 + 	    *got += map->l_addr;
   1.119 + 	}
   1.120 +       else
   1.121 +-	*got = RESOLVE_GOTSYM (sym, symidx);
   1.122 ++	*got = RESOLVE_GOTSYM (sym, vernum, symidx);
   1.123 + 
   1.124 +       ++got;
   1.125 +       ++sym;
   1.126 +@@ -661,9 +623,8 @@
   1.127 +     }
   1.128 + 
   1.129 + #undef RESOLVE_GOTSYM
   1.130 +-
   1.131 +-  return;
   1.132 + }
   1.133 ++#endif
   1.134 + 
   1.135 + /* Set up the loaded object described by L so its stub function
   1.136 +    will jump to the on-demand fixup code __dl_runtime_resolve.  */
   1.137 +diff -urNbB glibc-2.2.3/sysdeps/mips/mips64/rtld-parms glibc-2.2.3-mips/sysdeps/mips/mips64/rtld-parms
   1.138 +--- glibc-2.2.3/sysdeps/mips/mips64/rtld-parms	Sat Jul 12 18:26:11 1997
   1.139 ++++ glibc-2.2.3-mips/sysdeps/mips/mips64/rtld-parms	Wed Dec 31 19:00:00 1969
   1.140 +@@ -1,3 +0,0 @@
   1.141 +-ifndef rtld-wordsize
   1.142 +-rtld-wordsize = 64
   1.143 +-endif
   1.144 +diff -urNbB glibc-2.2.3/sysdeps/mips/mipsel/rtld-parms glibc-2.2.3-mips/sysdeps/mips/mipsel/rtld-parms
   1.145 +--- glibc-2.2.3/sysdeps/mips/mipsel/rtld-parms	Sat Jul 12 18:26:15 1997
   1.146 ++++ glibc-2.2.3-mips/sysdeps/mips/mipsel/rtld-parms	Wed Dec 31 19:00:00 1969
   1.147 +@@ -1,3 +0,0 @@
   1.148 +-ifndef rtld-oformat
   1.149 +-rtld-oformat = elf32-littlemips
   1.150 +-endif
   1.151 +diff -urNbB glibc-2.2.3/sysdeps/mips/rtld-ldscript.in glibc-2.2.3-mips/sysdeps/mips/rtld-ldscript.in
   1.152 +--- glibc-2.2.3/sysdeps/mips/rtld-ldscript.in	Sat Jul 12 18:23:14 1997
   1.153 ++++ glibc-2.2.3-mips/sysdeps/mips/rtld-ldscript.in	Wed Dec 31 19:00:00 1969
   1.154 +@@ -1,106 +0,0 @@
   1.155 +-OUTPUT_FORMAT("@@rtld-oformat@@")
   1.156 +-OUTPUT_ARCH(@@rtld-arch@@)
   1.157 +-ENTRY(@@rtld-entry@@)
   1.158 +-SECTIONS
   1.159 +-{
   1.160 +-  /* Read-only sections, merged into text segment: */
   1.161 +-  . = @@rtld-base@@;
   1.162 +-  .reginfo       : { *(.reginfo) }
   1.163 +-  .dynamic       : { *(.dynamic) }
   1.164 +-  .dynstr        : { *(.dynstr)		}
   1.165 +-  .dynsym        : { *(.dynsym)		}
   1.166 +-  .hash          : { *(.hash)		}
   1.167 +-  .rel.text      : { *(.rel.text)		}
   1.168 +-  .rela.text     : { *(.rela.text) 	}
   1.169 +-  .rel.data      : { *(.rel.data)		}
   1.170 +-  .rela.data     : { *(.rela.data) 	}
   1.171 +-  .rel.rodata    : { *(.rel.rodata) 	}
   1.172 +-  .rela.rodata   : { *(.rela.rodata) 	}
   1.173 +-  .rel.got       : { *(.rel.got)		}
   1.174 +-  .rela.got      : { *(.rela.got)		}
   1.175 +-  .rel.ctors     : { *(.rel.ctors)	}
   1.176 +-  .rela.ctors    : { *(.rela.ctors)	}
   1.177 +-  .rel.dtors     : { *(.rel.dtors)	}
   1.178 +-  .rela.dtors    : { *(.rela.dtors)	}
   1.179 +-  .rel.init      : { *(.rel.init)	}
   1.180 +-  .rela.init     : { *(.rela.init)	}
   1.181 +-  .rel.fini      : { *(.rel.fini)	}
   1.182 +-  .rela.fini     : { *(.rela.fini)	}
   1.183 +-  .rel.bss       : { *(.rel.bss)		}
   1.184 +-  .rela.bss      : { *(.rela.bss)		}
   1.185 +-  .rel.plt       : { *(.rel.plt)		}
   1.186 +-  .rela.plt      : { *(.rela.plt)		}
   1.187 +-  .rodata    : { *(.rodata)  }
   1.188 +-  .rodata1   : { *(.rodata1) }
   1.189 +-  .init          : { *(.init)	} =0
   1.190 +-  .text      :
   1.191 +-  {
   1.192 +-    *(.text)
   1.193 +-    *(.stub)
   1.194 +-    /* .gnu.warning sections are handled specially by elf32.em.  */
   1.195 +-    *(.gnu.warning)
   1.196 +-  } =0
   1.197 +-  .fini      : { *(.fini)    } =0
   1.198 +-  /* Adjust the address for the data segment.  We want to adjust up to
   1.199 +-     the same address within the page on the next page up.  It would
   1.200 +-     be more correct to do this:
   1.201 +-       . = 0x10000000;
   1.202 +-     The current expression does not correctly handle the case of a
   1.203 +-     text segment ending precisely at the end of a page; it causes the
   1.204 +-     data segment to skip a page.  The above expression does not have
   1.205 +-     this problem, but it will currently (2/95) cause BFD to allocate
   1.206 +-     a single segment, combining both text and data, for this case.
   1.207 +-     This will prevent the text segment from being shared among
   1.208 +-     multiple executions of the program; I think that is more
   1.209 +-     important than losing a page of the virtual address space (note
   1.210 +-     that no actual memory is lost; the page which is skipped can not
   1.211 +-     be referenced).  */
   1.212 +-  . += 0x10000;
   1.213 +-  .data    :
   1.214 +-  {
   1.215 +-    *(.data)
   1.216 +-    CONSTRUCTORS
   1.217 +-  }
   1.218 +-  .data1   : { *(.data1) }
   1.219 +-  .ctors         : { *(.ctors)   }
   1.220 +-  .dtors         : { *(.dtors)   }
   1.221 +-  _gp = ALIGN(16) + 0x7ff0;
   1.222 +-  .got           :
   1.223 +-  {
   1.224 +-    *(.got.plt) *(.got)
   1.225 +-   }
   1.226 +-  /* We want the small data sections together, so single-instruction offsets
   1.227 +-     can access them all, and initialized data all before uninitialized, so
   1.228 +-     we can shorten the on-disk segment size.  */
   1.229 +-  .sdata     : { *(.sdata) }
   1.230 +-  .lit8 : { *(.lit8) }
   1.231 +-  .lit4 : { *(.lit4) }
   1.232 +-  .sbss      : { *(.sbss) *(.scommon) }
   1.233 +-  .bss       :
   1.234 +-  {
   1.235 +-   *(.dynbss)
   1.236 +-   *(.bss)
   1.237 +-   *(COMMON)
   1.238 +-  }
   1.239 +-  /* The normal linker scripts created by the binutils doesn't have the
   1.240 +-     symbols end and _end which breaks ld.so's dl-minimal.c.  */
   1.241 +-  _end = . ;
   1.242 +-  PROVIDE (end = .);
   1.243 +-  /* These are needed for ELF backends which have not yet been
   1.244 +-     converted to the new style linker.  */
   1.245 +-  .stab 0 : { *(.stab) }
   1.246 +-  .stabstr 0 : { *(.stabstr) }
   1.247 +-  /* DWARF debug sections.
   1.248 +-     Symbols in the .debug DWARF section are relative to the beginning of the
   1.249 +-     section so we begin .debug at 0.  It's not clear yet what needs to happen
   1.250 +-     for the others.   */
   1.251 +-  .debug          0 : { *(.debug) }
   1.252 +-  .debug_srcinfo  0 : { *(.debug_srcinfo) }
   1.253 +-  .debug_aranges  0 : { *(.debug_aranges) }
   1.254 +-  .debug_pubnames 0 : { *(.debug_pubnames) }
   1.255 +-  .debug_sfnames  0 : { *(.debug_sfnames) }
   1.256 +-  .line           0 : { *(.line) }
   1.257 +-  /* These must appear regardless of  .  */
   1.258 +-  .gptab.sdata : { *(.gptab.data) *(.gptab.sdata) }
   1.259 +-  .gptab.sbss : { *(.gptab.bss) *(.gptab.sbss) }
   1.260 +-}
   1.261 +diff -urNbB glibc-2.2.3/sysdeps/mips/rtld-parms glibc-2.2.3-mips/sysdeps/mips/rtld-parms
   1.262 +--- glibc-2.2.3/sysdeps/mips/rtld-parms	Mon Jul 21 19:04:07 1997
   1.263 ++++ glibc-2.2.3-mips/sysdeps/mips/rtld-parms	Wed Dec 31 19:00:00 1969
   1.264 +@@ -1,15 +0,0 @@
   1.265 +-ifndef rtld-wordsize
   1.266 +-rtld-wordsize = 32
   1.267 +-endif
   1.268 +-ifndef rtld-oformat
   1.269 +-rtld-oformat = elf$(rtld-wordsize)-bigmips
   1.270 +-endif
   1.271 +-ifndef rtld-arch
   1.272 +-rtld-arch = mips
   1.273 +-endif
   1.274 +-ifndef rtld-entry
   1.275 +-rtld-entry = __start
   1.276 +-endif
   1.277 +-ifndef rtld-base
   1.278 +-rtld-base = 0x0fb60000 + SIZEOF_HEADERS
   1.279 +-endif