diff options
| -rw-r--r-- | recipes/glibc/glibc-2.10.1/nios2-elf.patch | 67 | ||||
| -rw-r--r-- | recipes/glibc/glibc-2.10.1/sysdeps-nios2.patch | 4062 | ||||
| -rw-r--r-- | recipes/glibc/glibc_2.10.1.bb | 5 |
3 files changed, 4134 insertions, 0 deletions
diff --git a/recipes/glibc/glibc-2.10.1/nios2-elf.patch b/recipes/glibc/glibc-2.10.1/nios2-elf.patch new file mode 100644 index 0000000000..194654cd17 --- /dev/null +++ b/recipes/glibc/glibc-2.10.1/nios2-elf.patch @@ -0,0 +1,67 @@ +*** 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. */ +*************** +*** 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.10.1/sysdeps-nios2.patch b/recipes/glibc/glibc-2.10.1/sysdeps-nios2.patch new file mode 100644 index 0000000000..f4529199e8 --- /dev/null +++ b/recipes/glibc/glibc-2.10.1/sysdeps-nios2.patch @@ -0,0 +1,4062 @@ +Index: glibc-2.10.1/sysdeps/nios2/Implies +=================================================================== +--- /dev/null ++++ glibc-2.10.1/sysdeps/nios2/Implies +@@ -0,0 +1,4 @@ ++wordsize-32 ++ieee754/dbl-64 ++ieee754/flt-32 ++nios2/soft-fp +Index: glibc-2.10.1/sysdeps/nios2/Makefile +=================================================================== +--- /dev/null ++++ glibc-2.10.1/sysdeps/nios2/Makefile +@@ -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.10.1/sysdeps/nios2/Subdirs +=================================================================== +--- /dev/null ++++ glibc-2.10.1/sysdeps/nios2/Subdirs +@@ -0,0 +1 @@ ++soft-fp +Index: glibc-2.10.1/sysdeps/nios2/Versions +=================================================================== +--- /dev/null ++++ glibc-2.10.1/sysdeps/nios2/Versions +@@ -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.10.1/sysdeps/nios2/__longjmp.c +=================================================================== +--- /dev/null ++++ glibc-2.10.1/sysdeps/nios2/__longjmp.c +@@ -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.10.1/sysdeps/nios2/bits/endian.h +=================================================================== +--- /dev/null ++++ glibc-2.10.1/sysdeps/nios2/bits/endian.h +@@ -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.10.1/sysdeps/nios2/bits/link.h +=================================================================== +--- /dev/null ++++ glibc-2.10.1/sysdeps/nios2/bits/link.h +@@ -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.10.1/sysdeps/nios2/bits/setjmp.h +=================================================================== +--- /dev/null ++++ glibc-2.10.1/sysdeps/nios2/bits/setjmp.h +@@ -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.10.1/sysdeps/nios2/bsd-_setjmp.S +=================================================================== +--- /dev/null ++++ glibc-2.10.1/sysdeps/nios2/bsd-_setjmp.S +@@ -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.10.1/sysdeps/nios2/bsd-setjmp.S +=================================================================== +--- /dev/null ++++ glibc-2.10.1/sysdeps/nios2/bsd-setjmp.S +@@ -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.10.1/sysdeps/nios2/dl-init.c +=================================================================== +--- /dev/null ++++ glibc-2.10.1/sysdeps/nios2/dl-init.c +@@ -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.10.1/sysdeps/nios2/dl-machine.h +=================================================================== +--- /dev/null ++++ glibc-2.10.1/sysdeps/nios2/dl-machine.h +@@ -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(_dl_nios2_get_gp_value)(r22)\n\ ++ callr r8\n\ ++ mov gp, r2\n\ ++\n\ ++ /* Find the number of arguments to skip. */\n\ ++ ldw r8, %got(_dl_skip_args)(r22)\n\ ++ ldw r8, 0(r8)\n\ ++\n\ ++ /* Find the main_map from the GOT. */\n\ ++ ldw r4, %got(_rtld_local)(r22)\n\ ++ ldw r4, 0(r4)\n\ ++\n\ ++ /* Find argc. */\n\ ++ ldw r5, 0(sp)\n\ ++ sub r5, r5, r8\n\ ++ stw r5, 0(sp)\n\ ++\n\ ++ /* Find the first unskipped argument. */\n\ ++ slli r8, r8, 2\n\ ++ addi r6, sp, 4\n\ ++ add r9, r6, r8\n\ ++ mov r10, r6\n\ ++\n\ ++ /* Shuffle argv down. */\n\ ++3: ldw r11, 0(r9)\n\ ++ stw r11, 0(r10)\n\ ++ addi r9, r9, 4\n\ ++ addi r10, r10, 4\n\ ++ bne r11, zero, 3b\n\ ++\n\ ++ /* Shuffle envp down. */\n\ ++ mov r7, r10\n\ ++4: ldw r11, 0(r9)\n\ ++ stw r11, 0(r10)\n\ ++ addi r9, r9, 4\n\ ++ addi r10, r10, 4\n\ ++ bne r11, zero, 4b\n\ ++\n\ ++ /* Shuffle auxv down. */\n\ ++5: ldw r11, 4(r9)\n\ ++ stw r11, 4(r10)\n\ ++ ldw r11, 0(r9)\n\ ++ stw r11, 0(r10)\n\ ++ addi r9, r9, 8\n\ ++ addi r10, r10, 8\n\ ++ bne r11, zero, 5b\n\ ++\n\ ++ /* Update _dl_argv. */\n\ ++ ldw r2, %got(_dl_argv)(r22)\n\ ++ stw r6, 0(r2)\n\ ++\n\ ++ /* Call _dl_init through the PLT. */\n\ ++ ldw r8, %call(_dl_init)(r22)\n\ ++ callr r8\n\ ++\n\ ++ /* Find the finalization function. */\n\ ++ ldw r4, %got(_dl_fini)(r22)\n\ ++\n\ ++ /* Jump to the user's entry point. */\n\ ++ jmp r16\n\ ++"); ++ ++/* ELF_RTYPE_CLASS_PLT iff TYPE describes relocation of a PLT entry, so ++ PLT entries should not be allowed to define the value. ++ ELF_RTYPE_CLASS_NOCOPY iff TYPE should not be allowed to resolve to one ++ of the main executable's symbols, as for a COPY reloc. */ ++#define elf_machine_type_class(type) \ ++ ((((type) == R_NIOS2_JUMP_SLOT) * ELF_RTYPE_CLASS_PLT) \ ++ | (((type) == R_NIOS2_COPY) * ELF_RTYPE_CLASS_COPY)) ++ ++/* A reloc type used for ld.so cmdline arg lookups to reject PLT entries. */ ++#define ELF_MACHINE_JMP_SLOT R_NIOS2_JUMP_SLOT ++ ++/* The Nios II never uses Elf32_Rel relocations. */ ++#define ELF_MACHINE_NO_REL 1 ++ ++/* Fixup a PLT entry to bounce directly to the function at VALUE. */ ++ ++static inline Elf32_Addr ++elf_machine_fixup_plt (struct link_map *map, lookup_t t, ++ const Elf32_Rel *reloc, ++ Elf32_Addr *reloc_addr, Elf32_Addr value) ++{ ++ return *reloc_addr = value; ++} ++ ++/* Return the final value of a plt relocation. */ ++static inline Elf32_Addr ++elf_machine_plt_value (struct link_map *map, const Elf32_Rela *reloc, ++ Elf32_Addr value) ++{ ++ return value; ++} ++ ++/* Names of the architecture-specific auditing callback functions. */ ++#define ARCH_LA_PLTENTER nios2_gnu_pltenter ++#define ARCH_LA_PLTEXIT nios2_gnu_pltexit ++ ++#endif /* dl_machine_h */ ++ ++#ifdef RESOLVE_MAP ++ ++/* Perform the relocation specified by RELOC and SYM (which is fully resolved). ++ LOADADDR is the load address of the object; INFO is an array indexed ++ by DT_* of the .dynamic section info. */ ++ ++auto inline void __attribute__ ((always_inline)) ++elf_machine_rela (struct link_map *map, const ElfW(Rela) *reloc, ++ const ElfW(Sym) *sym, const struct r_found_version *version, ++ void *const reloc_addr_arg) ++{ ++ Elf32_Addr *const reloc_addr = reloc_addr_arg; ++ const unsigned int r_type = ELF32_R_TYPE (reloc->r_info); ++ ++ if (__builtin_expect (r_type == R_NIOS2_RELATIVE, 0)) ++ *reloc_addr = map->l_addr + reloc->r_addend; ++ else if (__builtin_expect (r_type == R_NIOS2_NONE, 0)) ++ return; ++ else ++ { ++ const Elf32_Sym *const refsym = sym; ++ struct link_map *sym_map = RESOLVE_MAP (&sym, version, r_type); ++ Elf32_Addr value = sym == NULL ? 0 : sym_map->l_addr + sym->st_value; ++ ++ switch (r_type) ++ { ++ case R_NIOS2_COPY: ++ if (sym == NULL) ++ /* This can happen in trace mode if an object could not be ++ found. */ ++ break; ++ if (sym->st_size > refsym->st_size ++ || (sym->st_size < refsym->st_size && GLRO(dl_verbose))) ++ { ++ const char *strtab; ++ ++ strtab = (const void *) D_PTR (map, l_info[DT_STRTAB]); ++ _dl_error_printf ("\ ++%s: Symbol `%s' has different size in shared object, consider re-linking\n", ++ rtld_progname ?: "<program name unknown>", ++ strtab + refsym->st_name); ++ } ++ memcpy (reloc_addr_arg, (void *) value, ++ MIN (sym->st_size, refsym->st_size)); ++ break; ++ case R_NIOS2_GLOB_DAT: ++ case R_NIOS2_JUMP_SLOT: ++# ifdef RTLD_BOOTSTRAP ++ /* Fix weak undefined references. */ ++ if (sym != NULL && sym->st_value == 0) ++ *reloc_addr = 0; ++ else ++# endif ++ *reloc_addr = value; ++ break; ++#if defined USE_TLS && !defined RTLD_BOOTSTRAP ++ case R_NIOS2_TLS_DTPMOD: ++ /* Get the information from the link map returned by the ++ resolv function. */ ++ if (sym_map != NULL) ++ *reloc_addr = sym_map->l_tls_modid; ++ break; ++ ++ case R_NIOS2_TLS_DTPREL: ++ *reloc_addr = reloc->r_addend + TLS_DTPREL_VALUE(sym); ++ break; ++ ++ case R_NIOS2_TLS_TPREL: ++ if (sym != NULL) ++ { ++ CHECK_STATIC_TLS (map, sym_map); ++ *reloc_addr = reloc->r_addend + TLS_TPREL_VALUE(sym_map, sym); ++ } ++ break; ++#endif ++ case R_NIOS2_BFD_RELOC_32: ++ *reloc_addr = value + reloc->r_addend; ++ break; ++ ++ default: ++ _dl_reloc_bad_type (map, r_type, 0); ++ break; ++ } ++ } ++} ++ ++auto inline void __attribute__((always_inline)) ++ elf_machine_rela_relative (ElfW(Addr) l_addr, const ElfW(Rela) *reloc, ++ void *const reloc_addr_arg) ++{ ++ Elf32_Addr *const reloc_addr = reloc_addr_arg; ++ *reloc_addr = l_addr + reloc->r_addend; ++} ++ ++auto inline void __attribute__((always_inline)) ++ elf_machine_lazy_rel (struct link_map *map, ++ ElfW(Addr) l_addr, const ElfW(Rela) *reloc) ++{ ++ Elf32_Addr *const reloc_addr = (void *) (l_addr + reloc->r_offset); ++ if (ELF32_R_TYPE (reloc->r_info) == R_NIOS2_JUMP_SLOT) ++ *reloc_addr += l_addr; ++ else ++ _dl_reloc_bad_type (map, ELF32_R_TYPE (reloc->r_info), 1); ++} ++ ++#endif /* RESOLVE_MAP */ +Index: glibc-2.10.1/sysdeps/nios2/dl-sysdep.h +=================================================================== +--- /dev/null ++++ glibc-2.10.1/sysdeps/nios2/dl-sysdep.h +@@ -0,0 +1,24 @@ ++/* System-specific settings for dynamic linker code. Nios II version. ++ 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. */ ++ ++#include_next <dl-sysdep.h> ++ ++/* _dl_argv cannot be attribute_relro, because _dl_start_user ++ might write into it after _dl_start returns. */ ++#define DL_ARGV_NOT_RELRO 1 +Index: glibc-2.10.1/sysdeps/nios2/dl-tls.h +=================================================================== +--- /dev/null ++++ glibc-2.10.1/sysdeps/nios2/dl-tls.h +@@ -0,0 +1,46 @@ ++/* Thread-local storage handling in the ELF dynamic linker. Nios II version. ++ Copyright (C) 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. */ ++ ++ ++/* Type used for the representation of TLS information in the GOT. */ ++typedef struct ++{ ++ unsigned long int ti_module; ++ unsigned long int ti_offset; ++} tls_index; ++ ++/* The thread pointer points 0x7000 past the first static TLS block. */ ++#define TLS_TP_OFFSET 0x7000 ++ ++/* Dynamic thread vector pointers point 0x8000 past the start of each ++ TLS block. */ ++#define TLS_DTV_OFFSET 0x8000 ++ ++/* Compute the value for a GOTTPREL reloc. */ ++#define TLS_TPREL_VALUE(sym_map, sym) \ ++ ((sym_map)->l_tls_offset + (sym)->st_value - TLS_TP_OFFSET) ++ ++/* Compute the value for a DTPREL reloc. */ ++#define TLS_DTPREL_VALUE(sym) \ ++ ((sym)->st_value - TLS_DTV_OFFSET) ++ ++extern void *__tls_get_addr (tls_index *ti); ++ ++# define GET_ADDR_OFFSET (ti->ti_offset + TLS_DTV_OFFSET) ++# define __TLS_GET_ADDR(__ti) (__tls_get_addr (__ti) - TLS_DTV_OFFSET) +Index: glibc-2.10.1/sysdeps/nios2/dl-trampoline.S +=================================================================== +--- /dev/null ++++ glibc-2.10.1/sysdeps/nios2/dl-trampoline.S +@@ -0,0 +1,80 @@ ++/* PLT trampolines. Nios II version. ++ Copyright (C) 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. */ ++ ++#include <sysdep.h> ++#include <libc-symbols.h> ++ ++ .text ++ .globl _dl_runtime_resolve ++ cfi_startproc ++_dl_runtime_resolve: ++/* The runtime resolver receives the original function arguments in r4 ++ through r7, the shared library identifier from GOT[1]? in r14, and the ++ relocation index times four in r15. It updates the corresponding PLT GOT ++ entry so that the PLT entry will transfer control directly to the target ++ in the future, and then transfers control to the target. */ ++ /* Save arguments and return address. */ ++ subi sp, sp, 28 ++ cfi_adjust_cfa_offset (28) ++ stw r22, 24(sp) ++ cfi_rel_offset (r22, 24) ++ stw r8, 20(sp) /* save r8, because this might be a call to mcount */ ++ cfi_rel_offset (r8, 20) ++ stw r7, 16(sp) ++ cfi_rel_offset (r7, 16) ++ stw r6, 12(sp) ++ cfi_rel_offset (r6, 12) ++ stw r5, 8(sp) ++ cfi_rel_offset (r5, 8) ++ stw r4, 4(sp) ++ cfi_rel_offset (r4, 4) ++ stw ra, 0(sp) ++ cfi_rel_offset (ra, 0) ++ ++ /* Get pointer to linker struct. */ ++ mov r4, r14 ++ ++ /* Get the relocation offset. We're given a multiple of 4 and ++ need a multiple of 12, so multiply by 3. */ ++ slli r5, r15, 1 ++ add r5, r5, r15 ++ ++ /* Call the fixup routine. */ ++ nextpc r22 ++1: movhi r2, %hiadj(_GLOBAL_OFFSET_TABLE_ - 1b) ++ addi r2, r2, %lo(_GLOBAL_OFFSET_TABLE_ - 1b) ++ add r22, r22, r2 ++ ldw r2, %call(_dl_fixup)(r22) ++ callr r2 ++ ++ /* Restore the arguments and return address. */ ++ ldw ra, 0(sp) ++ ldw r4, 4(sp) ++ ldw r5, 8(sp) ++ ldw r6, 12(sp) ++ ldw r7, 16(sp) ++ ldw r8, 20(sp) ++ ldw r22, 24(sp) ++ addi sp, sp, 28 ++ cfi_adjust_cfa_offset (-28) ++ ++ /* Jump to the newly found address. */ ++ jmp r2 ++ ++ cfi_endproc +Index: glibc-2.10.1/sysdeps/nios2/elf/start.S +=================================================================== +--- /dev/null ++++ glibc-2.10.1/sysdeps/nios2/elf/start.S +@@ -0,0 +1,132 @@ ++/* Startup code for Nios II ++ Copyright (C) 1995, 1996, 1997, 1998, 2001, 2002, 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. ++ ++ In addition to the permissions in the GNU Lesser General Public ++ License, the Free Software Foundation gives you unlimited ++ permission to link the compiled version of this file with other ++ programs, and to distribute those programs without any restriction ++ coming from the use of this file. (The GNU Lesser General Public ++ License restrictions do apply in other respects; for example, they ++ cover modification of the file, and distribution when not linked ++ into another program.) ++ ++ Note that people who make modified versions of this file are not ++ obligated to grant this special exception for their modified ++ versions; it is their choice whether to do so. The GNU Lesser ++ General Public License gives permission to release a modified ++ version without this exception; this exception also makes it ++ possible to release a modified version which carries forward this ++ exception. ++ ++ 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 is the canonical entry point, usually the first thing in the text ++ segment. ++ ++ Note that the code in the .init section has already been run. ++ This includes _init and _libc_init ++ ++ The stack pointer, sp, will point to the argument count on the stack. ++ The initial state of the stack when a userspace process is started is: ++ ++ Purpose Start Address Length ++ Unspecified High Addresses ++ Referenced strings, etc. Varies ++ Unspecified ++ Null auxilliary vector entry 4bytes ++ Auxilliary vector entries 8bytes eac |
