]> Git Repo - binutils.git/blame - sim/arm/run.c
* infrun.c (wait_for_inferior): Add support for dynamic function
[binutils.git] / sim / arm / run.c
CommitLineData
2494eaf6
SC
1/* run front end support for ARM
2 Copyright (C) 1996 Free Software Foundation, Inc.
3
4This file is part of ARM SIM
5
6GNU CC is free software; you can redistribute it and/or modify
7it under the terms of the GNU General Public License as published by
8the Free Software Foundation; either version 2, or (at your option)
9any later version.
10
11GNU CC is distributed in the hope that it will be useful,
12but WITHOUT ANY WARRANTY; without even the implied warranty of
13MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14GNU General Public License for more details.
15
16You should have received a copy of the GNU General Public License
17along with GNU CC; see the file COPYING. If not, write to
6c9638b4 18Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111, USA. */
2494eaf6
SC
19
20
21/* Steve Chamberlain
22 [email protected] */
23
24#include <stdio.h>
25#include <varargs.h>
26#include "bfd.h"
2494eaf6
SC
27#include "remote-sim.h"
28
29void usage();
30extern int optind;
31extern char *optarg;
32
e47e4805 33int verbose = 0;
2494eaf6
SC
34int target_byte_order;
35
36int
37main (ac, av)
38 int ac;
39 char **av;
40{
41 bfd *abfd;
42 bfd_vma start_address;
43 asection *s;
44 int i;
2494eaf6
SC
45 int trace = 0;
46 char *name = "";
47
48 while ((i = getopt (ac, av, "m:p:s:tv")) != EOF)
49 switch (i)
50 {
51 case 'm':
52 sim_size (atoi (optarg));
53 break;
54 case 'p':
55 sim_set_profile (atoi (optarg));
56 break;
57 case 's':
58 sim_set_profile_size (atoi (optarg));
59 break;
60 case 't':
61 trace = 1;
62 break;
63 case 'v':
64 verbose = 1;
65 break;
66 default:
67 usage();
68 }
69 ac -= optind;
70 av += optind;
71
72 if (ac != 1)
73 usage();
74
75 name = *av;
76
77 if (verbose)
78 {
79 printf ("run %s\n", name);
80 }
81 abfd = bfd_openr (name, 0);
82 if (abfd)
83 {
84 if (bfd_check_format (abfd, bfd_object))
85 {
86
87 for (s = abfd->sections; s; s = s->next)
88 {
89 unsigned char *buffer = malloc (bfd_section_size (abfd, s));
90 bfd_get_section_contents (abfd,
91 s,
92 buffer,
93 0,
94 bfd_section_size (abfd, s));
95 sim_write (s->vma, buffer, bfd_section_size (abfd, s));
96 }
97
98 start_address = bfd_get_start_address (abfd);
99 sim_create_inferior (start_address, NULL, NULL);
100
101 target_byte_order = abfd->xvec->byteorder_big_p ? 4321 : 1234;
102
103 if (trace)
104 {
105 int done = 0;
106 while (!done)
107 {
108 done = sim_trace ();
109 }
110 }
111 else
112 {
113 sim_resume (0, 0);
114 }
115 if (verbose)
116 sim_info (0);
117
118 /* Assume we left through the exit system call,
c8aea29b 119 in which case r0 has the exit code */
2494eaf6
SC
120 {
121 unsigned char b[4];
c8aea29b
SC
122 sim_fetch_register (0, b);
123 return b[0];
2494eaf6
SC
124 }
125
126 }
127 }
128
129 return 1;
130}
131
132void
133usage()
134{
135 fprintf (stderr, "usage: run [-tv] program\n");
136 exit (1);
137}
138
139\f
140/* Callbacks used by the simulator proper. */
141
142void
143printf_filtered (va_alist)
144 va_dcl
145{
146 va_list args;
147 char *format;
148
149 va_start (args);
150 format = va_arg (args, char *);
151
152 vfprintf (stdout, format, args);
153 va_end (args);
154}
This page took 0.088879 seconds and 4 git commands to generate.