diff options
| -rw-r--r-- | recipes/glibc/glibc-2.5/nios2-elf.patch | 87 | ||||
| -rw-r--r-- | recipes/glibc/glibc-2.5/nios2-iconv.patch | 85 | ||||
| -rw-r--r-- | recipes/glibc/glibc-2.5/nios2-ld-collate.patch | 308 | ||||
| -rw-r--r-- | recipes/glibc/glibc-2.5/sysdeps-nios2.patch | 4028 | ||||
| -rw-r--r-- | recipes/glibc/glibc_2.5.bb | 9 |
5 files changed, 4517 insertions, 0 deletions
diff --git a/recipes/glibc/glibc-2.5/nios2-elf.patch b/recipes/glibc/glibc-2.5/nios2-elf.patch new file mode 100644 index 0000000000..240bbeca8a --- /dev/null +++ b/recipes/glibc/glibc-2.5/nios2-elf.patch @@ -0,0 +1,87 @@ +*** glibc-2.5/elf/elf.h 2010-05-31 16:05:58.000000000 +0200 +--- glibc-2.5-/elf/elf.h 2008-12-19 00:35:12.000000000 +0100 +*************** +*** 250,255 **** +--- 250,257 ---- + #define EM_XTENSA 94 /* Tensilica Xtensa Architecture */ + #define EM_NUM 95 + ++ #define EM_ALTERA_NIOS2 113 /* Altera Nios II */ ++ + /* If it is necessary to assign new unofficial EM_* values, please + pick large random numbers (0x8523, 0xa7f2, etc.) to minimize the + chances of collision with official or non-GNU unofficial values. */ +*************** +*** 1511,1518 **** + #define R_MIPS_TLS_TPREL64 48 /* TP-relative offset, 64 bit */ + #define R_MIPS_TLS_TPREL_HI16 49 /* TP-relative offset, high 16 bits */ + #define R_MIPS_TLS_TPREL_LO16 50 /* TP-relative offset, low 16 bits */ + /* Keep this the last entry. */ +! #define R_MIPS_NUM 51 + + /* Legal values for p_type field of Elf32_Phdr. */ + +--- 1513,1521 ---- + #define R_MIPS_TLS_TPREL64 48 /* TP-relative offset, 64 bit */ + #define R_MIPS_TLS_TPREL_HI16 49 /* TP-relative offset, high 16 bits */ + #define R_MIPS_TLS_TPREL_LO16 50 /* TP-relative offset, low 16 bits */ ++ #define R_MIPS_GLOB_DAT 51 + /* Keep this the last entry. */ +! #define R_MIPS_NUM 52 + + /* Legal values for p_type field of Elf32_Phdr. */ + +*************** +*** 2602,2607 **** +--- 2605,2655 ---- + #define R_M32R_GOTOFF_LO 64 /* Low 16 bit offset to GOT */ + #define R_M32R_NUM 256 /* Keep this the last entry. */ + ++ /* Legal values for d_tag (dynamic entry type). */ ++ #define DT_NIOS2_GP 0x70000002 /* Address of _gp. */ ++ ++ /* Nios II relocs. */ ++ #define R_NIOS2_NONE 0 /* No reloc. */ ++ #define R_NIOS2_S16 1 /* Direct signed 16 bit. */ ++ #define R_NIOS2_U16 2 /* Direct unsigned 16 bit. */ ++ #define R_NIOS2_PCREL16 3 /* PC relative 16 bit. */ ++ #define R_NIOS2_CALL26 4 ++ #define R_NIOS2_IMM5 5 ++ #define R_NIOS2_CACHE_OPX 6 ++ #define R_NIOS2_IMM6 7 ++ #define R_NIOS2_IMM8 8 ++ #define R_NIOS2_HI16 9 ++ #define R_NIOS2_LO16 10 ++ #define R_NIOS2_HIADJ16 11 ++ #define R_NIOS2_BFD_RELOC_32 12 ++ #define R_NIOS2_BFD_RELOC_16 13 ++ #define R_NIOS2_BFD_RELOC_8 14 ++ #define R_NIOS2_GPREL 15 ++ #define R_NIOS2_GNU_VTINHERIT 16 ++ #define R_NIOS2_GNU_VTENTRY 17 ++ #define R_NIOS2_UJMP 18 ++ #define R_NIOS2_CJMP 19 ++ #define R_NIOS2_CALLR 20 ++ #define R_NIOS2_ALIGN 21 ++ #define R_NIOS2_GOT16 22 ++ #define R_NIOS2_CALL16 23 ++ #define R_NIOS2_GOTOFF_LO 24 ++ #define R_NIOS2_GOTOFF_HA 25 ++ #define R_NIOS2_PCREL_LO 26 ++ #define R_NIOS2_PCREL_HA 27 ++ #define R_NIOS2_TLS_GD16 28 ++ #define R_NIOS2_TLS_LDM16 29 ++ #define R_NIOS2_TLS_LDO16 30 ++ #define R_NIOS2_TLS_IE16 31 ++ #define R_NIOS2_TLS_LE16 32 ++ #define R_NIOS2_TLS_DTPMOD 33 ++ #define R_NIOS2_TLS_DTPREL 34 ++ #define R_NIOS2_TLS_TPREL 35 ++ #define R_NIOS2_COPY 36 ++ #define R_NIOS2_GLOB_DAT 37 ++ #define R_NIOS2_JUMP_SLOT 38 ++ #define R_NIOS2_RELATIVE 39 ++ #define R_NIOS2_GOTOFF 40 + + __END_DECLS + diff --git a/recipes/glibc/glibc-2.5/nios2-iconv.patch b/recipes/glibc/glibc-2.5/nios2-iconv.patch new file mode 100644 index 0000000000..7aa574816f --- /dev/null +++ b/recipes/glibc/glibc-2.5/nios2-iconv.patch @@ -0,0 +1,85 @@ +*** glibc-2.5/iconv/iconvconfig.c 2006-09-21 05:57:30.000000000 +0200 +--- /home/frans/workspace/nios2/wrs-linux-4.1-176-nios2-wrs-linux-gnu/glibc-2.5/iconv/iconvconfig.c 2008-11-18 18:43:02.000000000 +0100 +*************** +*** 1011,1016 **** +--- 1011,1045 ---- + module name offset + (following last entry with step count 0) + */ ++ ++ struct hash_entry *hash_table; ++ size_t hash_size; ++ ++ /* Function to insert the names. */ ++ static void ++ name_insert (const void *nodep, VISIT value, int level) ++ { ++ struct name *name; ++ unsigned int idx; ++ unsigned int hval2; ++ ++ if (value != leaf && value != postorder) ++ return; ++ ++ name = *(struct name **) nodep; ++ idx = name->hashval % hash_size; ++ hval2 = 1 + name->hashval % (hash_size - 2); ++ ++ while (hash_table[idx].string_offset != 0) ++ if ((idx += hval2) >= hash_size) ++ idx -= hash_size; ++ ++ hash_table[idx].string_offset = strtaboffset (name->strent); ++ ++ assert (name->module_idx != -1); ++ hash_table[idx].module_idx = name->module_idx; ++ } ++ + static int + write_output (void) + { +*************** +*** 1018,1025 **** + char *string_table; + size_t string_table_size; + struct gconvcache_header header; +- struct hash_entry *hash_table; +- size_t hash_size; + struct module_entry *module_table; + char *extra_table; + char *cur_extra_table; +--- 1047,1052 ---- +*************** +*** 1032,1062 **** + char tmpfname[(output_file == NULL ? sizeof finalname : output_file_len + 1) + + strlen (".XXXXXX")]; + +- /* Function to insert the names. */ +- auto void +- name_insert (const void *nodep, VISIT value, int level) +- { +- struct name *name; +- unsigned int idx; +- unsigned int hval2; +- +- if (value != leaf && value != postorder) +- return; +- +- name = *(struct name **) nodep; +- idx = name->hashval % hash_size; +- hval2 = 1 + name->hashval % (hash_size - 2); +- +- while (hash_table[idx].string_offset != 0) +- if ((idx += hval2) >= hash_size) +- idx -= hash_size; +- +- hash_table[idx].string_offset = strtaboffset (name->strent); +- +- assert (name->module_idx != -1); +- hash_table[idx].module_idx = name->module_idx; +- } +- + /* Open the output file. */ + if (output_file == NULL) + { +--- 1059,1064 ---- diff --git a/recipes/glibc/glibc-2.5/nios2-ld-collate.patch b/recipes/glibc/glibc-2.5/nios2-ld-collate.patch new file mode 100644 index 0000000000..abdc7d9667 --- /dev/null +++ b/recipes/glibc/glibc-2.5/nios2-ld-collate.patch @@ -0,0 +1,308 @@ +*** glibc-2.5/./locale/programs/ld-collate.c- 2006-09-21 05:57:30.000000000 +0200 +--- glibc-2.5/./locale/programs/ld-collate.c 2010-06-01 10:00:50.000000000 +0200 +*************** +*** 1934,1945 **** + return retval | ((elem->section->ruleidx & 0x7f) << 24); + } + + + void + collate_output (struct localedef_t *locale, const struct charmap_t *charmap, + const char *output_path) + { +- struct locale_collate_t *collate = locale->categories[LC_COLLATE].collate; + const size_t nelems = _NL_ITEM_INDEX (_NL_NUM_LC_COLLATE); + struct iovec iov[2 + nelems]; + struct locale_file data; +--- 1934,2066 ---- + return retval | ((elem->section->ruleidx & 0x7f) << 24); + } + ++ /* If localedef is every threaded, these would need to be __thread var. */ ++ struct obstack weightpool; ++ struct obstack extrapool; ++ struct obstack indirectpool; ++ struct collidx_table tablewc; ++ struct locale_collate_t *collate; ++ ++ static void ++ add_to_tablewc (uint32_t ch, struct element_t *runp) ++ { ++ if (runp->wcnext == NULL && runp->nwcs == 1) ++ { ++ int32_t weigthidx = output_weightwc (&weightpool, collate, runp); ++ collidx_table_add (&tablewc, ch, weigthidx); ++ } ++ else ++ { ++ /* As for the singlebyte table, we recognize sequences and ++ compress them. */ ++ struct element_t *lastp; ++ ++ collidx_table_add (&tablewc, ch, ++ -(obstack_object_size (&extrapool) / sizeof (uint32_t))); ++ ++ do ++ { ++ /* Store the current index in the weight table. We know that ++ the current position in the `extrapool' is aligned on a ++ 32-bit address. */ ++ int32_t weightidx; ++ int added; ++ ++ /* Find out wether this is a single entry or we have more than ++ one consecutive entry. */ ++ if (runp->wcnext != NULL ++ && runp->nwcs == runp->wcnext->nwcs ++ && wmemcmp ((wchar_t *) runp->wcs, ++ (wchar_t *)runp->wcnext->wcs, ++ runp->nwcs - 1) == 0 ++ && (runp->wcs[runp->nwcs - 1] ++ == runp->wcnext->wcs[runp->nwcs - 1] + 1)) ++ { ++ int i; ++ struct element_t *series_startp = runp; ++ struct element_t *curp; ++ ++ /* Now add first the initial byte sequence. */ ++ added = (1 + 1 + 2 * (runp->nwcs - 1)) * sizeof (int32_t); ++ if (sizeof (int32_t) == sizeof (int)) ++ obstack_make_room (&extrapool, added); ++ ++ /* More than one consecutive entry. We mark this by having ++ a negative index into the indirect table. */ ++ obstack_int32_grow_fast (&extrapool, ++ -(obstack_object_size (&indirectpool) ++ / sizeof (int32_t))); ++ obstack_int32_grow_fast (&extrapool, runp->nwcs - 1); ++ ++ do ++ runp = runp->wcnext; ++ while (runp->wcnext != NULL ++ && runp->nwcs == runp->wcnext->nwcs ++ && wmemcmp ((wchar_t *) runp->wcs, ++ (wchar_t *)runp->wcnext->wcs, ++ runp->nwcs - 1) == 0 ++ && (runp->wcs[runp->nwcs - 1] ++ == runp->wcnext->wcs[runp->nwcs - 1] + 1)); ++ ++ /* Now walk backward from here to the beginning. */ ++ curp = runp; ++ ++ for (i = 1; i < runp->nwcs; ++i) ++ obstack_int32_grow_fast (&extrapool, curp->wcs[i]); ++ ++ /* Now find the end of the consecutive sequence and ++ add all the indeces in the indirect pool. */ ++ do ++ { ++ weightidx = output_weightwc (&weightpool, collate, ++ curp); ++ obstack_int32_grow (&indirectpool, weightidx); ++ ++ curp = curp->wclast; ++ } ++ while (curp != series_startp); ++ ++ /* Add the final weight. */ ++ weightidx = output_weightwc (&weightpool, collate, curp); ++ obstack_int32_grow (&indirectpool, weightidx); ++ ++ /* And add the end byte sequence. Without length this ++ time. */ ++ for (i = 1; i < curp->nwcs; ++i) ++ obstack_int32_grow (&extrapool, curp->wcs[i]); ++ } ++ else ++ { ++ /* A single entry. Simply add the index and the length and ++ string (except for the first character which is already ++ tested for). */ ++ int i; ++ ++ /* Output the weight info. */ ++ weightidx = output_weightwc (&weightpool, collate, runp); ++ ++ added = (1 + 1 + runp->nwcs - 1) * sizeof (int32_t); ++ if (sizeof (int) == sizeof (int32_t)) ++ obstack_make_room (&extrapool, added); ++ ++ obstack_int32_grow_fast (&extrapool, weightidx); ++ obstack_int32_grow_fast (&extrapool, runp->nwcs - 1); ++ for (i = 1; i < runp->nwcs; ++i) ++ obstack_int32_grow_fast (&extrapool, runp->wcs[i]); ++ } ++ ++ /* Next entry. */ ++ lastp = runp; ++ runp = runp->wcnext; ++ } ++ while (runp != NULL); ++ } ++ } + + void + collate_output (struct localedef_t *locale, const struct charmap_t *charmap, + const char *output_path) + { + const size_t nelems = _NL_ITEM_INDEX (_NL_NUM_LC_COLLATE); + struct iovec iov[2 + nelems]; + struct locale_file data; +*************** +*** 1947,1962 **** + size_t cnt; + size_t ch; + int32_t tablemb[256]; +- struct obstack weightpool; +- struct obstack extrapool; +- struct obstack indirectpool; + struct section_list *sect; +- struct collidx_table tablewc; + uint32_t elem_size; + uint32_t *elem_table; + int i; + struct element_t *runp; + + data.magic = LIMAGIC (LC_COLLATE); + data.n = nelems; + iov[0].iov_base = (void *) &data; +--- 2068,2080 ---- + size_t cnt; + size_t ch; + int32_t tablemb[256]; + struct section_list *sect; + uint32_t elem_size; + uint32_t *elem_table; + int i; + struct element_t *runp; + ++ collate = locale->categories[LC_COLLATE].collate; + data.magic = LIMAGIC (LC_COLLATE); + data.n = nelems; + iov[0].iov_base = (void *) &data; +*************** +*** 2292,2414 **** + the table. In case we have more than one sequence starting with + the same byte we have to use extra indirection. */ + { +- auto void add_to_tablewc (uint32_t ch, struct element_t *runp); +- +- void add_to_tablewc (uint32_t ch, struct element_t *runp) +- { +- if (runp->wcnext == NULL && runp->nwcs == 1) +- { +- int32_t weigthidx = output_weightwc (&weightpool, collate, runp); +- collidx_table_add (&tablewc, ch, weigthidx); +- } +- else +- { +- /* As for the singlebyte table, we recognize sequences and +- compress them. */ +- struct element_t *lastp; +- +- collidx_table_add (&tablewc, ch, +- -(obstack_object_size (&extrapool) / sizeof (uint32_t))); +- +- do +- { +- /* Store the current index in the weight table. We know that +- the current position in the `extrapool' is aligned on a +- 32-bit address. */ +- int32_t weightidx; +- int added; +- +- /* Find out wether this is a single entry or we have more than +- one consecutive entry. */ +- if (runp->wcnext != NULL +- && runp->nwcs == runp->wcnext->nwcs +- && wmemcmp ((wchar_t *) runp->wcs, +- (wchar_t *)runp->wcnext->wcs, +- runp->nwcs - 1) == 0 +- && (runp->wcs[runp->nwcs - 1] +- == runp->wcnext->wcs[runp->nwcs - 1] + 1)) +- { +- int i; +- struct element_t *series_startp = runp; +- struct element_t *curp; +- +- /* Now add first the initial byte sequence. */ +- added = (1 + 1 + 2 * (runp->nwcs - 1)) * sizeof (int32_t); +- if (sizeof (int32_t) == sizeof (int)) +- obstack_make_room (&extrapool, added); +- +- /* More than one consecutive entry. We mark this by having +- a negative index into the indirect table. */ +- obstack_int32_grow_fast (&extrapool, +- -(obstack_object_size (&indirectpool) +- / sizeof (int32_t))); +- obstack_int32_grow_fast (&extrapool, runp->nwcs - 1); +- +- do +- runp = runp->wcnext; +- while (runp->wcnext != NULL +- && runp->nwcs == runp->wcnext->nwcs +- && wmemcmp ((wchar_t *) runp->wcs, +- (wchar_t *)runp->wcnext->wcs, +- runp->nwcs - 1) == 0 +- && (runp->wcs[runp->nwcs - 1] +- == runp->wcnext->wcs[runp->nwcs - 1] + 1)); +- +- /* Now walk backward from here to the beginning. */ +- curp = runp; +- +- for (i = 1; i < runp->nwcs; ++i) +- obstack_int32_grow_fast (&extrapool, curp->wcs[i]); +- +- /* Now find the end of the consecutive sequence and +- add all the indeces in the indirect pool. */ +- do +- { +- weightidx = output_weightwc (&weightpool, collate, +- curp); +- obstack_int32_grow (&indirectpool, weightidx); +- +- curp = curp->wclast; +- } +- while (curp != series_startp); +- +- /* Add the final weight. */ +- weightidx = output_weightwc (&weightpool, collate, curp); +- obstack_int32_grow (&indirectpool, weightidx); +- +- /* And add the end byte sequence. Without length this +- time. */ +- for (i = 1; i < curp->nwcs; ++i) +- obstack_int32_grow (&extrapool, curp->wcs[i]); +- } +- else +- { +- /* A single entry. Simply add the index and the length and +- string (except for the first character which is already +- tested for). */ +- int i; +- +- /* Output the weight info. */ +- weightidx = output_weightwc (&weightpool, collate, runp); +- +- added = (1 + 1 + runp->nwcs - 1) * sizeof (int32_t); +- if (sizeof (int) == sizeof (int32_t)) +- obstack_make_room (&extrapool, added); +- +- obstack_int32_grow_fast (&extrapool, weightidx); +- obstack_int32_grow_fast (&extrapool, runp->nwcs - 1); +- for (i = 1; i < runp->nwcs; ++i) +- obstack_int32_grow_fast (&extrapool, runp->wcs[i]); +- } +- +- /* Next entry. */ +- lastp = runp; +- runp = runp->wcnext; +- } +- while (runp != NULL); +- } +- } +- + tablewc.p = 6; + tablewc.q = 10; + collidx_table_init (&tablewc); +--- 2410,2415 ---- diff --git a/recipes/glibc/glibc-2.5/sysdeps-nios2.patch b/recipes/glibc/glibc-2.5/sysdeps-nios2.patch new file mode 100644 index 0000000000..9d54a806e1 --- /dev/null +++ b/recipes/glibc/glibc-2.5/sysdeps-nios2.patch @@ -0,0 +1,4028 @@ +Index: glibc-2.5/sysdeps/nios2/Implies +=================================================================== +--- /dev/null 1970-01-01 00:00:00.000000000 +0000 ++++ glibc-2.5/sysdeps/nios2/Implies 2010-05-31 08:56:05.000000000 +0200 +@@ -0,0 +1,4 @@ ++wordsize-32 ++ieee754/dbl-64 ++ieee754/flt-32 ++nios2/soft-fp +Index: glibc-2.5/sysdeps/nios2/Makefile +=================================================================== +--- /dev/null 1970-01-01 00:00:00.000000000 +0000 ++++ glibc-2.5/sysdeps/nios2/Makefile 2010-05-31 08:56:05.000000000 +0200 +@@ -0,0 +1,33 @@ ++# Copyright (C) 1993, 1994, 1996, 1997, 2003, 2008 Free Software Foundation, ++# Inc. ++# This file is part of the GNU C Library. ++ ++# The GNU C Library is free software; you can redistribute it and/or ++# modify it under the terms of the GNU Lesser General Public ++# License as published by the Free Software Foundation; either ++# version 2.1 of the License, or (at your option) any later version. ++ ++# The GNU C Library is distributed in the hope that it will be useful, ++# but WITHOUT ANY WARRANTY; without even the implied warranty of ++# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ++# Lesser General Public License for more details. ++ ++# You should have received a copy of the GNU Lesser General Public ++# License along with the GNU C Library; if not, write to the Free ++# Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA ++# 02111-1307 USA. ++ ++pic-ccflag = -fpic ++ ++ifeq ($(subdir),elf) ++CFLAGS-rtld.c += -mhw-div ++endif ++ ++ifeq ($(subdir),soft-fp) ++sysdep_routines += $(filter-out sqrtsf2,$(gcc-single-routines)) \ ++ $(filter-out sqrtdf2,$(gcc-double-routines)) ++endif ++ ++ifeq ($(subdir),csu) ++gen-as-const-headers += tcb-offsets.sym ++endif +Index: glibc-2.5/sysdeps/nios2/Subdirs +=================================================================== +--- /dev/null 1970-01-01 00:00:00.000000000 +0000 ++++ glibc-2.5/sysdeps/nios2/Subdirs 2010-05-31 08:56:05.000000000 +0200 +@@ -0,0 +1 @@ ++soft-fp +Index: glibc-2.5/sysdeps/nios2/Versions +=================================================================== +--- /dev/null 1970-01-01 00:00:00.000000000 +0000 ++++ glibc-2.5/sysdeps/nios2/Versions 2010-05-31 08:56:05.000000000 +0200 +@@ -0,0 +1,12 @@ ++libc { ++ GLIBC_2.10 { ++ __adddf3; __addsf3; __divdf3; __divsf3; __eqdf2; __eqsf2; __extendsfdf2; ++ __fixdfdi; __fixdfsi; __fixsfdi; __fixsfsi; ++ __fixunsdfdi; __fixunsdfsi; __fixunssfdi; __fixunssfsi; ++ __floatdidf; __floatdisf; __floatsidf; __floatsisf; ++ __floatundidf; __floatundisf; __floatunsidf; __floatunsisf; ++ __gedf2; __gesf2; __gtdf2; __gtsf2; __ledf2; __lesf2; __ltdf2; __ltsf2; ++ __muldf3; __mulsf3; __nedf2; __nesf2; __negdf2; __negsf2; ++ __subdf3; __subsf3; __truncdfsf2; __unorddf2; __unordsf2; ++ } ++} +Index: glibc-2.5/sysdeps/nios2/__longjmp.c +=================================================================== +--- /dev/null 1970-01-01 00:00:00.000000000 +0000 ++++ glibc-2.5/sysdeps/nios2/__longjmp.c 2010-05-31 08:56:05.000000000 +0200 +@@ -0,0 +1,41 @@ ++/* Copyright (C) 1991, 92, 93, 94, 95, 97, 2008 Free Software Foundation, Inc. ++ This file is part of the GNU C Library. ++ ++ The GNU C Library is free software; you can redistribute it and/or ++ modify it under the terms of the GNU Lesser General Public ++ License as published by the Free Software Foundation; either ++ version 2.1 of the License, or (at your option) any later version. ++ ++ The GNU C Library is distributed in the hope that it will be useful, ++ but WITHOUT ANY WARRANTY; without even the implied warranty of ++ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ++ Lesser General Public License for more details. ++ ++ You should have received a copy of the GNU Lesser General Public ++ License along with the GNU C Library; if not, write to the Free ++ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA ++ 02111-1307 USA. */ ++ ++#include <setjmp.h> ++#include <stdlib.h> ++ ++/* Jump to the position specified by ENV, causing the ++ setjmp call there to return VAL, or 1 if VAL is 0. */ ++void ++__longjmp (__jmp_buf env, int val) ++{ ++ if (val == 0) ++ val = 1; ++ __asm__ volatile ("mov r2, %0" : : "r" (val)); ++ __asm__ volatile ("ldw r16, %0" : : "m" (env[0].__regs[0])); ++ __asm__ volatile ("ldw r17, %0" : : "m" (env[0].__regs[1])); ++ __asm__ volatile ("ldw r18, %0" : : "m" (env[0].__regs[2])); ++ __asm__ volatile ("ldw r19, %0" : : "m" (env[0].__regs[3])); ++ __asm__ volatile ("ldw r20, %0" : : "m" (env[0].__regs[4])); ++ __asm__ volatile ("ldw r21, %0" : : "m" (env[0].__regs[5])); ++ __asm__ volatile ("ldw r22, %0" : : "m" (env[0].__regs[6])); ++ __asm__ volatile ("ldw r23, %0" : : "m" (env[0].__regs[7])); ++ __asm__ volatile ("ldw sp, %0" : : "m" (env[0].__regs[8])); ++ __asm__ volatile ("ldw fp, %0" : : "m" (env[0].__regs[9])); ++ __asm__ volatile ("ldw ra, %0" : : "m" (env[0].__regs[10])); ++} +Index: glibc-2.5/sysdeps/nios2/bits/endian.h +=================================================================== +--- /dev/null 1970-01-01 00:00:00.000000000 +0000 ++++ glibc-2.5/sysdeps/nios2/bits/endian.h 2010-05-31 08:56:05.000000000 +0200 +@@ -0,0 +1,12 @@ ++/* The Nios II architecture has selectable endianness. */ ++ ++#ifndef _ENDIAN_H ++# error "Never use <bits/endian.h> directly; include <endian.h> instead." ++#endif ++ ++#ifdef __nios2_big_endian__ ++# define __BYTE_ORDER __BIG_ENDIAN ++#endif ++#ifdef __nios2_little_endian__ ++# define __BYTE_ORDER __LITTLE_ENDIAN ++#endif +Index: glibc-2.5/sysdeps/nios2/bits/link.h +=================================================================== +--- /dev/null 1970-01-01 00:00:00.000000000 +0000 ++++ glibc-2.5/sysdeps/nios2/bits/link.h 2010-05-31 08:56:05.000000000 +0200 +@@ -0,0 +1,54 @@ ++/* Copyright (C) 2009 Free Software Foundation, Inc. ++ This file is part of the GNU C Library. ++ ++ The GNU C Library is free software; you can redistribute it and/or ++ modify it under the terms of the GNU Lesser General Public ++ License as published by the Free Software Foundation; either ++ version 2.1 of the License, or (at your option) any later version. ++ ++ The GNU C Library is distributed in the hope that it will be useful, ++ but WITHOUT ANY WARRANTY; without even the implied warranty of ++ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ++ Lesser General Public License for more details. ++ ++ You should have received a copy of the GNU Lesser General Public ++ License along with the GNU C Library; if not, write to the Free ++ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA ++ 02111-1307 USA. */ ++ ++#ifndef _LINK_H ++# error "Never include <bits/link.h> directly; use <link.h> instead." ++#endif ++ ++/* Registers for entry into PLT on Nios II. */ ++typedef struct La_nios2_regs ++{ ++ uint32_t lr_reg[4]; /* r4 through r7 */ ++ uint32_t lr_ra; ++ uint32_t lr_sp; ++} La_nios2_regs; ++ ++/* Return values for calls from PLT on Nios II. */ ++typedef struct La_nios2_retval ++{ ++ uint32_t lrv_r2; ++ uint32_t lrv_r3; ++} La_nios2_retval; ++ ++__BEGIN_DECLS ++ ++extern Elf32_Addr la_nios2_gnu_pltenter (Elf32_Sym *__sym, unsigned int __ndx, ++ uintptr_t *__refcook, ++ uintptr_t *__defcook, ++ La_nios2_regs *__regs, ++ unsigned int *__flags, ++ const char *__symname, ++ long int *__framesizep); ++extern unsigned int la_nios2_gnu_pltexit (Elf32_Sym *__sym, unsigned int __ndx, ++ uintptr_t *__refcook, ++ uintptr_t *__defcook, ++ const La_nios2_regs *__inregs, ++ La_nios2_retval *__outregs, ++ const char *symname); ++ ++__END_DECLS +Index: glibc-2.5/sysdeps/nios2/bits/setjmp.h +=================================================================== +--- /dev/null 1970-01-01 00:00:00.000000000 +0000 ++++ glibc-2.5/sysdeps/nios2/bits/setjmp.h 2010-05-31 08:56:05.000000000 +0200 +@@ -0,0 +1,35 @@ ++/* Define the machine-dependent type `jmp_buf'. Nios II version. ++ Copyright (C) 1992,1993,1995,1997,2000,2002,2003,2004,2005,2006,2008 ++ Free Software Foundation, Inc. ++ This file is part of the GNU C Library. ++ ++ The GNU C Library is free software; you can redistribute it and/or ++ modify it under the terms of the GNU Lesser General Public ++ License as published by the Free Software Foundation; either ++ version 2.1 of the License, or (at your option) any later version. ++ ++ The GNU C Library is distributed in the hope that it will be useful, ++ but WITHOUT ANY WARRANTY; without even the implied warranty of ++ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ++ Lesser General Public License for more details. ++ ++ You should have received a copy of the GNU Lesser General Public ++ License along with the GNU C Library; if not, write to the Free ++ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA ++ 02111-1307 USA. */ ++ ++#ifndef _NIOS2_BITS_SETJMP_H ++#define _NIOS2_BITS_SETJMP_H 1 ++ ++#if !defined(_SETJMP_H) && !defined(_PTHREAD_H) ++# error "Never include <bits/setjmp.h> directly; use <setjmp.h> instead." ++#endif ++ ++typedef struct ++ { ++ /* r16,r17,r18,r19,r20,r21,r22,r23,sp,fp,ra */ ++ int __regs[11]; ++ ++ } __jmp_buf[1]; ++ ++#endif /* _NIOS2_BITS_SETJMP_H */ +Index: glibc-2.5/sysdeps/nios2/bsd-_setjmp.S +=================================================================== +--- /dev/null 1970-01-01 00:00:00.000000000 +0000 ++++ glibc-2.5/sysdeps/nios2/bsd-_setjmp.S 2010-05-31 08:56:05.000000000 +0200 +@@ -0,0 +1,40 @@ ++/* BSD `_setjmp' entry point to `sigsetjmp (..., 1)'. NIOS2 version. ++ Copyright (C) 1996, 1997, 2000, 2008 Free Software Foundation, Inc. ++ This file is part of the GNU C Library. ++ ++ The GNU C Library is free software; you can redistribute it and/or ++ modify it under the terms of the GNU Lesser General Public ++ License as published by the Free Software Foundation; either ++ version 2.1 of the License, or (at your option) any later version. ++ ++ The GNU C Library is distributed in the hope that it will be useful, ++ but WITHOUT ANY WARRANTY; without even the implied warranty of ++ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ++ Lesser General Public License for more details. ++ ++ You should have received a copy of the GNU Lesser General Public ++ License along with the GNU C Library; if not, write to the Free ++ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA ++ 02111-1307 USA. */ ++ ++/* This just does a tail-call to `__sigsetjmp (ARG, 1)'. ++ We cannot do it in C because it must be a tail-call, so frame-unwinding ++ in setjmp doesn't clobber the state restored by longjmp. */ ++ ++#include <sysdep.h> ++ ++ENTRY (_setjmp) ++ movi r5, 0 /* Pass a second argument of zero. */ ++#if defined (__PIC__) || defined (PIC) ++ nextpc r2 ++1: movhi r3, %hiadj(_GLOBAL_OFFSET_TABLE_ - 1b) ++ addi r3, r3, %lo(_GLOBAL_OFFSET_TABLE_ - 1b) ++ add r2, r2, r3 ++ ldw r2, %call(C_SYMBOL_NAME(__sigsetjmp))(r2) ++ jmp r2 ++#else ++ jmpi C_SYMBOL_NAME (__sigsetjmp) ++#endif ++ .size setjmp, . - setjmp ++ ++libc_hidden_def (_setjmp) +Index: glibc-2.5/sysdeps/nios2/bsd-setjmp.S +=================================================================== +--- /dev/null 1970-01-01 00:00:00.000000000 +0000 ++++ glibc-2.5/sysdeps/nios2/bsd-setjmp.S 2010-05-31 08:56:05.000000000 +0200 +@@ -0,0 +1,38 @@ ++/* BSD `setjmp' entry point to `sigsetjmp (..., 1)'. NIOS2 version. ++ Copyright (C) 1996, 1997, 2000, 2008 Free Software Foundation, Inc. ++ This file is part of the GNU C Library. ++ ++ The GNU C Library is free software; you can redistribute it and/or ++ modify it under the terms of the GNU Lesser General Public ++ License as published by the Free Software Foundation; either ++ version 2.1 of the License, or (at your option) any later version. ++ ++ The GNU C Library is distributed in the hope that it will be useful, ++ but WITHOUT ANY WARRANTY; without even the implied warranty of ++ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ++ Lesser General Public License for more details. ++ ++ You should have received a copy of the GNU Lesser General Public ++ License along with the GNU C Library; if not, write to the Free ++ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA ++ 02111-1307 USA. */ ++ ++/* This just does a tail-call to `__sigsetjmp (ARG, 1)'. ++ We cannot do it in C because it must be a tail-call, so frame-unwinding ++ in setjmp doesn't clobber the state restored by longjmp. */ ++ ++#include <sysdep.h> ++ ++ENTRY (setjmp) ++ movi r5, 1 /* Pass a second argument of one. */ ++#if defined (__PIC__) || defined (PIC) ++ nextpc r2 ++1: movhi r3, %hiadj(_GLOBAL_OFFSET_TABLE_ - 1b) ++ addi r3, r3, %lo(_GLOBAL_OFFSET_TABLE_ - 1b) ++ add r2, r2, r3 ++ ldw r2, %call(C_SYMBOL_NAME(__sigsetjmp))(r2) ++ jmp r2 ++#else ++ jmpi C_SYMBOL_NAME (__sigsetjmp) ++#endif ++ .size setjmp, . - setjmp +Index: glibc-2.5/sysdeps/nios2/dl-init.c +=================================================================== +--- /dev/null 1970-01-01 00:00:00.000000000 +0000 ++++ glibc-2.5/sysdeps/nios2/dl-init.c 2010-05-31 08:56:05.000000000 +0200 +@@ -0,0 +1,30 @@ ++/* Copyright (C) 2008 Free Software Foundation, Inc. ++ This file is part of the GNU C Library. ++ ++ The GNU C Library is free software; you can redistribute it and/or ++ modify it under the terms of the GNU Lesser General Public ++ License as published by the Free Software Foundation; either ++ version 2.1 of the License, or (at your option) any later version. ++ ++ The GNU C Library is distributed in the hope that it will be useful, ++ but WITHOUT ANY WARRANTY; without even the implied warranty of ++ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ++ Lesser General Public License for more details. ++ ++ You should have received a copy of the GNU Lesser General Public ++ License along with the GNU C Library; if not, write to the Free ++ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA ++ 02111-1307 USA. */ ++ ++#include <elf/dl-init.c> ++ ++unsigned int ++internal_function ++_dl_nios2_get_gp_value (struct link_map *main_map) ++{ ++ ElfW(Dyn)* dyn = main_map->l_ld; ++ for (dyn = main_map->l_ld; dyn->d_tag != DT_NULL; ++dyn) ++ if (dyn->d_tag == DT_NIOS2_GP) ++ return (unsigned int)(dyn->d_un.d_ptr); ++ return 0; ++} +Index: glibc-2.5/sysdeps/nios2/dl-machine.h +=================================================================== +--- /dev/null 1970-01-01 00:00:00.000000000 +0000 ++++ glibc-2.5/sysdeps/nios2/dl-machine.h 2010-05-31 08:56:05.000000000 +0200 +@@ -0,0 +1,332 @@ ++/* Machine-dependent ELF dynamic relocation inline functions. Nios II version. ++ Copyright (C) 1995, 1996, 1997, 1999, 2000, 2001, 2005 ++ Free Software Foundation, Inc. ++ This file is part of the GNU C Library. ++ ++ The GNU C Library is free software; you can redistribute it and/or ++ modify it under the terms of the GNU Lesser General Public ++ License as published by the Free Software Foundation; either ++ version 2.1 of the License, or (at your option) any later version. ++ ++ The GNU C Library is distributed in the hope that it will be useful, ++ but WITHOUT ANY WARRANTY; without even the implied warranty of ++ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ++ Lesser General Public License for more details. ++ ++ You should have received a copy of the GNU Lesser General Public ++ License along with the GNU C Library; if not, write to the Free ++ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA ++ 02111-1307 USA. */ ++ ++#ifndef dl_machine_h ++#define dl_machine_h ++ ++#define ELF_MACHINE_NAME "nios2" ++ ++#include <string.h> ++#include <link.h> ++#include <dl-tls.h> ++ ++/* Return nonzero iff ELF header is compatible with the running host. */ ++static inline int ++elf_machine_matches_host (const Elf32_Ehdr *ehdr) ++{ ++ return ehdr->e_machine == EM_ALTERA_NIOS2; ++} ++ ++ ++/* Return the link-time address of _DYNAMIC. Conveniently, this is the ++ first element of the GOT. */ ++static inline Elf32_Addr ++elf_machine_dynamic (void) ++{ ++ Elf32_Addr *dynamic; ++ int tmp; ++ asm("nextpc\t%0\n\t" ++ "1: movhi\t%1, %%hiadj(_GLOBAL_OFFSET_TABLE_ - 1b)\n\t" ++ "addi\t%1, %1, %%lo( _GLOBAL_OFFSET_TABLE_ - 1b)\n\t" ++ "add\t%0, %0, %1\n" ++ : "=r" (dynamic), "=r" (tmp)); ++ return *dynamic; ++} ++ ++ ++/* Return the run-time load address of the shared object. */ ++static inline Elf32_Addr ++elf_machine_load_address (void) ++{ ++ Elf32_Addr result; ++ int tmp; ++ asm("nextpc\t%0\n\t" ++ "1: movhi\t%1, %%hiadj(1b)\n\t" ++ "addi\t%1, %1, %%lo(1b)\n\t" ++ "sub\t%0, %0, %1\n" ++ : "=r" (result), "=r" (tmp)); ++ return result; ++} ++ ++/* Set up the loaded object described by L so its unrelocated PLT ++ entries will jump to the on-demand fixup code in dl-runtime.c. */ ++ ++static inline int ++elf_machine_runtime_setup (struct link_map *l, int lazy, int profile) ++{ ++ extern void _dl_runtime_resolve (Elf32_Word); ++ ++ if (lazy) ++ { ++ /* The GOT entries for functions in the PLT have not yet been filled ++ in. Their initial contents will arrange when called to load r15 with ++ an offset into the .got section, load r14 with ++ _GLOBAL_OFFSET_TABLE_[1], and then jump to _GLOBAL_OFFSET_TABLE[2]. ++ */ ++ Elf32_Addr *got = (Elf32_Addr *) D_PTR (l, l_info[DT_PLTGOT]); ++ got[1] = (Elf32_Addr) l; /* Identify this shared object. */ ++ ++ /* This function will get called to fix up the GOT entry indicated by ++ the offset on the stack, and then jump to the resolved address. */ ++ got[2] = (Elf32_Addr) &_dl_runtime_resolve; ++ } ++ ++ return lazy; ++} ++ ++/* Initial entry point code for the dynamic linker. ++ The C function `_dl_start' is the real entry point; ++ its return value is the user program's entry point. */ ++ ++#define RTLD_START asm("\ ++.text\n\ ++.globl _start\n\ ++.type _start, %function\n\ ++_start:\n\ ++ /* At start time, all the args are on the stack. */\n\ ++ mov r4, sp\n\ ++\n\ ++ /* Start the calculation of the GOT pointer. */\n\ ++ nextpc r22\n\ ++1: movhi r8, %hiadj(_GLOBAL_OFFSET_TABLE_ - 1b)\n\ ++ addi r8, r8, %lo(_GLOBAL_OFFSET_TABLE_ - 1b)\n\ ++\n\ ++ /* Figure out where _dl_start will need to return to. */\n\ ++ movhi ra, %hiadj(2f - 1b)\n\ ++ addi ra, ra, %lo(2f - 1b)\n\ ++ add ra, ra, r22\n\ ++\n\ ++ /* Finish the calculation of the GOT pointer. */\n\ ++ add r22, r22, r8\n\ ++\n\ ++ br _dl_start\n\ ++\n\ ++ /* Save the returned user entry point. */\n\ ++2: mov r16, r2\n\ ++\n\ ++ /* Initialize gp. */\n\ ++ ldw r4, %got(_rtld_local)(r22)\n\ ++ ldw r4, 0(r4)\n\ ++ ldw r8, %call( |
