OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-old/] [newlib-1.17.0/] [libgloss/] [cris/] [lcrt0.c] - Diff between revs 158 and 816

Go to most recent revision | Only display areas with differences | Details | Blame | View Log

Rev 158 Rev 816
/* Support for cris*-axis-linux-gnu and src/sim/cris simulator.
/* Support for cris*-axis-linux-gnu and src/sim/cris simulator.
   Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005 Axis Communications.
   Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005 Axis Communications.
   All rights reserved.
   All rights reserved.
 
 
   Redistribution and use in source and binary forms, with or without
   Redistribution and use in source and binary forms, with or without
   modification, are permitted provided that the following conditions
   modification, are permitted provided that the following conditions
   are met:
   are met:
 
 
   1. Redistributions of source code must retain the above copyright
   1. Redistributions of source code must retain the above copyright
      notice, this list of conditions and the following disclaimer.
      notice, this list of conditions and the following disclaimer.
 
 
   2. Neither the name of Axis Communications nor the names of its
   2. Neither the name of Axis Communications nor the names of its
      contributors may be used to endorse or promote products derived
      contributors may be used to endorse or promote products derived
      from this software without specific prior written permission.
      from this software without specific prior written permission.
 
 
   THIS SOFTWARE IS PROVIDED BY AXIS COMMUNICATIONS AND ITS CONTRIBUTORS
   THIS SOFTWARE IS PROVIDED BY AXIS COMMUNICATIONS AND ITS CONTRIBUTORS
   ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
   ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
   LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
   LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
   A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL AXIS
   A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL AXIS
   COMMUNICATIONS OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
   COMMUNICATIONS OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
   INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
   INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
   (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
   (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
   SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
   SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
   HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
   HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
   STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
   STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
   IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
   IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
   POSSIBILITY OF SUCH DAMAGE.  */
   POSSIBILITY OF SUCH DAMAGE.  */
 
 
#include "linunistd.h"
#include "linunistd.h"
 
 
extern void exit (int) __attribute ((__noreturn__));
extern void exit (int) __attribute ((__noreturn__));
 
 
__asm__ (".syntax no_register_prefix");
__asm__ (".syntax no_register_prefix");
 
 
#ifdef __ELF__
#ifdef __ELF__
/* This simulator magic for an earlier simulator was supposed to be
/* This simulator magic for an earlier simulator was supposed to be
   found two bytes before _start.  Let's keep it for sake of
   found two bytes before _start.  Let's keep it for sake of
   compatibility.  Trying to emit them with an ordinary const char[]
   compatibility.  Trying to emit them with an ordinary const char[]
   and attribute section makes gcc barf; it doesn't like having the
   and attribute section makes gcc barf; it doesn't like having the
   same section attribute for both code and data.
   same section attribute for both code and data.
   The code is supposed to cause a crash if someone jumps to 0.  */
   The code is supposed to cause a crash if someone jumps to 0.  */
__asm__
__asm__
 (
 (
  " .section .startup,\"ax\",@progbits\n"
  " .section .startup,\"ax\",@progbits\n"
  " .byte 55,55\n"
  " .byte 55,55\n"
  " move.d 0xbadacce5,r9\n"
  " move.d 0xbadacce5,r9\n"
  " clear.d [r9]\n"
  " clear.d [r9]\n"
  " setf\n"
  " setf\n"
  " setf\n"
  " setf\n"
  " .previous");
  " .previous");
#endif
#endif
 
 
__asm__
__asm__
 (
 (
#ifdef __AOUT__
#ifdef __AOUT__
  " .text\n\t"
  " .text\n\t"
#elif defined (__ELF__)
#elif defined (__ELF__)
  " .section .startup,\"ax\",@progbits\n"
  " .section .startup,\"ax\",@progbits\n"
#endif
#endif
  " .global __start\n"
  " .global __start\n"
  "__start:\n"
  "__start:\n"
  /* SP must be set up by the simulator or the system.  */
  /* SP must be set up by the simulator or the system.  */
 
 
  /* Find ARGC, ARGV and ENV.  */
  /* Find ARGC, ARGV and ENV.  */
  /* ARGC.  */
  /* ARGC.  */
  " move.d [sp],r10\n"
  " move.d [sp],r10\n"
 
 
  /* ARGV.  */
  /* ARGV.  */
  " move.d sp,r11\n"
  " move.d sp,r11\n"
  " addq 4,r11\n"
  " addq 4,r11\n"
 
 
  /* ENVP.  */
  /* ENVP.  */
  " move.d sp,r12\n"
  " move.d sp,r12\n"
  " addi r10.d,r12\n"
  " addi r10.d,r12\n"
  " addq 8,r12\n"
  " addq 8,r12\n"
 
 
  /* Terminate R9 and R6; we don't have a "console_print_etrax" or system
  /* Terminate R9 and R6; we don't have a "console_print_etrax" or system
     call function.  */
     call function.  */
  " clear.d r9\n"
  " clear.d r9\n"
  " clear.d r6\n"
  " clear.d r6\n"
  " move.d __start1,r13\n"
  " move.d __start1,r13\n"
  " jump r13\n"
  " jump r13\n"
  " setf\n"
  " setf\n"
#ifndef __AOUT__
#ifndef __AOUT__
  /* We rely on a.out not being in .data here.  Quite fragile, but
  /* We rely on a.out not being in .data here.  Quite fragile, but
     covered by e.g. running the GCC test-suite for cris-unknown-aout. */
     covered by e.g. running the GCC test-suite for cris-unknown-aout. */
  " .previous"
  " .previous"
#endif
#endif
  );
  );
 
 
extern void _Libctors (void);
extern void _Libctors (void);
extern void _Libdtors (void);
extern void _Libdtors (void);
 
 
extern void __init__start (void) __attribute ((weak));
extern void __init__start (void) __attribute ((weak));
extern void __aout__ctors (void) __attribute ((weak));
extern void __aout__ctors (void) __attribute ((weak));
 
 
static void start1 () __asm__ ("__start1") __attribute ((__used__));
static void start1 () __asm__ ("__start1") __attribute ((__used__));
static void
static void
start1 (int argc, char **argv, char **env)
start1 (int argc, char **argv, char **env)
{
{
#ifdef __ELF__
#ifdef __ELF__
  /* For ELF systems, we call _init and register _fini with atexit.  */
  /* For ELF systems, we call _init and register _fini with atexit.  */
  {
  {
    extern void _init (void);
    extern void _init (void);
    extern void _fini (void);
    extern void _fini (void);
    _init ();
    _init ();
    if (atexit (_fini) != 0)
    if (atexit (_fini) != 0)
      exit (-1);
      exit (-1);
  }
  }
#else
#else
  /* Constructors which may get here through the ELF .init section, when
  /* Constructors which may get here through the ELF .init section, when
     linking ELF and producing a.out.  */
     linking ELF and producing a.out.  */
  if (__init__start)
  if (__init__start)
    __init__start ();
    __init__start ();
 
 
  if (__aout__ctors)
  if (__aout__ctors)
    __aout__ctors ();
    __aout__ctors ();
 
 
  /* Call constructors in shared libraries. */
  /* Call constructors in shared libraries. */
  _Libctors ();
  _Libctors ();
 
 
  if (atexit (_Libdtors) != 0)
  if (atexit (_Libdtors) != 0)
    exit (-1);
    exit (-1);
#endif
#endif
 
 
  /* Call the user program.  */
  /* Call the user program.  */
  exit (main (argc, argv, env));
  exit (main (argc, argv, env));
}
}
 
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.