mips-compile-error.patch 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577
  1. diff -Nur glibc-2.10.1/ports/sysdeps/mips/dl-lookup.c glibc-2.10.90/ports/sysdeps/mips/dl-lookup.c
  2. --- glibc-2.10.1/ports/sysdeps/mips/dl-lookup.c 2009-08-20 08:59:52.000000000 +0200
  3. +++ glibc-2.10.90/ports/sysdeps/mips/dl-lookup.c 2009-05-26 22:53:27.000000000 +0200
  4. @@ -1,6 +1,9 @@
  5. /* Look up a symbol in the loaded objects.
  6. - MIPS/Linux version - special handling of non-PIC undefined symbol rules.
  7. - Copyright (C) 1995-2005, 2006, 2007, 2009 Free Software Foundation, Inc.
  8. + MIPS/Linux version - this is identical to the common version, but
  9. + because it is in sysdeps/mips, it gets sysdeps/mips/do-lookup.h.
  10. + Using <do-lookup.h> instead of "do-lookup.h" would work too.
  11. +
  12. + Copyright (C) 1995-2005, 2006, 2007 Free Software Foundation, Inc.
  13. This file is part of the GNU C Library.
  14. The GNU C Library is free software; you can redistribute it and/or
  15. @@ -70,387 +73,8 @@
  16. #endif
  17. -/* Inner part of the lookup functions. We return a value > 0 if we
  18. - found the symbol, the value 0 if nothing is found and < 0 if
  19. - something bad happened. */
  20. -static int
  21. -__attribute_noinline__
  22. -do_lookup_x (const char *undef_name, uint_fast32_t new_hash,
  23. - unsigned long int *old_hash, const ElfW(Sym) *ref,
  24. - struct sym_val *result, struct r_scope_elem *scope, size_t i,
  25. - const struct r_found_version *const version, int flags,
  26. - struct link_map *skip, int type_class, struct link_map *undef_map)
  27. -{
  28. - size_t n = scope->r_nlist;
  29. - /* Make sure we read the value before proceeding. Otherwise we
  30. - might use r_list pointing to the initial scope and r_nlist being
  31. - the value after a resize. That is the only path in dl-open.c not
  32. - protected by GSCOPE. A read barrier here might be to expensive. */
  33. - __asm volatile ("" : "+r" (n), "+m" (scope->r_list));
  34. - struct link_map **list = scope->r_list;
  35. -
  36. - do
  37. - {
  38. - /* These variables are used in the nested function. */
  39. - Elf_Symndx symidx;
  40. - int num_versions = 0;
  41. - const ElfW(Sym) *versioned_sym = NULL;
  42. -
  43. - const struct link_map *map = list[i]->l_real;
  44. -
  45. - /* Here come the extra test needed for `_dl_lookup_symbol_skip'. */
  46. - if (map == skip)
  47. - continue;
  48. -
  49. - /* Don't search the executable when resolving a copy reloc. */
  50. - if ((type_class & ELF_RTYPE_CLASS_COPY) && map->l_type == lt_executable)
  51. - continue;
  52. -
  53. - /* Do not look into objects which are going to be removed. */
  54. - if (map->l_removed)
  55. - continue;
  56. -
  57. - /* Print some debugging info if wanted. */
  58. - if (__builtin_expect (GLRO(dl_debug_mask) & DL_DEBUG_SYMBOLS, 0))
  59. - _dl_debug_printf ("symbol=%s; lookup in file=%s [%lu]\n",
  60. - undef_name,
  61. - map->l_name[0] ? map->l_name : rtld_progname,
  62. - map->l_ns);
  63. -
  64. - /* If the hash table is empty there is nothing to do here. */
  65. - if (map->l_nbuckets == 0)
  66. - continue;
  67. -
  68. - /* The tables for this map. */
  69. - const ElfW(Sym) *symtab = (const void *) D_PTR (map, l_info[DT_SYMTAB]);
  70. - const char *strtab = (const void *) D_PTR (map, l_info[DT_STRTAB]);
  71. -
  72. -
  73. - /* Nested routine to check whether the symbol matches. */
  74. - const ElfW(Sym) *
  75. - __attribute_noinline__
  76. - check_match (const ElfW(Sym) *sym)
  77. - {
  78. - unsigned int stt = ELFW(ST_TYPE) (sym->st_info);
  79. - assert (ELF_RTYPE_CLASS_PLT == 1);
  80. - /* The semantics of zero/non-zero values of undefined symbols
  81. - differs depending on whether the non-PIC ABI is in use.
  82. - Under the non-PIC ABI, a non-zero value indicates that
  83. - there is an address reference to the symbol and thus it
  84. - must always be resolved (except when resolving a jump slot
  85. - relocation) to the PLT entry whose address is provided as
  86. - the symbol's value; a zero value indicates that this
  87. - canonical-address behaviour is not required. Yet under the
  88. - classic MIPS psABI, a zero value indicates that there is an
  89. - address reference to the function and the dynamic linker
  90. - must resolve the symbol immediately upon loading. To avoid
  91. - conflict, symbols for which the dynamic linker must assume
  92. - the non-PIC ABI semantics are marked with the STO_MIPS_PLT
  93. - flag. */
  94. - if (__builtin_expect ((sym->st_value == 0 /* No value. */
  95. - && stt != STT_TLS)
  96. - || (sym->st_shndx == SHN_UNDEF
  97. - && !(sym->st_other & STO_MIPS_PLT))
  98. - || (type_class & (sym->st_shndx == SHN_UNDEF)),
  99. - 0))
  100. - return NULL;
  101. -
  102. - /* Ignore all but STT_NOTYPE, STT_OBJECT, STT_FUNC,
  103. - STT_COMMON, STT_TLS, and STT_GNU_IFUNC since these are no
  104. - code/data definitions. */
  105. -#define ALLOWED_STT \
  106. - ((1 << STT_NOTYPE) | (1 << STT_OBJECT) | (1 << STT_FUNC) \
  107. - | (1 << STT_COMMON) | (1 << STT_TLS) | (1 << STT_GNU_IFUNC))
  108. - if (__builtin_expect (((1 << stt) & ALLOWED_STT) == 0, 0))
  109. - return NULL;
  110. -
  111. - if (sym != ref && strcmp (strtab + sym->st_name, undef_name))
  112. - /* Not the symbol we are looking for. */
  113. - return NULL;
  114. -
  115. - const ElfW(Half) *verstab = map->l_versyms;
  116. - if (version != NULL)
  117. - {
  118. - if (__builtin_expect (verstab == NULL, 0))
  119. - {
  120. - /* We need a versioned symbol but haven't found any. If
  121. - this is the object which is referenced in the verneed
  122. - entry it is a bug in the library since a symbol must
  123. - not simply disappear.
  124. -
  125. - It would also be a bug in the object since it means that
  126. - the list of required versions is incomplete and so the
  127. - tests in dl-version.c haven't found a problem.*/
  128. - assert (version->filename == NULL
  129. - || ! _dl_name_match_p (version->filename, map));
  130. -
  131. - /* Otherwise we accept the symbol. */
  132. - }
  133. - else
  134. - {
  135. - /* We can match the version information or use the
  136. - default one if it is not hidden. */
  137. - ElfW(Half) ndx = verstab[symidx] & 0x7fff;
  138. - if ((map->l_versions[ndx].hash != version->hash
  139. - || strcmp (map->l_versions[ndx].name, version->name))
  140. - && (version->hidden || map->l_versions[ndx].hash
  141. - || (verstab[symidx] & 0x8000)))
  142. - /* It's not the version we want. */
  143. - return NULL;
  144. - }
  145. - }
  146. - else
  147. - {
  148. - /* No specific version is selected. There are two ways we
  149. - can got here:
  150. -
  151. - - a binary which does not include versioning information
  152. - is loaded
  153. -
  154. - - dlsym() instead of dlvsym() is used to get a symbol which
  155. - might exist in more than one form
  156. -
  157. - If the library does not provide symbol version information
  158. - there is no problem at at: we simply use the symbol if it
  159. - is defined.
  160. -
  161. - These two lookups need to be handled differently if the
  162. - library defines versions. In the case of the old
  163. - unversioned application the oldest (default) version
  164. - should be used. In case of a dlsym() call the latest and
  165. - public interface should be returned. */
  166. - if (verstab != NULL)
  167. - {
  168. - if ((verstab[symidx] & 0x7fff)
  169. - >= ((flags & DL_LOOKUP_RETURN_NEWEST) ? 2 : 3))
  170. - {
  171. - /* Don't accept hidden symbols. */
  172. - if ((verstab[symidx] & 0x8000) == 0
  173. - && num_versions++ == 0)
  174. - /* No version so far. */
  175. - versioned_sym = sym;
  176. -
  177. - return NULL;
  178. - }
  179. - }
  180. - }
  181. -
  182. - /* There cannot be another entry for this symbol so stop here. */
  183. - return sym;
  184. - }
  185. -
  186. - const ElfW(Sym) *sym;
  187. - const ElfW(Addr) *bitmask = map->l_gnu_bitmask;
  188. - if (__builtin_expect (bitmask != NULL, 1))
  189. - {
  190. - ElfW(Addr) bitmask_word
  191. - = bitmask[(new_hash / __ELF_NATIVE_CLASS)
  192. - & map->l_gnu_bitmask_idxbits];
  193. -
  194. - unsigned int hashbit1 = new_hash & (__ELF_NATIVE_CLASS - 1);
  195. - unsigned int hashbit2 = ((new_hash >> map->l_gnu_shift)
  196. - & (__ELF_NATIVE_CLASS - 1));
  197. -
  198. - if (__builtin_expect ((bitmask_word >> hashbit1)
  199. - & (bitmask_word >> hashbit2) & 1, 0))
  200. - {
  201. - Elf32_Word bucket = map->l_gnu_buckets[new_hash
  202. - % map->l_nbuckets];
  203. - if (bucket != 0)
  204. - {
  205. - const Elf32_Word *hasharr = &map->l_gnu_chain_zero[bucket];
  206. -
  207. - do
  208. - if (((*hasharr ^ new_hash) >> 1) == 0)
  209. - {
  210. - symidx = hasharr - map->l_gnu_chain_zero;
  211. - sym = check_match (&symtab[symidx]);
  212. - if (sym != NULL)
  213. - goto found_it;
  214. - }
  215. - while ((*hasharr++ & 1u) == 0);
  216. - }
  217. - }
  218. - /* No symbol found. */
  219. - symidx = SHN_UNDEF;
  220. - }
  221. - else
  222. - {
  223. - if (*old_hash == 0xffffffff)
  224. - *old_hash = _dl_elf_hash (undef_name);
  225. -
  226. - /* Use the old SysV-style hash table. Search the appropriate
  227. - hash bucket in this object's symbol table for a definition
  228. - for the same symbol name. */
  229. - for (symidx = map->l_buckets[*old_hash % map->l_nbuckets];
  230. - symidx != STN_UNDEF;
  231. - symidx = map->l_chain[symidx])
  232. - {
  233. - sym = check_match (&symtab[symidx]);
  234. - if (sym != NULL)
  235. - goto found_it;
  236. - }
  237. - }
  238. -
  239. - /* If we have seen exactly one versioned symbol while we are
  240. - looking for an unversioned symbol and the version is not the
  241. - default version we still accept this symbol since there are
  242. - no possible ambiguities. */
  243. - sym = num_versions == 1 ? versioned_sym : NULL;
  244. -
  245. - if (sym != NULL)
  246. - {
  247. - found_it:
  248. - switch (__builtin_expect (ELFW(ST_BIND) (sym->st_info), STB_GLOBAL))
  249. - {
  250. - case STB_WEAK:
  251. - /* Weak definition. Use this value if we don't find another. */
  252. - if (__builtin_expect (GLRO(dl_dynamic_weak), 0))
  253. - {
  254. - if (! result->s)
  255. - {
  256. - result->s = sym;
  257. - result->m = (struct link_map *) map;
  258. - }
  259. - break;
  260. - }
  261. - /* FALLTHROUGH */
  262. - case STB_GLOBAL:
  263. - success:
  264. - /* Global definition. Just what we need. */
  265. - result->s = sym;
  266. - result->m = (struct link_map *) map;
  267. - return 1;
  268. -
  269. - case STB_GNU_UNIQUE:;
  270. - /* We have to determine whether we already found a
  271. - symbol with this name before. If not then we have to
  272. - add it to the search table. If we already found a
  273. - definition we have to use it. */
  274. - void enter (struct unique_sym *table, size_t size,
  275. - unsigned int hash, const char *name,
  276. - const ElfW(Sym) *sym, const struct link_map *map)
  277. - {
  278. - size_t idx = hash % size;
  279. - size_t hash2 = 1 + hash % (size - 2);
  280. - while (1)
  281. - {
  282. - if (table[idx].hashval == 0)
  283. - {
  284. - table[idx].hashval = hash;
  285. - table[idx].name = strtab + sym->st_name;
  286. - if ((type_class & ELF_RTYPE_CLASS_COPY) != 0)
  287. - {
  288. - table[idx].sym = ref;
  289. - table[idx].map = undef_map;
  290. - }
  291. - else
  292. - {
  293. - table[idx].sym = sym;
  294. - table[idx].map = map;
  295. - }
  296. - return;
  297. - }
  298. -
  299. - idx += hash2;
  300. - if (idx >= size)
  301. - idx -= size;
  302. - }
  303. - }
  304. -
  305. - struct unique_sym_table *tab
  306. - = &GL(dl_ns)[map->l_ns]._ns_unique_sym_table;
  307. -
  308. - __rtld_lock_lock_recursive (tab->lock);
  309. -
  310. - struct unique_sym *entries = tab->entries;
  311. - size_t size = tab->size;
  312. - if (entries != NULL)
  313. - {
  314. - size_t idx = new_hash % size;
  315. - size_t hash2 = 1 + new_hash % (size - 2);
  316. - while (1)
  317. - {
  318. - if (entries[idx].hashval == new_hash
  319. - && strcmp (entries[idx].name, undef_name) == 0)
  320. - {
  321. - result->s = entries[idx].sym;
  322. - result->m = (struct link_map *) entries[idx].map;
  323. - __rtld_lock_unlock_recursive (tab->lock);
  324. - return 1;
  325. - }
  326. -
  327. - if (entries[idx].hashval == 0
  328. - && entries[idx].name == NULL)
  329. - break;
  330. -
  331. - idx += hash2;
  332. - if (idx >= size)
  333. - idx -= size;
  334. - }
  335. -
  336. - if (size * 3 <= tab->n_elements)
  337. - {
  338. - /* Expand the table. */
  339. - size_t newsize = _dl_higher_prime_number (size);
  340. - struct unique_sym *newentries
  341. - = calloc (sizeof (struct unique_sym), newsize);
  342. - if (newentries == NULL)
  343. - {
  344. - nomem:
  345. - __rtld_lock_unlock_recursive (tab->lock);
  346. - _dl_fatal_printf ("out of memory\n");
  347. - }
  348. -
  349. - for (idx = 0; idx < size; ++idx)
  350. - if (entries[idx].hashval != 0)
  351. - enter (newentries, newsize, entries[idx].hashval,
  352. - entries[idx].name, entries[idx].sym,
  353. - entries[idx].map);
  354. -
  355. - tab->free (entries);
  356. - tab->size = newsize;
  357. - entries = tab->entries = newentries;
  358. - tab->free = free;
  359. - }
  360. - }
  361. - else
  362. - {
  363. -#define INITIAL_NUNIQUE_SYM_TABLE 31
  364. - size = INITIAL_NUNIQUE_SYM_TABLE;
  365. - entries = calloc (sizeof (struct unique_sym), size);
  366. - if (entries == NULL)
  367. - goto nomem;
  368. -
  369. - tab->entries = entries;
  370. - tab->size = size;
  371. - tab->free = free;
  372. - }
  373. -
  374. - enter (entries, size, new_hash, strtab + sym->st_name, sym, map);
  375. - ++tab->n_elements;
  376. -
  377. - __rtld_lock_unlock_recursive (tab->lock);
  378. -
  379. - goto success;
  380. -
  381. - default:
  382. - /* Local symbols are ignored. */
  383. - break;
  384. - }
  385. - }
  386. -
  387. - /* If this current map is the one mentioned in the verneed entry
  388. - and we have not found a weak entry, it is a bug. */
  389. - if (symidx == STN_UNDEF && version != NULL && version->filename != NULL
  390. - && __builtin_expect (_dl_name_match_p (version->filename, map), 0))
  391. - return -1;
  392. - }
  393. - while (++i < n);
  394. -
  395. - /* We have not found anything until now. */
  396. - return 0;
  397. -}
  398. +/* The actual lookup code. */
  399. +#include "do-lookup.h"
  400. static uint_fast32_t
  401. @@ -717,7 +341,7 @@
  402. {
  403. int res = do_lookup_x (undef_name, new_hash, &old_hash, *ref,
  404. &current_value, *scope, start, version, flags,
  405. - skip_map, type_class, undef_map);
  406. + skip_map, type_class);
  407. if (res > 0)
  408. break;
  409. @@ -790,7 +414,7 @@
  410. for (scope = symbol_scope; *scope != NULL; i = 0, ++scope)
  411. if (do_lookup_x (undef_name, new_hash, &old_hash, *ref,
  412. &protected_value, *scope, i, version, flags,
  413. - skip_map, ELF_RTYPE_CLASS_PLT, NULL) != 0)
  414. + skip_map, ELF_RTYPE_CLASS_PLT) != 0)
  415. break;
  416. if (protected_value.s != NULL && protected_value.m != undef_map)
  417. @@ -916,26 +540,21 @@
  418. do_lookup_x (undef_name, new_hash, &old_hash, *ref, &val,
  419. undef_map->l_local_scope[0], 0, version, 0, NULL,
  420. - type_class, undef_map);
  421. + type_class);
  422. if (val.s != value->s || val.m != value->m)
  423. conflict = 1;
  424. }
  425. - if (value->s)
  426. - {
  427. - if (__builtin_expect (ELFW(ST_TYPE) (value->s->st_info)
  428. - == STT_TLS, 0))
  429. - type_class = 4;
  430. - else if (__builtin_expect (ELFW(ST_TYPE) (value->s->st_info)
  431. - == STT_GNU_IFUNC, 0))
  432. - type_class |= 8;
  433. - }
  434. + if (value->s
  435. + && (__builtin_expect (ELFW(ST_TYPE) (value->s->st_info)
  436. + == STT_TLS, 0)))
  437. + type_class = 4;
  438. if (conflict
  439. || GLRO(dl_trace_prelink_map) == undef_map
  440. || GLRO(dl_trace_prelink_map) == NULL
  441. - || type_class >= 4)
  442. + || type_class == 4)
  443. {
  444. _dl_printf ("%s 0x%0*Zx 0x%0*Zx -> 0x%0*Zx 0x%0*Zx ",
  445. conflict ? "conflict" : "lookup",
  446. diff -Nur glibc-2.10.1/ports/sysdeps/mips/do-lookup.h glibc-2.10.90/ports/sysdeps/mips/do-lookup.h
  447. --- glibc-2.10.1/ports/sysdeps/mips/do-lookup.h 1970-01-01 01:00:00.000000000 +0100
  448. +++ glibc-2.10.90/ports/sysdeps/mips/do-lookup.h 2009-05-26 22:53:27.000000000 +0200
  449. @@ -0,0 +1,37 @@
  450. +/* MIPS-specific veneer to GLIBC's do-lookup.h.
  451. + Copyright (C) 2008 Free Software Foundation, Inc.
  452. + This file is part of the GNU C Library.
  453. +
  454. + The GNU C Library is free software; you can redistribute it and/or
  455. + modify it under the terms of the GNU Lesser General Public
  456. + License as published by the Free Software Foundation; either
  457. + version 2.1 of the License, or (at your option) any later version.
  458. +
  459. + The GNU C Library is distributed in the hope that it will be useful,
  460. + but WITHOUT ANY WARRANTY; without even the implied warranty of
  461. + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  462. + Lesser General Public License for more details.
  463. +
  464. + You should have received a copy of the GNU Lesser General Public
  465. + License along with the GNU C Library; if not, write to the Free
  466. + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
  467. + 02111-1307 USA. */
  468. +
  469. +/* The semantics of zero/non-zero values of undefined symbols differs
  470. + depending on whether the non-PIC ABI is in use. Under the non-PIC ABI,
  471. + a non-zero value indicates that there is an address reference to the
  472. + symbol and thus it must always be resolved (except when resolving a jump
  473. + slot relocation) to the PLT entry whose address is provided as the
  474. + symbol's value; a zero value indicates that this canonical-address
  475. + behaviour is not required. Yet under the classic MIPS psABI, a zero value
  476. + indicates that there is an address reference to the function and the
  477. + dynamic linker must resolve the symbol immediately upon loading. To
  478. + avoid conflict, symbols for which the dynamic linker must assume the
  479. + non-PIC ABI semantics are marked with the STO_MIPS_PLT flag. The
  480. + following ugly hack causes the code in the platform-independent
  481. + do-lookup.h file to check this flag correctly. */
  482. +#define st_value st_shndx == SHN_UNDEF && !(sym->st_other & STO_MIPS_PLT)) \
  483. + || (sym->st_value
  484. +#include_next "do-lookup.h"
  485. +#undef st_value
  486. +
  487. diff -Nur glibc-2.10.1/ports/sysdeps/mips/__longjmp.c glibc-2.10.90/ports/sysdeps/mips/__longjmp.c
  488. --- glibc-2.10.1/ports/sysdeps/mips/__longjmp.c 2009-08-20 08:59:52.000000000 +0200
  489. +++ glibc-2.10.90/ports/sysdeps/mips/__longjmp.c 2009-05-26 22:53:26.000000000 +0200
  490. @@ -25,19 +25,19 @@
  491. #endif
  492. void
  493. -__longjmp (env_arg, val_arg)
  494. - __jmp_buf env_arg;
  495. +__longjmp (env, val_arg)
  496. + __jmp_buf env;
  497. int val_arg;
  498. {
  499. /* gcc 1.39.19 miscompiled the longjmp routine (as it did setjmp before
  500. the hack around it); force it to use $a1 for the longjmp value.
  501. Without this it saves $a1 in a register which gets clobbered
  502. along the way. */
  503. - register struct __jmp_buf_internal_tag *env asm ("a0");
  504. register int val asm ("a1");
  505. #ifdef CHECK_SP
  506. register long sp asm ("$29");
  507. - CHECK_SP (env[0].__sp, sp, long);
  508. + if ((long) (env[0].__sp) < sp)
  509. + __fortify_fail ("longjmp causes uninitialized stack frame");
  510. #endif
  511. #ifdef __mips_hard_float
  512. diff -Nur glibc-2.10.1/ports/sysdeps/mips/____longjmp_chk.c glibc-2.10.90/ports/sysdeps/mips/____longjmp_chk.c
  513. --- glibc-2.10.1/ports/sysdeps/mips/____longjmp_chk.c 1970-01-01 01:00:00.000000000 +0100
  514. +++ glibc-2.10.90/ports/sysdeps/mips/____longjmp_chk.c 2009-05-26 22:53:26.000000000 +0200
  515. @@ -0,0 +1,22 @@
  516. +/* Copyright (C) 2009 Free Software Foundation, Inc.
  517. + This file is part of the GNU C Library.
  518. +
  519. + The GNU C Library is free software; you can redistribute it and/or
  520. + modify it under the terms of the GNU Lesser General Public
  521. + License as published by the Free Software Foundation; either
  522. + version 2.1 of the License, or (at your option) any later version.
  523. +
  524. + The GNU C Library is distributed in the hope that it will be useful,
  525. + but WITHOUT ANY WARRANTY; without even the implied warranty of
  526. + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  527. + Lesser General Public License for more details.
  528. +
  529. + You should have received a copy of the GNU Lesser General Public
  530. + License along with the GNU C Library; if not, write to the Free
  531. + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
  532. + 02111-1307 USA. */
  533. +
  534. +#include <stdio.h>
  535. +#define __longjmp ____longjmp_chk
  536. +#define CHECK_SP
  537. +#include <__longjmp.c>
  538. diff -Nur glibc-2.10.1/ports/sysdeps/mips/mips64/__longjmp.c glibc-2.10.90/ports/sysdeps/mips/mips64/__longjmp.c
  539. --- glibc-2.10.1/ports/sysdeps/mips/mips64/__longjmp.c 2009-08-20 08:59:52.000000000 +0200
  540. +++ glibc-2.10.90/ports/sysdeps/mips/mips64/__longjmp.c 2009-05-26 22:53:27.000000000 +0200
  541. @@ -27,19 +27,19 @@
  542. #endif
  543. void
  544. -__longjmp (env_arg, val_arg)
  545. - __jmp_buf env_arg;
  546. +__longjmp (env, val_arg)
  547. + __jmp_buf env;
  548. int val_arg;
  549. {
  550. /* gcc 1.39.19 miscompiled the longjmp routine (as it did setjmp before
  551. the hack around it); force it to use $a1 for the longjmp value.
  552. Without this it saves $a1 in a register which gets clobbered
  553. along the way. */
  554. - register struct __jmp_buf_internal_tag *env asm ("a0");
  555. register int val asm ("a1");
  556. #ifdef CHECK_SP
  557. register long long sp asm ("$29");
  558. - CHECK_SP (env[0].__sp, sp, long long);
  559. + if ((long long) (env[0].__sp) < sp)
  560. + __fortify_fail ("longjmp causes uninitialized stack frame");
  561. #endif
  562. #ifdef __mips_hard_float