Commit | Line | Data |
---|---|---|
748894bf | 1 | /* Target-dependent code for the Motorola 68000 series. |
c6f0559b | 2 | |
b811d2c2 | 3 | Copyright (C) 1990-2020 Free Software Foundation, Inc. |
c906108c | 4 | |
c5aa993b | 5 | This file is part of GDB. |
c906108c | 6 | |
c5aa993b JM |
7 | This program is free software; you can redistribute it and/or modify |
8 | it under the terms of the GNU General Public License as published by | |
a9762ec7 | 9 | the Free Software Foundation; either version 3 of the License, or |
c5aa993b | 10 | (at your option) any later version. |
c906108c | 11 | |
c5aa993b JM |
12 | This program is distributed in the hope that it will be useful, |
13 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
15 | GNU General Public License for more details. | |
c906108c | 16 | |
c5aa993b | 17 | You should have received a copy of the GNU General Public License |
a9762ec7 | 18 | along with this program. If not, see <http://www.gnu.org/licenses/>. */ |
c906108c SS |
19 | |
20 | #include "defs.h" | |
82ca8957 | 21 | #include "dwarf2/frame.h" |
c906108c | 22 | #include "frame.h" |
8de307e0 AS |
23 | #include "frame-base.h" |
24 | #include "frame-unwind.h" | |
e6bb342a | 25 | #include "gdbtypes.h" |
c906108c SS |
26 | #include "symtab.h" |
27 | #include "gdbcore.h" | |
28 | #include "value.h" | |
7a292a7a | 29 | #include "inferior.h" |
4e052eda | 30 | #include "regcache.h" |
5d3ed2e3 | 31 | #include "arch-utils.h" |
55809acb | 32 | #include "osabi.h" |
a89aa300 | 33 | #include "dis-asm.h" |
8ed86d01 | 34 | #include "target-descriptions.h" |
1841ee5d | 35 | #include "floatformat.h" |
3b2ca824 | 36 | #include "target-float.h" |
3eba3a01 TT |
37 | #include "elf-bfd.h" |
38 | #include "elf/m68k.h" | |
32eeb91a AS |
39 | |
40 | #include "m68k-tdep.h" | |
c906108c | 41 | \f |
c5aa993b | 42 | |
89c3b6d3 PDM |
43 | #define P_LINKL_FP 0x480e |
44 | #define P_LINKW_FP 0x4e56 | |
45 | #define P_PEA_FP 0x4856 | |
8de307e0 AS |
46 | #define P_MOVEAL_SP_FP 0x2c4f |
47 | #define P_ADDAW_SP 0xdefc | |
48 | #define P_ADDAL_SP 0xdffc | |
49 | #define P_SUBQW_SP 0x514f | |
50 | #define P_SUBQL_SP 0x518f | |
51 | #define P_LEA_SP_SP 0x4fef | |
52 | #define P_LEA_PC_A5 0x4bfb0170 | |
53 | #define P_FMOVEMX_SP 0xf227 | |
54 | #define P_MOVEL_SP 0x2f00 | |
55 | #define P_MOVEML_SP 0x48e7 | |
89c3b6d3 | 56 | |
025bb325 | 57 | /* Offset from SP to first arg on stack at first instruction of a function. */ |
103a1597 GS |
58 | #define SP_ARG0 (1 * 4) |
59 | ||
103a1597 GS |
60 | #if !defined (BPT_VECTOR) |
61 | #define BPT_VECTOR 0xf | |
62 | #endif | |
63 | ||
04180708 | 64 | constexpr gdb_byte m68k_break_insn[] = {0x4e, (0x40 | BPT_VECTOR)}; |
598cc9dc | 65 | |
04180708 | 66 | typedef BP_MANIPULATION (m68k_break_insn) m68k_breakpoint; |
4713453b AS |
67 | \f |
68 | ||
4713453b | 69 | /* Construct types for ISA-specific registers. */ |
209bd28e UW |
70 | static struct type * |
71 | m68k_ps_type (struct gdbarch *gdbarch) | |
4713453b | 72 | { |
209bd28e UW |
73 | struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); |
74 | ||
75 | if (!tdep->m68k_ps_type) | |
76 | { | |
77 | struct type *type; | |
78 | ||
77b7c781 | 79 | type = arch_flags_type (gdbarch, "builtin_type_m68k_ps", 32); |
209bd28e UW |
80 | append_flags_type_flag (type, 0, "C"); |
81 | append_flags_type_flag (type, 1, "V"); | |
82 | append_flags_type_flag (type, 2, "Z"); | |
83 | append_flags_type_flag (type, 3, "N"); | |
84 | append_flags_type_flag (type, 4, "X"); | |
85 | append_flags_type_flag (type, 8, "I0"); | |
86 | append_flags_type_flag (type, 9, "I1"); | |
87 | append_flags_type_flag (type, 10, "I2"); | |
88 | append_flags_type_flag (type, 12, "M"); | |
89 | append_flags_type_flag (type, 13, "S"); | |
90 | append_flags_type_flag (type, 14, "T0"); | |
91 | append_flags_type_flag (type, 15, "T1"); | |
92 | ||
93 | tdep->m68k_ps_type = type; | |
94 | } | |
95 | ||
96 | return tdep->m68k_ps_type; | |
4713453b | 97 | } |
103a1597 | 98 | |
27067745 UW |
99 | static struct type * |
100 | m68881_ext_type (struct gdbarch *gdbarch) | |
101 | { | |
102 | struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); | |
103 | ||
104 | if (!tdep->m68881_ext_type) | |
105 | tdep->m68881_ext_type | |
e9bb382b | 106 | = arch_float_type (gdbarch, -1, "builtin_type_m68881_ext", |
27067745 UW |
107 | floatformats_m68881_ext); |
108 | ||
109 | return tdep->m68881_ext_type; | |
110 | } | |
111 | ||
d85fe7f7 AS |
112 | /* Return the GDB type object for the "standard" data type of data in |
113 | register N. This should be int for D0-D7, SR, FPCONTROL and | |
114 | FPSTATUS, long double for FP0-FP7, and void pointer for all others | |
115 | (A0-A7, PC, FPIADDR). Note, for registers which contain | |
116 | addresses return pointer to void, not pointer to char, because we | |
117 | don't want to attempt to print the string after printing the | |
118 | address. */ | |
5d3ed2e3 GS |
119 | |
120 | static struct type * | |
8de307e0 | 121 | m68k_register_type (struct gdbarch *gdbarch, int regnum) |
5d3ed2e3 | 122 | { |
c984b7ff | 123 | struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); |
03dac896 | 124 | |
8ed86d01 VP |
125 | if (tdep->fpregs_present) |
126 | { | |
c984b7ff UW |
127 | if (regnum >= gdbarch_fp0_regnum (gdbarch) |
128 | && regnum <= gdbarch_fp0_regnum (gdbarch) + 7) | |
8ed86d01 VP |
129 | { |
130 | if (tdep->flavour == m68k_coldfire_flavour) | |
131 | return builtin_type (gdbarch)->builtin_double; | |
132 | else | |
27067745 | 133 | return m68881_ext_type (gdbarch); |
8ed86d01 VP |
134 | } |
135 | ||
136 | if (regnum == M68K_FPI_REGNUM) | |
0dfff4cb | 137 | return builtin_type (gdbarch)->builtin_func_ptr; |
8ed86d01 VP |
138 | |
139 | if (regnum == M68K_FPC_REGNUM || regnum == M68K_FPS_REGNUM) | |
df4df182 | 140 | return builtin_type (gdbarch)->builtin_int32; |
8ed86d01 VP |
141 | } |
142 | else | |
143 | { | |
144 | if (regnum >= M68K_FP0_REGNUM && regnum <= M68K_FPI_REGNUM) | |
df4df182 | 145 | return builtin_type (gdbarch)->builtin_int0; |
8ed86d01 | 146 | } |
03dac896 | 147 | |
c984b7ff | 148 | if (regnum == gdbarch_pc_regnum (gdbarch)) |
0dfff4cb | 149 | return builtin_type (gdbarch)->builtin_func_ptr; |
03dac896 | 150 | |
32eeb91a | 151 | if (regnum >= M68K_A0_REGNUM && regnum <= M68K_A0_REGNUM + 7) |
0dfff4cb | 152 | return builtin_type (gdbarch)->builtin_data_ptr; |
03dac896 | 153 | |
4713453b | 154 | if (regnum == M68K_PS_REGNUM) |
209bd28e | 155 | return m68k_ps_type (gdbarch); |
4713453b | 156 | |
df4df182 | 157 | return builtin_type (gdbarch)->builtin_int32; |
5d3ed2e3 GS |
158 | } |
159 | ||
27087b7f | 160 | static const char * const m68k_register_names[] = { |
5d3ed2e3 GS |
161 | "d0", "d1", "d2", "d3", "d4", "d5", "d6", "d7", |
162 | "a0", "a1", "a2", "a3", "a4", "a5", "fp", "sp", | |
163 | "ps", "pc", | |
164 | "fp0", "fp1", "fp2", "fp3", "fp4", "fp5", "fp6", "fp7", | |
8ed86d01 | 165 | "fpcontrol", "fpstatus", "fpiaddr" |
5d3ed2e3 GS |
166 | }; |
167 | ||
8ed86d01 | 168 | /* Function: m68k_register_name |
025bb325 | 169 | Returns the name of the standard m68k register regnum. */ |
8ed86d01 VP |
170 | |
171 | static const char * | |
d93859e2 | 172 | m68k_register_name (struct gdbarch *gdbarch, int regnum) |
8ed86d01 VP |
173 | { |
174 | if (regnum < 0 || regnum >= ARRAY_SIZE (m68k_register_names)) | |
5d3ed2e3 | 175 | internal_error (__FILE__, __LINE__, |
025bb325 MS |
176 | _("m68k_register_name: illegal register number %d"), |
177 | regnum); | |
86443c3e MK |
178 | else if (regnum >= M68K_FP0_REGNUM && regnum <= M68K_FPI_REGNUM |
179 | && gdbarch_tdep (gdbarch)->fpregs_present == 0) | |
180 | return ""; | |
5d3ed2e3 | 181 | else |
8ed86d01 | 182 | return m68k_register_names[regnum]; |
5d3ed2e3 | 183 | } |
e47577ab MK |
184 | \f |
185 | /* Return nonzero if a value of type TYPE stored in register REGNUM | |
186 | needs any special handling. */ | |
187 | ||
188 | static int | |
025bb325 MS |
189 | m68k_convert_register_p (struct gdbarch *gdbarch, |
190 | int regnum, struct type *type) | |
e47577ab | 191 | { |
0abe36f5 | 192 | if (!gdbarch_tdep (gdbarch)->fpregs_present) |
8ed86d01 | 193 | return 0; |
83acabca | 194 | return (regnum >= M68K_FP0_REGNUM && regnum <= M68K_FP0_REGNUM + 7 |
e3ec9b69 | 195 | /* We only support floating-point values. */ |
78134374 | 196 | && type->code () == TYPE_CODE_FLT |
3c1ac6e7 | 197 | && type != register_type (gdbarch, M68K_FP0_REGNUM)); |
e47577ab MK |
198 | } |
199 | ||
200 | /* Read a value of type TYPE from register REGNUM in frame FRAME, and | |
201 | return its contents in TO. */ | |
202 | ||
8dccd430 | 203 | static int |
e47577ab | 204 | m68k_register_to_value (struct frame_info *frame, int regnum, |
8dccd430 PA |
205 | struct type *type, gdb_byte *to, |
206 | int *optimizedp, int *unavailablep) | |
e47577ab | 207 | { |
d8e07dda | 208 | struct gdbarch *gdbarch = get_frame_arch (frame); |
f5cf7aa1 | 209 | gdb_byte from[M68K_MAX_REGISTER_SIZE]; |
e3ec9b69 | 210 | struct type *fpreg_type = register_type (gdbarch, M68K_FP0_REGNUM); |
e47577ab | 211 | |
78134374 | 212 | gdb_assert (type->code () == TYPE_CODE_FLT); |
8dccd430 PA |
213 | |
214 | /* Convert to TYPE. */ | |
d8e07dda YQ |
215 | if (!get_frame_register_bytes (frame, regnum, 0, |
216 | register_size (gdbarch, regnum), | |
8dccd430 PA |
217 | from, optimizedp, unavailablep)) |
218 | return 0; | |
219 | ||
3b2ca824 | 220 | target_float_convert (from, fpreg_type, to, type); |
8dccd430 PA |
221 | *optimizedp = *unavailablep = 0; |
222 | return 1; | |
e47577ab MK |
223 | } |
224 | ||
225 | /* Write the contents FROM of a value of type TYPE into register | |
226 | REGNUM in frame FRAME. */ | |
227 | ||
228 | static void | |
229 | m68k_value_to_register (struct frame_info *frame, int regnum, | |
f5cf7aa1 | 230 | struct type *type, const gdb_byte *from) |
e47577ab | 231 | { |
f5cf7aa1 | 232 | gdb_byte to[M68K_MAX_REGISTER_SIZE]; |
c984b7ff UW |
233 | struct type *fpreg_type = register_type (get_frame_arch (frame), |
234 | M68K_FP0_REGNUM); | |
e47577ab MK |
235 | |
236 | /* We only support floating-point values. */ | |
78134374 | 237 | if (type->code () != TYPE_CODE_FLT) |
e47577ab | 238 | { |
8a3fe4f8 AC |
239 | warning (_("Cannot convert non-floating-point type " |
240 | "to floating-point register value.")); | |
e47577ab MK |
241 | return; |
242 | } | |
243 | ||
83acabca | 244 | /* Convert from TYPE. */ |
3b2ca824 | 245 | target_float_convert (from, type, to, fpreg_type); |
e47577ab MK |
246 | put_frame_register (frame, regnum, to); |
247 | } | |
248 | ||
8de307e0 | 249 | \f |
f595cb19 MK |
250 | /* There is a fair number of calling conventions that are in somewhat |
251 | wide use. The 68000/08/10 don't support an FPU, not even as a | |
252 | coprocessor. All function return values are stored in %d0/%d1. | |
253 | Structures are returned in a static buffer, a pointer to which is | |
254 | returned in %d0. This means that functions returning a structure | |
255 | are not re-entrant. To avoid this problem some systems use a | |
256 | convention where the caller passes a pointer to a buffer in %a1 | |
257 | where the return values is to be stored. This convention is the | |
258 | default, and is implemented in the function m68k_return_value. | |
259 | ||
260 | The 68020/030/040/060 do support an FPU, either as a coprocessor | |
261 | (68881/2) or built-in (68040/68060). That's why System V release 4 | |
30baf67b | 262 | (SVR4) introduces a new calling convention specified by the SVR4 |
f595cb19 MK |
263 | psABI. Integer values are returned in %d0/%d1, pointer return |
264 | values in %a0 and floating values in %fp0. When calling functions | |
265 | returning a structure the caller should pass a pointer to a buffer | |
266 | for the return value in %a0. This convention is implemented in the | |
267 | function m68k_svr4_return_value, and by appropriately setting the | |
268 | struct_value_regnum member of `struct gdbarch_tdep'. | |
269 | ||
270 | GNU/Linux returns values in the same way as SVR4 does, but uses %a1 | |
271 | for passing the structure return value buffer. | |
272 | ||
273 | GCC can also generate code where small structures are returned in | |
274 | %d0/%d1 instead of in memory by using -freg-struct-return. This is | |
275 | the default on NetBSD a.out, OpenBSD and GNU/Linux and several | |
276 | embedded systems. This convention is implemented by setting the | |
3eba3a01 TT |
277 | struct_return member of `struct gdbarch_tdep' to reg_struct_return. |
278 | ||
279 | GCC also has an "embedded" ABI. This works like the SVR4 ABI, | |
280 | except that pointers are returned in %D0. This is implemented by | |
281 | setting the pointer_result_regnum member of `struct gdbarch_tdep' | |
282 | as appropriate. */ | |
f595cb19 MK |
283 | |
284 | /* Read a function return value of TYPE from REGCACHE, and copy that | |
8de307e0 | 285 | into VALBUF. */ |
942dc0e9 GS |
286 | |
287 | static void | |
8de307e0 | 288 | m68k_extract_return_value (struct type *type, struct regcache *regcache, |
f5cf7aa1 | 289 | gdb_byte *valbuf) |
942dc0e9 | 290 | { |
8de307e0 | 291 | int len = TYPE_LENGTH (type); |
f5cf7aa1 | 292 | gdb_byte buf[M68K_MAX_REGISTER_SIZE]; |
942dc0e9 | 293 | |
3eba3a01 TT |
294 | if (type->code () == TYPE_CODE_PTR && len == 4) |
295 | { | |
296 | struct gdbarch *gdbarch = regcache->arch (); | |
297 | struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); | |
298 | regcache->raw_read (tdep->pointer_result_regnum, valbuf); | |
299 | } | |
300 | else if (len <= 4) | |
8de307e0 | 301 | { |
0b883586 | 302 | regcache->raw_read (M68K_D0_REGNUM, buf); |
8de307e0 AS |
303 | memcpy (valbuf, buf + (4 - len), len); |
304 | } | |
305 | else if (len <= 8) | |
306 | { | |
0b883586 | 307 | regcache->raw_read (M68K_D0_REGNUM, buf); |
8de307e0 | 308 | memcpy (valbuf, buf + (8 - len), len - 4); |
0b883586 | 309 | regcache->raw_read (M68K_D1_REGNUM, valbuf + (len - 4)); |
8de307e0 AS |
310 | } |
311 | else | |
312 | internal_error (__FILE__, __LINE__, | |
e2e0b3e5 | 313 | _("Cannot extract return value of %d bytes long."), len); |
942dc0e9 GS |
314 | } |
315 | ||
942dc0e9 | 316 | static void |
f595cb19 | 317 | m68k_svr4_extract_return_value (struct type *type, struct regcache *regcache, |
f5cf7aa1 | 318 | gdb_byte *valbuf) |
942dc0e9 | 319 | { |
f5cf7aa1 | 320 | gdb_byte buf[M68K_MAX_REGISTER_SIZE]; |
ac7936df | 321 | struct gdbarch *gdbarch = regcache->arch (); |
c984b7ff | 322 | struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); |
942dc0e9 | 323 | |
78134374 | 324 | if (tdep->float_return && type->code () == TYPE_CODE_FLT) |
8de307e0 | 325 | { |
c984b7ff | 326 | struct type *fpreg_type = register_type (gdbarch, M68K_FP0_REGNUM); |
0b883586 | 327 | regcache->raw_read (M68K_FP0_REGNUM, buf); |
3b2ca824 | 328 | target_float_convert (buf, fpreg_type, valbuf, type); |
8de307e0 | 329 | } |
f595cb19 MK |
330 | else |
331 | m68k_extract_return_value (type, regcache, valbuf); | |
332 | } | |
333 | ||
334 | /* Write a function return value of TYPE from VALBUF into REGCACHE. */ | |
335 | ||
336 | static void | |
337 | m68k_store_return_value (struct type *type, struct regcache *regcache, | |
f5cf7aa1 | 338 | const gdb_byte *valbuf) |
f595cb19 MK |
339 | { |
340 | int len = TYPE_LENGTH (type); | |
942dc0e9 | 341 | |
3eba3a01 TT |
342 | if (type->code () == TYPE_CODE_PTR && len == 4) |
343 | { | |
344 | struct gdbarch *gdbarch = regcache->arch (); | |
345 | struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); | |
346 | regcache->raw_write (tdep->pointer_result_regnum, valbuf); | |
347 | /* gdb historically also set D0 in the SVR4 case. */ | |
348 | if (tdep->pointer_result_regnum != M68K_D0_REGNUM) | |
349 | regcache->raw_write (M68K_D0_REGNUM, valbuf); | |
350 | } | |
351 | else if (len <= 4) | |
4f0420fd | 352 | regcache->raw_write_part (M68K_D0_REGNUM, 4 - len, len, valbuf); |
8de307e0 AS |
353 | else if (len <= 8) |
354 | { | |
4f0420fd | 355 | regcache->raw_write_part (M68K_D0_REGNUM, 8 - len, len - 4, valbuf); |
10eaee5f | 356 | regcache->raw_write (M68K_D1_REGNUM, valbuf + (len - 4)); |
8de307e0 AS |
357 | } |
358 | else | |
359 | internal_error (__FILE__, __LINE__, | |
e2e0b3e5 | 360 | _("Cannot store return value of %d bytes long."), len); |
8de307e0 | 361 | } |
942dc0e9 | 362 | |
f595cb19 MK |
363 | static void |
364 | m68k_svr4_store_return_value (struct type *type, struct regcache *regcache, | |
f5cf7aa1 | 365 | const gdb_byte *valbuf) |
942dc0e9 | 366 | { |
ac7936df | 367 | struct gdbarch *gdbarch = regcache->arch (); |
c984b7ff | 368 | struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); |
8de307e0 | 369 | |
78134374 | 370 | if (tdep->float_return && type->code () == TYPE_CODE_FLT) |
f595cb19 | 371 | { |
c984b7ff | 372 | struct type *fpreg_type = register_type (gdbarch, M68K_FP0_REGNUM); |
f5cf7aa1 | 373 | gdb_byte buf[M68K_MAX_REGISTER_SIZE]; |
3b2ca824 | 374 | target_float_convert (valbuf, type, buf, fpreg_type); |
10eaee5f | 375 | regcache->raw_write (M68K_FP0_REGNUM, buf); |
f595cb19 | 376 | } |
f595cb19 MK |
377 | else |
378 | m68k_store_return_value (type, regcache, valbuf); | |
942dc0e9 GS |
379 | } |
380 | ||
108fb0f7 AS |
381 | /* Return non-zero if TYPE, which is assumed to be a structure, union or |
382 | complex type, should be returned in registers for architecture | |
f595cb19 MK |
383 | GDBARCH. */ |
384 | ||
c481dac7 | 385 | static int |
f595cb19 | 386 | m68k_reg_struct_return_p (struct gdbarch *gdbarch, struct type *type) |
c481dac7 | 387 | { |
f595cb19 | 388 | struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); |
78134374 | 389 | enum type_code code = type->code (); |
f595cb19 | 390 | int len = TYPE_LENGTH (type); |
c481dac7 | 391 | |
108fb0f7 | 392 | gdb_assert (code == TYPE_CODE_STRUCT || code == TYPE_CODE_UNION |
3eba3a01 | 393 | || code == TYPE_CODE_COMPLEX || code == TYPE_CODE_ARRAY); |
f595cb19 MK |
394 | |
395 | if (tdep->struct_return == pcc_struct_return) | |
396 | return 0; | |
397 | ||
3eba3a01 TT |
398 | const bool is_vector = code == TYPE_CODE_ARRAY && type->is_vector (); |
399 | ||
400 | if (is_vector | |
401 | && check_typedef (TYPE_TARGET_TYPE (type))->code () == TYPE_CODE_FLT) | |
402 | return 0; | |
403 | ||
404 | /* According to m68k_return_in_memory in the m68k GCC back-end, | |
405 | strange things happen for small aggregate types. Aggregate types | |
406 | with only one component are always returned like the type of the | |
407 | component. Aggregate types whose size is 2, 4, or 8 are returned | |
408 | in registers if their natural alignment is at least 16 bits. | |
409 | ||
410 | We reject vectors here, as experimentally this gives the correct | |
411 | answer. */ | |
412 | if (!is_vector && (len == 2 || len == 4 || len == 8)) | |
413 | return type_align (type) >= 2; | |
414 | ||
f595cb19 | 415 | return (len == 1 || len == 2 || len == 4 || len == 8); |
c481dac7 AS |
416 | } |
417 | ||
f595cb19 MK |
418 | /* Determine, for architecture GDBARCH, how a return value of TYPE |
419 | should be returned. If it is supposed to be returned in registers, | |
420 | and READBUF is non-zero, read the appropriate value from REGCACHE, | |
421 | and copy it into READBUF. If WRITEBUF is non-zero, write the value | |
422 | from WRITEBUF into REGCACHE. */ | |
423 | ||
424 | static enum return_value_convention | |
6a3a010b | 425 | m68k_return_value (struct gdbarch *gdbarch, struct value *function, |
c055b101 CV |
426 | struct type *type, struct regcache *regcache, |
427 | gdb_byte *readbuf, const gdb_byte *writebuf) | |
f595cb19 | 428 | { |
78134374 | 429 | enum type_code code = type->code (); |
f595cb19 | 430 | |
1c845060 | 431 | /* GCC returns a `long double' in memory too. */ |
108fb0f7 | 432 | if (((code == TYPE_CODE_STRUCT || code == TYPE_CODE_UNION |
3eba3a01 | 433 | || code == TYPE_CODE_COMPLEX || code == TYPE_CODE_ARRAY) |
1c845060 MK |
434 | && !m68k_reg_struct_return_p (gdbarch, type)) |
435 | || (code == TYPE_CODE_FLT && TYPE_LENGTH (type) == 12)) | |
436 | { | |
437 | /* The default on m68k is to return structures in static memory. | |
438 | Consequently a function must return the address where we can | |
439 | find the return value. */ | |
f595cb19 | 440 | |
1c845060 MK |
441 | if (readbuf) |
442 | { | |
443 | ULONGEST addr; | |
444 | ||
445 | regcache_raw_read_unsigned (regcache, M68K_D0_REGNUM, &addr); | |
446 | read_memory (addr, readbuf, TYPE_LENGTH (type)); | |
447 | } | |
448 | ||
449 | return RETURN_VALUE_ABI_RETURNS_ADDRESS; | |
450 | } | |
f595cb19 MK |
451 | |
452 | if (readbuf) | |
453 | m68k_extract_return_value (type, regcache, readbuf); | |
454 | if (writebuf) | |
455 | m68k_store_return_value (type, regcache, writebuf); | |
456 | ||
457 | return RETURN_VALUE_REGISTER_CONVENTION; | |
458 | } | |
459 | ||
460 | static enum return_value_convention | |
6a3a010b | 461 | m68k_svr4_return_value (struct gdbarch *gdbarch, struct value *function, |
c055b101 CV |
462 | struct type *type, struct regcache *regcache, |
463 | gdb_byte *readbuf, const gdb_byte *writebuf) | |
f595cb19 | 464 | { |
78134374 | 465 | enum type_code code = type->code (); |
f595cb19 | 466 | |
3eba3a01 TT |
467 | /* Aggregates with a single member are always returned like their |
468 | sole element. */ | |
469 | if ((code == TYPE_CODE_STRUCT || code == TYPE_CODE_UNION) | |
470 | && type->num_fields () == 1) | |
471 | { | |
472 | type = check_typedef (type->field (0).type ()); | |
473 | return m68k_svr4_return_value (gdbarch, function, type, regcache, | |
474 | readbuf, writebuf); | |
475 | } | |
476 | ||
477 | if (((code == TYPE_CODE_STRUCT || code == TYPE_CODE_UNION | |
478 | || code == TYPE_CODE_COMPLEX || code == TYPE_CODE_ARRAY) | |
479 | && !m68k_reg_struct_return_p (gdbarch, type)) | |
480 | /* GCC may return a `long double' in memory too. */ | |
481 | || (!gdbarch_tdep (gdbarch)->float_return | |
482 | && code == TYPE_CODE_FLT | |
483 | && TYPE_LENGTH (type) == 12)) | |
51da707a MK |
484 | { |
485 | /* The System V ABI says that: | |
486 | ||
487 | "A function returning a structure or union also sets %a0 to | |
488 | the value it finds in %a0. Thus when the caller receives | |
489 | control again, the address of the returned object resides in | |
490 | register %a0." | |
491 | ||
492 | So the ABI guarantees that we can always find the return | |
3eba3a01 TT |
493 | value just after the function has returned. |
494 | ||
495 | However, GCC also implements the "embedded" ABI. That ABI | |
496 | does not preserve %a0 across calls, but does write the value | |
497 | back to %d0. */ | |
51da707a MK |
498 | |
499 | if (readbuf) | |
500 | { | |
3eba3a01 | 501 | struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); |
51da707a MK |
502 | ULONGEST addr; |
503 | ||
3eba3a01 TT |
504 | regcache_raw_read_unsigned (regcache, tdep->pointer_result_regnum, |
505 | &addr); | |
51da707a MK |
506 | read_memory (addr, readbuf, TYPE_LENGTH (type)); |
507 | } | |
508 | ||
509 | return RETURN_VALUE_ABI_RETURNS_ADDRESS; | |
510 | } | |
f595cb19 | 511 | |
f595cb19 MK |
512 | if (readbuf) |
513 | m68k_svr4_extract_return_value (type, regcache, readbuf); | |
514 | if (writebuf) | |
515 | m68k_svr4_store_return_value (type, regcache, writebuf); | |
516 | ||
517 | return RETURN_VALUE_REGISTER_CONVENTION; | |
518 | } | |
519 | \f | |
392a587b | 520 | |
9bb47d95 NS |
521 | /* Always align the frame to a 4-byte boundary. This is required on |
522 | coldfire and harmless on the rest. */ | |
523 | ||
524 | static CORE_ADDR | |
525 | m68k_frame_align (struct gdbarch *gdbarch, CORE_ADDR sp) | |
526 | { | |
527 | /* Align the stack to four bytes. */ | |
528 | return sp & ~3; | |
529 | } | |
530 | ||
8de307e0 | 531 | static CORE_ADDR |
7d9b040b | 532 | m68k_push_dummy_call (struct gdbarch *gdbarch, struct value *function, |
8de307e0 | 533 | struct regcache *regcache, CORE_ADDR bp_addr, int nargs, |
cf84fa6b AH |
534 | struct value **args, CORE_ADDR sp, |
535 | function_call_return_method return_method, | |
8de307e0 | 536 | CORE_ADDR struct_addr) |
7f8e7424 | 537 | { |
f595cb19 | 538 | struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); |
e17a4113 | 539 | enum bfd_endian byte_order = gdbarch_byte_order (gdbarch); |
f5cf7aa1 | 540 | gdb_byte buf[4]; |
8de307e0 AS |
541 | int i; |
542 | ||
543 | /* Push arguments in reverse order. */ | |
544 | for (i = nargs - 1; i >= 0; i--) | |
545 | { | |
4754a64e | 546 | struct type *value_type = value_enclosing_type (args[i]); |
c481dac7 | 547 | int len = TYPE_LENGTH (value_type); |
8de307e0 | 548 | int container_len = (len + 3) & ~3; |
c481dac7 AS |
549 | int offset; |
550 | ||
551 | /* Non-scalars bigger than 4 bytes are left aligned, others are | |
552 | right aligned. */ | |
78134374 SM |
553 | if ((value_type->code () == TYPE_CODE_STRUCT |
554 | || value_type->code () == TYPE_CODE_UNION | |
555 | || value_type->code () == TYPE_CODE_ARRAY) | |
c481dac7 AS |
556 | && len > 4) |
557 | offset = 0; | |
558 | else | |
559 | offset = container_len - len; | |
8de307e0 | 560 | sp -= container_len; |
46615f07 | 561 | write_memory (sp + offset, value_contents_all (args[i]), len); |
8de307e0 AS |
562 | } |
563 | ||
c481dac7 | 564 | /* Store struct value address. */ |
cf84fa6b | 565 | if (return_method == return_method_struct) |
8de307e0 | 566 | { |
e17a4113 | 567 | store_unsigned_integer (buf, 4, byte_order, struct_addr); |
b66f5587 | 568 | regcache->cooked_write (tdep->struct_value_regnum, buf); |
8de307e0 AS |
569 | } |
570 | ||
571 | /* Store return address. */ | |
572 | sp -= 4; | |
e17a4113 | 573 | store_unsigned_integer (buf, 4, byte_order, bp_addr); |
8de307e0 AS |
574 | write_memory (sp, buf, 4); |
575 | ||
576 | /* Finally, update the stack pointer... */ | |
e17a4113 | 577 | store_unsigned_integer (buf, 4, byte_order, sp); |
b66f5587 | 578 | regcache->cooked_write (M68K_SP_REGNUM, buf); |
8de307e0 AS |
579 | |
580 | /* ...and fake a frame pointer. */ | |
b66f5587 | 581 | regcache->cooked_write (M68K_FP_REGNUM, buf); |
8de307e0 AS |
582 | |
583 | /* DWARF2/GCC uses the stack address *before* the function call as a | |
584 | frame's CFA. */ | |
585 | return sp + 8; | |
7f8e7424 | 586 | } |
6dd0fba6 NS |
587 | |
588 | /* Convert a dwarf or dwarf2 regnumber to a GDB regnum. */ | |
589 | ||
590 | static int | |
d3f73121 | 591 | m68k_dwarf_reg_to_regnum (struct gdbarch *gdbarch, int num) |
6dd0fba6 NS |
592 | { |
593 | if (num < 8) | |
594 | /* d0..7 */ | |
595 | return (num - 0) + M68K_D0_REGNUM; | |
596 | else if (num < 16) | |
597 | /* a0..7 */ | |
598 | return (num - 8) + M68K_A0_REGNUM; | |
d3f73121 | 599 | else if (num < 24 && gdbarch_tdep (gdbarch)->fpregs_present) |
6dd0fba6 NS |
600 | /* fp0..7 */ |
601 | return (num - 16) + M68K_FP0_REGNUM; | |
602 | else if (num == 25) | |
603 | /* pc */ | |
604 | return M68K_PC_REGNUM; | |
605 | else | |
0fde2c53 | 606 | return -1; |
6dd0fba6 NS |
607 | } |
608 | ||
8de307e0 AS |
609 | \f |
610 | struct m68k_frame_cache | |
611 | { | |
612 | /* Base address. */ | |
613 | CORE_ADDR base; | |
614 | CORE_ADDR sp_offset; | |
615 | CORE_ADDR pc; | |
7f8e7424 | 616 | |
8de307e0 AS |
617 | /* Saved registers. */ |
618 | CORE_ADDR saved_regs[M68K_NUM_REGS]; | |
619 | CORE_ADDR saved_sp; | |
7f8e7424 | 620 | |
8de307e0 AS |
621 | /* Stack space reserved for local variables. */ |
622 | long locals; | |
623 | }; | |
c906108c | 624 | |
8de307e0 AS |
625 | /* Allocate and initialize a frame cache. */ |
626 | ||
627 | static struct m68k_frame_cache * | |
628 | m68k_alloc_frame_cache (void) | |
c906108c | 629 | { |
8de307e0 AS |
630 | struct m68k_frame_cache *cache; |
631 | int i; | |
c906108c | 632 | |
8de307e0 | 633 | cache = FRAME_OBSTACK_ZALLOC (struct m68k_frame_cache); |
c906108c | 634 | |
8de307e0 AS |
635 | /* Base address. */ |
636 | cache->base = 0; | |
637 | cache->sp_offset = -4; | |
638 | cache->pc = 0; | |
c906108c | 639 | |
8de307e0 AS |
640 | /* Saved registers. We initialize these to -1 since zero is a valid |
641 | offset (that's where %fp is supposed to be stored). */ | |
642 | for (i = 0; i < M68K_NUM_REGS; i++) | |
643 | cache->saved_regs[i] = -1; | |
644 | ||
645 | /* Frameless until proven otherwise. */ | |
646 | cache->locals = -1; | |
647 | ||
648 | return cache; | |
c906108c SS |
649 | } |
650 | ||
8de307e0 AS |
651 | /* Check whether PC points at a code that sets up a new stack frame. |
652 | If so, it updates CACHE and returns the address of the first | |
653 | instruction after the sequence that sets removes the "hidden" | |
654 | argument from the stack or CURRENT_PC, whichever is smaller. | |
655 | Otherwise, return PC. */ | |
c906108c | 656 | |
8de307e0 | 657 | static CORE_ADDR |
e17a4113 UW |
658 | m68k_analyze_frame_setup (struct gdbarch *gdbarch, |
659 | CORE_ADDR pc, CORE_ADDR current_pc, | |
8de307e0 | 660 | struct m68k_frame_cache *cache) |
c906108c | 661 | { |
e17a4113 | 662 | enum bfd_endian byte_order = gdbarch_byte_order (gdbarch); |
8de307e0 AS |
663 | int op; |
664 | ||
665 | if (pc >= current_pc) | |
666 | return current_pc; | |
c906108c | 667 | |
e17a4113 | 668 | op = read_memory_unsigned_integer (pc, 2, byte_order); |
8de307e0 AS |
669 | |
670 | if (op == P_LINKW_FP || op == P_LINKL_FP || op == P_PEA_FP) | |
c906108c | 671 | { |
8de307e0 AS |
672 | cache->saved_regs[M68K_FP_REGNUM] = 0; |
673 | cache->sp_offset += 4; | |
674 | if (op == P_LINKW_FP) | |
675 | { | |
676 | /* link.w %fp, #-N */ | |
677 | /* link.w %fp, #0; adda.l #-N, %sp */ | |
e17a4113 | 678 | cache->locals = -read_memory_integer (pc + 2, 2, byte_order); |
8de307e0 AS |
679 | |
680 | if (pc + 4 < current_pc && cache->locals == 0) | |
681 | { | |
e17a4113 | 682 | op = read_memory_unsigned_integer (pc + 4, 2, byte_order); |
8de307e0 AS |
683 | if (op == P_ADDAL_SP) |
684 | { | |
e17a4113 | 685 | cache->locals = read_memory_integer (pc + 6, 4, byte_order); |
8de307e0 AS |
686 | return pc + 10; |
687 | } | |
688 | } | |
689 | ||
690 | return pc + 4; | |
691 | } | |
692 | else if (op == P_LINKL_FP) | |
c906108c | 693 | { |
8de307e0 | 694 | /* link.l %fp, #-N */ |
e17a4113 | 695 | cache->locals = -read_memory_integer (pc + 2, 4, byte_order); |
8de307e0 AS |
696 | return pc + 6; |
697 | } | |
698 | else | |
699 | { | |
700 | /* pea (%fp); movea.l %sp, %fp */ | |
701 | cache->locals = 0; | |
702 | ||
703 | if (pc + 2 < current_pc) | |
704 | { | |
e17a4113 | 705 | op = read_memory_unsigned_integer (pc + 2, 2, byte_order); |
8de307e0 AS |
706 | |
707 | if (op == P_MOVEAL_SP_FP) | |
708 | { | |
709 | /* move.l %sp, %fp */ | |
710 | return pc + 4; | |
711 | } | |
712 | } | |
713 | ||
714 | return pc + 2; | |
c906108c SS |
715 | } |
716 | } | |
8de307e0 | 717 | else if ((op & 0170777) == P_SUBQW_SP || (op & 0170777) == P_SUBQL_SP) |
c906108c | 718 | { |
8de307e0 AS |
719 | /* subq.[wl] #N,%sp */ |
720 | /* subq.[wl] #8,%sp; subq.[wl] #N,%sp */ | |
721 | cache->locals = (op & 07000) == 0 ? 8 : (op & 07000) >> 9; | |
722 | if (pc + 2 < current_pc) | |
c906108c | 723 | { |
e17a4113 | 724 | op = read_memory_unsigned_integer (pc + 2, 2, byte_order); |
8de307e0 AS |
725 | if ((op & 0170777) == P_SUBQW_SP || (op & 0170777) == P_SUBQL_SP) |
726 | { | |
727 | cache->locals += (op & 07000) == 0 ? 8 : (op & 07000) >> 9; | |
728 | return pc + 4; | |
729 | } | |
c906108c | 730 | } |
8de307e0 AS |
731 | return pc + 2; |
732 | } | |
733 | else if (op == P_ADDAW_SP || op == P_LEA_SP_SP) | |
734 | { | |
735 | /* adda.w #-N,%sp */ | |
736 | /* lea (-N,%sp),%sp */ | |
e17a4113 | 737 | cache->locals = -read_memory_integer (pc + 2, 2, byte_order); |
8de307e0 | 738 | return pc + 4; |
c906108c | 739 | } |
8de307e0 | 740 | else if (op == P_ADDAL_SP) |
c906108c | 741 | { |
8de307e0 | 742 | /* adda.l #-N,%sp */ |
e17a4113 | 743 | cache->locals = -read_memory_integer (pc + 2, 4, byte_order); |
8de307e0 | 744 | return pc + 6; |
c906108c | 745 | } |
8de307e0 AS |
746 | |
747 | return pc; | |
c906108c | 748 | } |
c5aa993b | 749 | |
8de307e0 AS |
750 | /* Check whether PC points at code that saves registers on the stack. |
751 | If so, it updates CACHE and returns the address of the first | |
752 | instruction after the register saves or CURRENT_PC, whichever is | |
753 | smaller. Otherwise, return PC. */ | |
c906108c | 754 | |
8de307e0 | 755 | static CORE_ADDR |
be8626e0 MD |
756 | m68k_analyze_register_saves (struct gdbarch *gdbarch, CORE_ADDR pc, |
757 | CORE_ADDR current_pc, | |
8de307e0 AS |
758 | struct m68k_frame_cache *cache) |
759 | { | |
e17a4113 UW |
760 | enum bfd_endian byte_order = gdbarch_byte_order (gdbarch); |
761 | ||
8de307e0 AS |
762 | if (cache->locals >= 0) |
763 | { | |
764 | CORE_ADDR offset; | |
765 | int op; | |
766 | int i, mask, regno; | |
c906108c | 767 | |
8de307e0 AS |
768 | offset = -4 - cache->locals; |
769 | while (pc < current_pc) | |
770 | { | |
e17a4113 | 771 | op = read_memory_unsigned_integer (pc, 2, byte_order); |
8ed86d01 | 772 | if (op == P_FMOVEMX_SP |
be8626e0 | 773 | && gdbarch_tdep (gdbarch)->fpregs_present) |
8de307e0 AS |
774 | { |
775 | /* fmovem.x REGS,-(%sp) */ | |
e17a4113 | 776 | op = read_memory_unsigned_integer (pc + 2, 2, byte_order); |
8de307e0 AS |
777 | if ((op & 0xff00) == 0xe000) |
778 | { | |
779 | mask = op & 0xff; | |
780 | for (i = 0; i < 16; i++, mask >>= 1) | |
781 | { | |
782 | if (mask & 1) | |
783 | { | |
784 | cache->saved_regs[i + M68K_FP0_REGNUM] = offset; | |
785 | offset -= 12; | |
786 | } | |
787 | } | |
788 | pc += 4; | |
789 | } | |
790 | else | |
791 | break; | |
792 | } | |
0ba5a932 | 793 | else if ((op & 0177760) == P_MOVEL_SP) |
8de307e0 AS |
794 | { |
795 | /* move.l %R,-(%sp) */ | |
0ba5a932 | 796 | regno = op & 017; |
8de307e0 AS |
797 | cache->saved_regs[regno] = offset; |
798 | offset -= 4; | |
799 | pc += 2; | |
800 | } | |
801 | else if (op == P_MOVEML_SP) | |
802 | { | |
803 | /* movem.l REGS,-(%sp) */ | |
e17a4113 | 804 | mask = read_memory_unsigned_integer (pc + 2, 2, byte_order); |
8de307e0 AS |
805 | for (i = 0; i < 16; i++, mask >>= 1) |
806 | { | |
807 | if (mask & 1) | |
808 | { | |
809 | cache->saved_regs[15 - i] = offset; | |
810 | offset -= 4; | |
811 | } | |
812 | } | |
813 | pc += 4; | |
814 | } | |
815 | else | |
816 | break; | |
817 | } | |
818 | } | |
819 | ||
820 | return pc; | |
821 | } | |
c906108c | 822 | |
c906108c | 823 | |
8de307e0 AS |
824 | /* Do a full analysis of the prologue at PC and update CACHE |
825 | accordingly. Bail out early if CURRENT_PC is reached. Return the | |
826 | address where the analysis stopped. | |
c906108c | 827 | |
8de307e0 | 828 | We handle all cases that can be generated by gcc. |
c906108c | 829 | |
8de307e0 | 830 | For allocating a stack frame: |
c906108c | 831 | |
8de307e0 AS |
832 | link.w %a6,#-N |
833 | link.l %a6,#-N | |
834 | pea (%fp); move.l %sp,%fp | |
835 | link.w %a6,#0; add.l #-N,%sp | |
836 | subq.l #N,%sp | |
837 | subq.w #N,%sp | |
838 | subq.w #8,%sp; subq.w #N-8,%sp | |
839 | add.w #-N,%sp | |
840 | lea (-N,%sp),%sp | |
841 | add.l #-N,%sp | |
c906108c | 842 | |
8de307e0 | 843 | For saving registers: |
c906108c | 844 | |
8de307e0 AS |
845 | fmovem.x REGS,-(%sp) |
846 | move.l R1,-(%sp) | |
847 | move.l R1,-(%sp); move.l R2,-(%sp) | |
848 | movem.l REGS,-(%sp) | |
c906108c | 849 | |
8de307e0 | 850 | For setting up the PIC register: |
c906108c | 851 | |
8de307e0 | 852 | lea (%pc,N),%a5 |
c906108c | 853 | |
8de307e0 | 854 | */ |
c906108c | 855 | |
eb2e12d7 | 856 | static CORE_ADDR |
be8626e0 MD |
857 | m68k_analyze_prologue (struct gdbarch *gdbarch, CORE_ADDR pc, |
858 | CORE_ADDR current_pc, struct m68k_frame_cache *cache) | |
c906108c | 859 | { |
e17a4113 | 860 | enum bfd_endian byte_order = gdbarch_byte_order (gdbarch); |
8de307e0 | 861 | unsigned int op; |
c906108c | 862 | |
e17a4113 | 863 | pc = m68k_analyze_frame_setup (gdbarch, pc, current_pc, cache); |
be8626e0 | 864 | pc = m68k_analyze_register_saves (gdbarch, pc, current_pc, cache); |
8de307e0 AS |
865 | if (pc >= current_pc) |
866 | return current_pc; | |
c906108c | 867 | |
8de307e0 | 868 | /* Check for GOT setup. */ |
e17a4113 | 869 | op = read_memory_unsigned_integer (pc, 4, byte_order); |
8de307e0 | 870 | if (op == P_LEA_PC_A5) |
c906108c | 871 | { |
8de307e0 | 872 | /* lea (%pc,N),%a5 */ |
e4d8bc08 | 873 | return pc + 8; |
c906108c | 874 | } |
8de307e0 AS |
875 | |
876 | return pc; | |
c906108c SS |
877 | } |
878 | ||
8de307e0 | 879 | /* Return PC of first real instruction. */ |
7f8e7424 | 880 | |
8de307e0 | 881 | static CORE_ADDR |
6093d2eb | 882 | m68k_skip_prologue (struct gdbarch *gdbarch, CORE_ADDR start_pc) |
c906108c | 883 | { |
8de307e0 AS |
884 | struct m68k_frame_cache cache; |
885 | CORE_ADDR pc; | |
c906108c | 886 | |
8de307e0 | 887 | cache.locals = -1; |
be8626e0 | 888 | pc = m68k_analyze_prologue (gdbarch, start_pc, (CORE_ADDR) -1, &cache); |
8de307e0 AS |
889 | if (cache.locals < 0) |
890 | return start_pc; | |
891 | return pc; | |
892 | } | |
c906108c | 893 | |
8de307e0 AS |
894 | static CORE_ADDR |
895 | m68k_unwind_pc (struct gdbarch *gdbarch, struct frame_info *next_frame) | |
896 | { | |
f5cf7aa1 | 897 | gdb_byte buf[8]; |
7f8e7424 | 898 | |
c984b7ff | 899 | frame_unwind_register (next_frame, gdbarch_pc_regnum (gdbarch), buf); |
0dfff4cb | 900 | return extract_typed_address (buf, builtin_type (gdbarch)->builtin_func_ptr); |
8de307e0 AS |
901 | } |
902 | \f | |
903 | /* Normal frames. */ | |
7f8e7424 | 904 | |
8de307e0 | 905 | static struct m68k_frame_cache * |
f36bf22c | 906 | m68k_frame_cache (struct frame_info *this_frame, void **this_cache) |
8de307e0 | 907 | { |
e17a4113 UW |
908 | struct gdbarch *gdbarch = get_frame_arch (this_frame); |
909 | enum bfd_endian byte_order = gdbarch_byte_order (gdbarch); | |
8de307e0 | 910 | struct m68k_frame_cache *cache; |
f5cf7aa1 | 911 | gdb_byte buf[4]; |
8de307e0 AS |
912 | int i; |
913 | ||
914 | if (*this_cache) | |
9a3c8263 | 915 | return (struct m68k_frame_cache *) *this_cache; |
8de307e0 AS |
916 | |
917 | cache = m68k_alloc_frame_cache (); | |
918 | *this_cache = cache; | |
919 | ||
920 | /* In principle, for normal frames, %fp holds the frame pointer, | |
921 | which holds the base address for the current stack frame. | |
922 | However, for functions that don't need it, the frame pointer is | |
923 | optional. For these "frameless" functions the frame pointer is | |
924 | actually the frame pointer of the calling frame. Signal | |
925 | trampolines are just a special case of a "frameless" function. | |
926 | They (usually) share their frame pointer with the frame that was | |
927 | in progress when the signal occurred. */ | |
928 | ||
f36bf22c | 929 | get_frame_register (this_frame, M68K_FP_REGNUM, buf); |
e17a4113 | 930 | cache->base = extract_unsigned_integer (buf, 4, byte_order); |
8de307e0 AS |
931 | if (cache->base == 0) |
932 | return cache; | |
933 | ||
934 | /* For normal frames, %pc is stored at 4(%fp). */ | |
935 | cache->saved_regs[M68K_PC_REGNUM] = 4; | |
936 | ||
f36bf22c | 937 | cache->pc = get_frame_func (this_frame); |
8de307e0 | 938 | if (cache->pc != 0) |
f36bf22c AS |
939 | m68k_analyze_prologue (get_frame_arch (this_frame), cache->pc, |
940 | get_frame_pc (this_frame), cache); | |
8de307e0 AS |
941 | |
942 | if (cache->locals < 0) | |
943 | { | |
944 | /* We didn't find a valid frame, which means that CACHE->base | |
945 | currently holds the frame pointer for our calling frame. If | |
946 | we're at the start of a function, or somewhere half-way its | |
947 | prologue, the function's frame probably hasn't been fully | |
948 | setup yet. Try to reconstruct the base address for the stack | |
949 | frame by looking at the stack pointer. For truly "frameless" | |
950 | functions this might work too. */ | |
951 | ||
f36bf22c | 952 | get_frame_register (this_frame, M68K_SP_REGNUM, buf); |
e17a4113 UW |
953 | cache->base = extract_unsigned_integer (buf, 4, byte_order) |
954 | + cache->sp_offset; | |
8de307e0 | 955 | } |
7f8e7424 | 956 | |
8de307e0 AS |
957 | /* Now that we have the base address for the stack frame we can |
958 | calculate the value of %sp in the calling frame. */ | |
959 | cache->saved_sp = cache->base + 8; | |
7f8e7424 | 960 | |
8de307e0 AS |
961 | /* Adjust all the saved registers such that they contain addresses |
962 | instead of offsets. */ | |
963 | for (i = 0; i < M68K_NUM_REGS; i++) | |
964 | if (cache->saved_regs[i] != -1) | |
965 | cache->saved_regs[i] += cache->base; | |
c906108c | 966 | |
8de307e0 AS |
967 | return cache; |
968 | } | |
c906108c | 969 | |
8de307e0 | 970 | static void |
f36bf22c | 971 | m68k_frame_this_id (struct frame_info *this_frame, void **this_cache, |
8de307e0 AS |
972 | struct frame_id *this_id) |
973 | { | |
f36bf22c | 974 | struct m68k_frame_cache *cache = m68k_frame_cache (this_frame, this_cache); |
c906108c | 975 | |
8de307e0 AS |
976 | /* This marks the outermost frame. */ |
977 | if (cache->base == 0) | |
978 | return; | |
c5aa993b | 979 | |
8de307e0 AS |
980 | /* See the end of m68k_push_dummy_call. */ |
981 | *this_id = frame_id_build (cache->base + 8, cache->pc); | |
982 | } | |
c5aa993b | 983 | |
f36bf22c AS |
984 | static struct value * |
985 | m68k_frame_prev_register (struct frame_info *this_frame, void **this_cache, | |
986 | int regnum) | |
8de307e0 | 987 | { |
f36bf22c | 988 | struct m68k_frame_cache *cache = m68k_frame_cache (this_frame, this_cache); |
8de307e0 AS |
989 | |
990 | gdb_assert (regnum >= 0); | |
991 | ||
992 | if (regnum == M68K_SP_REGNUM && cache->saved_sp) | |
f36bf22c | 993 | return frame_unwind_got_constant (this_frame, regnum, cache->saved_sp); |
8de307e0 AS |
994 | |
995 | if (regnum < M68K_NUM_REGS && cache->saved_regs[regnum] != -1) | |
f36bf22c AS |
996 | return frame_unwind_got_memory (this_frame, regnum, |
997 | cache->saved_regs[regnum]); | |
8de307e0 | 998 | |
f36bf22c | 999 | return frame_unwind_got_register (this_frame, regnum, regnum); |
8de307e0 AS |
1000 | } |
1001 | ||
1002 | static const struct frame_unwind m68k_frame_unwind = | |
1003 | { | |
1004 | NORMAL_FRAME, | |
8fbca658 | 1005 | default_frame_unwind_stop_reason, |
8de307e0 | 1006 | m68k_frame_this_id, |
f36bf22c AS |
1007 | m68k_frame_prev_register, |
1008 | NULL, | |
1009 | default_frame_sniffer | |
8de307e0 | 1010 | }; |
8de307e0 | 1011 | \f |
8de307e0 | 1012 | static CORE_ADDR |
f36bf22c | 1013 | m68k_frame_base_address (struct frame_info *this_frame, void **this_cache) |
8de307e0 | 1014 | { |
f36bf22c | 1015 | struct m68k_frame_cache *cache = m68k_frame_cache (this_frame, this_cache); |
8de307e0 AS |
1016 | |
1017 | return cache->base; | |
1018 | } | |
1019 | ||
1020 | static const struct frame_base m68k_frame_base = | |
1021 | { | |
1022 | &m68k_frame_unwind, | |
1023 | m68k_frame_base_address, | |
1024 | m68k_frame_base_address, | |
1025 | m68k_frame_base_address | |
1026 | }; | |
1027 | ||
1028 | static struct frame_id | |
f36bf22c | 1029 | m68k_dummy_id (struct gdbarch *gdbarch, struct frame_info *this_frame) |
8de307e0 | 1030 | { |
8de307e0 | 1031 | CORE_ADDR fp; |
c906108c | 1032 | |
f36bf22c | 1033 | fp = get_frame_register_unsigned (this_frame, M68K_FP_REGNUM); |
c906108c | 1034 | |
8de307e0 | 1035 | /* See the end of m68k_push_dummy_call. */ |
f36bf22c | 1036 | return frame_id_build (fp + 8, get_frame_pc (this_frame)); |
8de307e0 AS |
1037 | } |
1038 | \f | |
c906108c | 1039 | |
c906108c SS |
1040 | /* Figure out where the longjmp will land. Slurp the args out of the stack. |
1041 | We expect the first arg to be a pointer to the jmp_buf structure from which | |
1042 | we extract the pc (JB_PC) that we will land at. The pc is copied into PC. | |
025bb325 | 1043 | This routine returns true on success. */ |
c906108c | 1044 | |
c34d127c | 1045 | static int |
60ade65d | 1046 | m68k_get_longjmp_target (struct frame_info *frame, CORE_ADDR *pc) |
c906108c | 1047 | { |
f5cf7aa1 | 1048 | gdb_byte *buf; |
c906108c | 1049 | CORE_ADDR sp, jb_addr; |
c984b7ff | 1050 | struct gdbarch *gdbarch = get_frame_arch (frame); |
e17a4113 UW |
1051 | struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); |
1052 | enum bfd_endian byte_order = gdbarch_byte_order (gdbarch); | |
eb2e12d7 AS |
1053 | |
1054 | if (tdep->jb_pc < 0) | |
1055 | { | |
1056 | internal_error (__FILE__, __LINE__, | |
e2e0b3e5 | 1057 | _("m68k_get_longjmp_target: not implemented")); |
eb2e12d7 AS |
1058 | return 0; |
1059 | } | |
c906108c | 1060 | |
224c3ddb | 1061 | buf = (gdb_byte *) alloca (gdbarch_ptr_bit (gdbarch) / TARGET_CHAR_BIT); |
c984b7ff | 1062 | sp = get_frame_register_unsigned (frame, gdbarch_sp_regnum (gdbarch)); |
c906108c | 1063 | |
025bb325 | 1064 | if (target_read_memory (sp + SP_ARG0, /* Offset of first arg on stack. */ |
c984b7ff | 1065 | buf, gdbarch_ptr_bit (gdbarch) / TARGET_CHAR_BIT)) |
c906108c SS |
1066 | return 0; |
1067 | ||
c984b7ff | 1068 | jb_addr = extract_unsigned_integer (buf, gdbarch_ptr_bit (gdbarch) |
e17a4113 | 1069 | / TARGET_CHAR_BIT, byte_order); |
c906108c | 1070 | |
eb2e12d7 | 1071 | if (target_read_memory (jb_addr + tdep->jb_pc * tdep->jb_elt_size, buf, |
e17a4113 UW |
1072 | gdbarch_ptr_bit (gdbarch) / TARGET_CHAR_BIT), |
1073 | byte_order) | |
c906108c SS |
1074 | return 0; |
1075 | ||
c984b7ff | 1076 | *pc = extract_unsigned_integer (buf, gdbarch_ptr_bit (gdbarch) |
e17a4113 | 1077 | / TARGET_CHAR_BIT, byte_order); |
c906108c SS |
1078 | return 1; |
1079 | } | |
f595cb19 MK |
1080 | \f |
1081 | ||
18648a37 YQ |
1082 | /* This is the implementation of gdbarch method |
1083 | return_in_first_hidden_param_p. */ | |
1084 | ||
1085 | static int | |
1086 | m68k_return_in_first_hidden_param_p (struct gdbarch *gdbarch, | |
1087 | struct type *type) | |
1088 | { | |
1089 | return 0; | |
1090 | } | |
1091 | ||
f595cb19 MK |
1092 | /* System V Release 4 (SVR4). */ |
1093 | ||
1094 | void | |
1095 | m68k_svr4_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch) | |
1096 | { | |
1097 | struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); | |
1098 | ||
1099 | /* SVR4 uses a different calling convention. */ | |
1100 | set_gdbarch_return_value (gdbarch, m68k_svr4_return_value); | |
1101 | ||
1102 | /* SVR4 uses %a0 instead of %a1. */ | |
1103 | tdep->struct_value_regnum = M68K_A0_REGNUM; | |
3eba3a01 TT |
1104 | |
1105 | /* SVR4 returns pointers in %a0. */ | |
1106 | tdep->pointer_result_regnum = M68K_A0_REGNUM; | |
1107 | } | |
1108 | ||
1109 | /* GCC's m68k "embedded" ABI. This is like the SVR4 ABI, but pointer | |
1110 | values are returned in %d0, not %a0. */ | |
1111 | ||
1112 | static void | |
1113 | m68k_embedded_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch) | |
1114 | { | |
1115 | struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); | |
1116 | ||
1117 | m68k_svr4_init_abi (info, gdbarch); | |
1118 | tdep->pointer_result_regnum = M68K_D0_REGNUM; | |
f595cb19 | 1119 | } |
3eba3a01 | 1120 | |
f595cb19 | 1121 | \f |
c906108c | 1122 | |
152d9db6 GS |
1123 | /* Function: m68k_gdbarch_init |
1124 | Initializer function for the m68k gdbarch vector. | |
025bb325 | 1125 | Called by gdbarch. Sets up the gdbarch vector(s) for this target. */ |
152d9db6 GS |
1126 | |
1127 | static struct gdbarch * | |
1128 | m68k_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) | |
1129 | { | |
1130 | struct gdbarch_tdep *tdep = NULL; | |
1131 | struct gdbarch *gdbarch; | |
8ed86d01 | 1132 | struct gdbarch_list *best_arch; |
c1e1314d | 1133 | tdesc_arch_data_up tdesc_data; |
8ed86d01 VP |
1134 | int i; |
1135 | enum m68k_flavour flavour = m68k_no_flavour; | |
1136 | int has_fp = 1; | |
1137 | const struct floatformat **long_double_format = floatformats_m68881_ext; | |
1138 | ||
1139 | /* Check any target description for validity. */ | |
1140 | if (tdesc_has_registers (info.target_desc)) | |
1141 | { | |
1142 | const struct tdesc_feature *feature; | |
1143 | int valid_p; | |
152d9db6 | 1144 | |
8ed86d01 VP |
1145 | feature = tdesc_find_feature (info.target_desc, |
1146 | "org.gnu.gdb.m68k.core"); | |
8ed86d01 VP |
1147 | |
1148 | if (feature == NULL) | |
1149 | { | |
1150 | feature = tdesc_find_feature (info.target_desc, | |
1151 | "org.gnu.gdb.coldfire.core"); | |
1152 | if (feature != NULL) | |
1153 | flavour = m68k_coldfire_flavour; | |
1154 | } | |
1155 | ||
1156 | if (feature == NULL) | |
1157 | { | |
1158 | feature = tdesc_find_feature (info.target_desc, | |
1159 | "org.gnu.gdb.fido.core"); | |
1160 | if (feature != NULL) | |
1161 | flavour = m68k_fido_flavour; | |
1162 | } | |
1163 | ||
1164 | if (feature == NULL) | |
1165 | return NULL; | |
1166 | ||
1167 | tdesc_data = tdesc_data_alloc (); | |
1168 | ||
1169 | valid_p = 1; | |
1170 | for (i = 0; i <= M68K_PC_REGNUM; i++) | |
c1e1314d | 1171 | valid_p &= tdesc_numbered_register (feature, tdesc_data.get (), i, |
8ed86d01 VP |
1172 | m68k_register_names[i]); |
1173 | ||
1174 | if (!valid_p) | |
c1e1314d | 1175 | return NULL; |
8ed86d01 VP |
1176 | |
1177 | feature = tdesc_find_feature (info.target_desc, | |
1178 | "org.gnu.gdb.coldfire.fp"); | |
1179 | if (feature != NULL) | |
1180 | { | |
1181 | valid_p = 1; | |
1182 | for (i = M68K_FP0_REGNUM; i <= M68K_FPI_REGNUM; i++) | |
c1e1314d | 1183 | valid_p &= tdesc_numbered_register (feature, tdesc_data.get (), i, |
8ed86d01 VP |
1184 | m68k_register_names[i]); |
1185 | if (!valid_p) | |
c1e1314d | 1186 | return NULL; |
8ed86d01 VP |
1187 | } |
1188 | else | |
1189 | has_fp = 0; | |
1190 | } | |
1191 | ||
1192 | /* The mechanism for returning floating values from function | |
1193 | and the type of long double depend on whether we're | |
025bb325 | 1194 | on ColdFire or standard m68k. */ |
8ed86d01 | 1195 | |
4ed77933 | 1196 | if (info.bfd_arch_info && info.bfd_arch_info->mach != 0) |
8ed86d01 VP |
1197 | { |
1198 | const bfd_arch_info_type *coldfire_arch = | |
1199 | bfd_lookup_arch (bfd_arch_m68k, bfd_mach_mcf_isa_a_nodiv); | |
1200 | ||
1201 | if (coldfire_arch | |
4ed77933 AS |
1202 | && ((*info.bfd_arch_info->compatible) |
1203 | (info.bfd_arch_info, coldfire_arch))) | |
8ed86d01 VP |
1204 | flavour = m68k_coldfire_flavour; |
1205 | } | |
1206 | ||
3eba3a01 TT |
1207 | /* Try to figure out if the arch uses floating registers to return |
1208 | floating point values from functions. On ColdFire, floating | |
1209 | point values are returned in D0. */ | |
1210 | int float_return = 0; | |
1211 | if (has_fp && flavour != m68k_coldfire_flavour) | |
1212 | float_return = 1; | |
1213 | #ifdef HAVE_ELF | |
1214 | if (info.abfd && bfd_get_flavour (info.abfd) == bfd_target_elf_flavour) | |
1215 | { | |
1216 | int fp_abi = bfd_elf_get_obj_attr_int (info.abfd, OBJ_ATTR_GNU, | |
1217 | Tag_GNU_M68K_ABI_FP); | |
1218 | if (fp_abi == 1) | |
1219 | float_return = 1; | |
1220 | else if (fp_abi == 2) | |
1221 | float_return = 0; | |
1222 | } | |
1223 | #endif /* HAVE_ELF */ | |
1224 | ||
8ed86d01 VP |
1225 | /* If there is already a candidate, use it. */ |
1226 | for (best_arch = gdbarch_list_lookup_by_info (arches, &info); | |
1227 | best_arch != NULL; | |
1228 | best_arch = gdbarch_list_lookup_by_info (best_arch->next, &info)) | |
1229 | { | |
1230 | if (flavour != gdbarch_tdep (best_arch->gdbarch)->flavour) | |
1231 | continue; | |
1232 | ||
1233 | if (has_fp != gdbarch_tdep (best_arch->gdbarch)->fpregs_present) | |
1234 | continue; | |
1235 | ||
3eba3a01 TT |
1236 | if (float_return != gdbarch_tdep (best_arch->gdbarch)->float_return) |
1237 | continue; | |
1238 | ||
8ed86d01 VP |
1239 | break; |
1240 | } | |
152d9db6 | 1241 | |
0c85e18e | 1242 | if (best_arch != NULL) |
c1e1314d | 1243 | return best_arch->gdbarch; |
0c85e18e | 1244 | |
8d749320 | 1245 | tdep = XCNEW (struct gdbarch_tdep); |
eb2e12d7 | 1246 | gdbarch = gdbarch_alloc (&info, tdep); |
8ed86d01 | 1247 | tdep->fpregs_present = has_fp; |
3eba3a01 | 1248 | tdep->float_return = float_return; |
8ed86d01 | 1249 | tdep->flavour = flavour; |
152d9db6 | 1250 | |
8ed86d01 VP |
1251 | if (flavour == m68k_coldfire_flavour || flavour == m68k_fido_flavour) |
1252 | long_double_format = floatformats_ieee_double; | |
1253 | set_gdbarch_long_double_format (gdbarch, long_double_format); | |
1254 | set_gdbarch_long_double_bit (gdbarch, long_double_format[0]->totalsize); | |
5d3ed2e3 | 1255 | |
5d3ed2e3 | 1256 | set_gdbarch_skip_prologue (gdbarch, m68k_skip_prologue); |
04180708 YQ |
1257 | set_gdbarch_breakpoint_kind_from_pc (gdbarch, m68k_breakpoint::kind_from_pc); |
1258 | set_gdbarch_sw_breakpoint_from_kind (gdbarch, m68k_breakpoint::bp_from_kind); | |
5d3ed2e3 | 1259 | |
025bb325 | 1260 | /* Stack grows down. */ |
5d3ed2e3 | 1261 | set_gdbarch_inner_than (gdbarch, core_addr_lessthan); |
9bb47d95 | 1262 | set_gdbarch_frame_align (gdbarch, m68k_frame_align); |
6300c360 GS |
1263 | |
1264 | set_gdbarch_believe_pcc_promotion (gdbarch, 1); | |
8ed86d01 VP |
1265 | if (flavour == m68k_coldfire_flavour || flavour == m68k_fido_flavour) |
1266 | set_gdbarch_decr_pc_after_break (gdbarch, 2); | |
942dc0e9 | 1267 | |
6300c360 | 1268 | set_gdbarch_frame_args_skip (gdbarch, 8); |
6dd0fba6 | 1269 | set_gdbarch_dwarf2_reg_to_regnum (gdbarch, m68k_dwarf_reg_to_regnum); |
942dc0e9 | 1270 | |
8de307e0 | 1271 | set_gdbarch_register_type (gdbarch, m68k_register_type); |
5d3ed2e3 | 1272 | set_gdbarch_register_name (gdbarch, m68k_register_name); |
6dd0fba6 | 1273 | set_gdbarch_num_regs (gdbarch, M68K_NUM_REGS); |
32eeb91a | 1274 | set_gdbarch_sp_regnum (gdbarch, M68K_SP_REGNUM); |
32eeb91a AS |
1275 | set_gdbarch_pc_regnum (gdbarch, M68K_PC_REGNUM); |
1276 | set_gdbarch_ps_regnum (gdbarch, M68K_PS_REGNUM); | |
e47577ab MK |
1277 | set_gdbarch_convert_register_p (gdbarch, m68k_convert_register_p); |
1278 | set_gdbarch_register_to_value (gdbarch, m68k_register_to_value); | |
1279 | set_gdbarch_value_to_register (gdbarch, m68k_value_to_register); | |
a2c6a6d5 | 1280 | |
8ed86d01 VP |
1281 | if (has_fp) |
1282 | set_gdbarch_fp0_regnum (gdbarch, M68K_FP0_REGNUM); | |
1283 | ||
025bb325 | 1284 | /* Function call & return. */ |
8de307e0 | 1285 | set_gdbarch_push_dummy_call (gdbarch, m68k_push_dummy_call); |
f595cb19 | 1286 | set_gdbarch_return_value (gdbarch, m68k_return_value); |
18648a37 YQ |
1287 | set_gdbarch_return_in_first_hidden_param_p (gdbarch, |
1288 | m68k_return_in_first_hidden_param_p); | |
6c0e89ed | 1289 | |
eb2e12d7 AS |
1290 | #if defined JB_PC && defined JB_ELEMENT_SIZE |
1291 | tdep->jb_pc = JB_PC; | |
1292 | tdep->jb_elt_size = JB_ELEMENT_SIZE; | |
1293 | #else | |
1294 | tdep->jb_pc = -1; | |
1295 | #endif | |
3eba3a01 | 1296 | tdep->pointer_result_regnum = M68K_D0_REGNUM; |
f595cb19 | 1297 | tdep->struct_value_regnum = M68K_A1_REGNUM; |
66894781 | 1298 | tdep->struct_return = reg_struct_return; |
8de307e0 AS |
1299 | |
1300 | /* Frame unwinder. */ | |
f36bf22c | 1301 | set_gdbarch_dummy_id (gdbarch, m68k_dummy_id); |
8de307e0 | 1302 | set_gdbarch_unwind_pc (gdbarch, m68k_unwind_pc); |
3f244638 AS |
1303 | |
1304 | /* Hook in the DWARF CFI frame unwinder. */ | |
f36bf22c | 1305 | dwarf2_append_unwinders (gdbarch); |
3f244638 | 1306 | |
8de307e0 | 1307 | frame_base_set_default (gdbarch, &m68k_frame_base); |
eb2e12d7 | 1308 | |
55809acb AS |
1309 | /* Hook in ABI-specific overrides, if they have been registered. */ |
1310 | gdbarch_init_osabi (info, gdbarch); | |
1311 | ||
eb2e12d7 AS |
1312 | /* Now we have tuned the configuration, set a few final things, |
1313 | based on what the OS ABI has told us. */ | |
1314 | ||
1315 | if (tdep->jb_pc >= 0) | |
1316 | set_gdbarch_get_longjmp_target (gdbarch, m68k_get_longjmp_target); | |
1317 | ||
f36bf22c | 1318 | frame_unwind_append_unwinder (gdbarch, &m68k_frame_unwind); |
8de307e0 | 1319 | |
c1e1314d TT |
1320 | if (tdesc_data != nullptr) |
1321 | tdesc_use_registers (gdbarch, info.target_desc, std::move (tdesc_data)); | |
8ed86d01 | 1322 | |
152d9db6 GS |
1323 | return gdbarch; |
1324 | } | |
1325 | ||
1326 | ||
1327 | static void | |
c984b7ff | 1328 | m68k_dump_tdep (struct gdbarch *gdbarch, struct ui_file *file) |
152d9db6 | 1329 | { |
c984b7ff | 1330 | struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); |
152d9db6 | 1331 | |
eb2e12d7 AS |
1332 | if (tdep == NULL) |
1333 | return; | |
152d9db6 | 1334 | } |
2acceee2 | 1335 | |
3eba3a01 TT |
1336 | /* OSABI sniffer for m68k. */ |
1337 | ||
1338 | static enum gdb_osabi | |
1339 | m68k_osabi_sniffer (bfd *abfd) | |
1340 | { | |
1341 | unsigned int elfosabi = elf_elfheader (abfd)->e_ident[EI_OSABI]; | |
1342 | ||
1343 | if (elfosabi == ELFOSABI_NONE) | |
1344 | return GDB_OSABI_SVR4; | |
1345 | ||
1346 | return GDB_OSABI_UNKNOWN; | |
1347 | } | |
1348 | ||
6c265988 | 1349 | void _initialize_m68k_tdep (); |
c906108c | 1350 | void |
6c265988 | 1351 | _initialize_m68k_tdep () |
c906108c | 1352 | { |
152d9db6 | 1353 | gdbarch_register (bfd_arch_m68k, m68k_gdbarch_init, m68k_dump_tdep); |
3eba3a01 TT |
1354 | |
1355 | gdbarch_register_osabi_sniffer (bfd_arch_m68k, bfd_target_elf_flavour, | |
1356 | m68k_osabi_sniffer); | |
1357 | gdbarch_register_osabi (bfd_arch_m68k, 0, GDB_OSABI_SVR4, | |
1358 | m68k_embedded_init_abi); | |
c906108c | 1359 | } |