Automatic date update in version.in
[binutils-gdb.git] / gdb / m68k-tdep.c
blob568bde66f931757c969787663ce3d3d4f1e89d99
1 /* Target-dependent code for the Motorola 68000 series.
3 Copyright (C) 1990-2022 Free Software Foundation, Inc.
5 This file is part of GDB.
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
9 the Free Software Foundation; either version 3 of the License, or
10 (at your option) any later version.
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.
17 You should have received a copy of the GNU General Public License
18 along with this program. If not, see <http://www.gnu.org/licenses/>. */
20 #include "defs.h"
21 #include "dwarf2/frame.h"
22 #include "frame.h"
23 #include "frame-base.h"
24 #include "frame-unwind.h"
25 #include "gdbtypes.h"
26 #include "symtab.h"
27 #include "gdbcore.h"
28 #include "value.h"
29 #include "inferior.h"
30 #include "regcache.h"
31 #include "arch-utils.h"
32 #include "osabi.h"
33 #include "dis-asm.h"
34 #include "target-descriptions.h"
35 #include "floatformat.h"
36 #include "target-float.h"
37 #include "elf-bfd.h"
38 #include "elf/m68k.h"
40 #include "m68k-tdep.h"
43 #define P_LINKL_FP 0x480e
44 #define P_LINKW_FP 0x4e56
45 #define P_PEA_FP 0x4856
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
57 /* Offset from SP to first arg on stack at first instruction of a function. */
58 #define SP_ARG0 (1 * 4)
60 #if !defined (BPT_VECTOR)
61 #define BPT_VECTOR 0xf
62 #endif
64 constexpr gdb_byte m68k_break_insn[] = {0x4e, (0x40 | BPT_VECTOR)};
66 typedef BP_MANIPULATION (m68k_break_insn) m68k_breakpoint;
69 /* Construct types for ISA-specific registers. */
70 static struct type *
71 m68k_ps_type (struct gdbarch *gdbarch)
73 m68k_gdbarch_tdep *tdep = (m68k_gdbarch_tdep *) gdbarch_tdep (gdbarch);
75 if (!tdep->m68k_ps_type)
77 struct type *type;
79 type = arch_flags_type (gdbarch, "builtin_type_m68k_ps", 32);
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");
93 tdep->m68k_ps_type = type;
96 return tdep->m68k_ps_type;
99 static struct type *
100 m68881_ext_type (struct gdbarch *gdbarch)
102 m68k_gdbarch_tdep *tdep = (m68k_gdbarch_tdep *) gdbarch_tdep (gdbarch);
104 if (!tdep->m68881_ext_type)
105 tdep->m68881_ext_type
106 = arch_float_type (gdbarch, -1, "builtin_type_m68881_ext",
107 floatformats_m68881_ext);
109 return tdep->m68881_ext_type;
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. */
120 static struct type *
121 m68k_register_type (struct gdbarch *gdbarch, int regnum)
123 m68k_gdbarch_tdep *tdep = (m68k_gdbarch_tdep *) gdbarch_tdep (gdbarch);
125 if (tdep->fpregs_present)
127 if (regnum >= gdbarch_fp0_regnum (gdbarch)
128 && regnum <= gdbarch_fp0_regnum (gdbarch) + 7)
130 if (tdep->flavour == m68k_coldfire_flavour)
131 return builtin_type (gdbarch)->builtin_double;
132 else
133 return m68881_ext_type (gdbarch);
136 if (regnum == M68K_FPI_REGNUM)
137 return builtin_type (gdbarch)->builtin_func_ptr;
139 if (regnum == M68K_FPC_REGNUM || regnum == M68K_FPS_REGNUM)
140 return builtin_type (gdbarch)->builtin_int32;
142 else
144 if (regnum >= M68K_FP0_REGNUM && regnum <= M68K_FPI_REGNUM)
145 return builtin_type (gdbarch)->builtin_int0;
148 if (regnum == gdbarch_pc_regnum (gdbarch))
149 return builtin_type (gdbarch)->builtin_func_ptr;
151 if (regnum >= M68K_A0_REGNUM && regnum <= M68K_A0_REGNUM + 7)
152 return builtin_type (gdbarch)->builtin_data_ptr;
154 if (regnum == M68K_PS_REGNUM)
155 return m68k_ps_type (gdbarch);
157 return builtin_type (gdbarch)->builtin_int32;
160 static const char * const m68k_register_names[] = {
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",
165 "fpcontrol", "fpstatus", "fpiaddr"
168 /* Function: m68k_register_name
169 Returns the name of the standard m68k register regnum. */
171 static const char *
172 m68k_register_name (struct gdbarch *gdbarch, int regnum)
174 m68k_gdbarch_tdep *tdep = (m68k_gdbarch_tdep *) gdbarch_tdep (gdbarch);
176 if (regnum < 0 || regnum >= ARRAY_SIZE (m68k_register_names))
177 internal_error (__FILE__, __LINE__,
178 _("m68k_register_name: illegal register number %d"),
179 regnum);
180 else if (regnum >= M68K_FP0_REGNUM && regnum <= M68K_FPI_REGNUM
181 && tdep->fpregs_present == 0)
182 return "";
183 else
184 return m68k_register_names[regnum];
187 /* Return nonzero if a value of type TYPE stored in register REGNUM
188 needs any special handling. */
190 static int
191 m68k_convert_register_p (struct gdbarch *gdbarch,
192 int regnum, struct type *type)
194 m68k_gdbarch_tdep *tdep = (m68k_gdbarch_tdep *) gdbarch_tdep (gdbarch);
196 if (!tdep->fpregs_present)
197 return 0;
198 return (regnum >= M68K_FP0_REGNUM && regnum <= M68K_FP0_REGNUM + 7
199 /* We only support floating-point values. */
200 && type->code () == TYPE_CODE_FLT
201 && type != register_type (gdbarch, M68K_FP0_REGNUM));
204 /* Read a value of type TYPE from register REGNUM in frame FRAME, and
205 return its contents in TO. */
207 static int
208 m68k_register_to_value (struct frame_info *frame, int regnum,
209 struct type *type, gdb_byte *to,
210 int *optimizedp, int *unavailablep)
212 struct gdbarch *gdbarch = get_frame_arch (frame);
213 gdb_byte from[M68K_MAX_REGISTER_SIZE];
214 struct type *fpreg_type = register_type (gdbarch, M68K_FP0_REGNUM);
216 gdb_assert (type->code () == TYPE_CODE_FLT);
218 /* Convert to TYPE. */
219 if (!get_frame_register_bytes (frame, regnum, 0,
220 gdb::make_array_view (from,
221 register_size (gdbarch,
222 regnum)),
223 optimizedp, unavailablep))
224 return 0;
226 target_float_convert (from, fpreg_type, to, type);
227 *optimizedp = *unavailablep = 0;
228 return 1;
231 /* Write the contents FROM of a value of type TYPE into register
232 REGNUM in frame FRAME. */
234 static void
235 m68k_value_to_register (struct frame_info *frame, int regnum,
236 struct type *type, const gdb_byte *from)
238 gdb_byte to[M68K_MAX_REGISTER_SIZE];
239 struct type *fpreg_type = register_type (get_frame_arch (frame),
240 M68K_FP0_REGNUM);
242 /* We only support floating-point values. */
243 if (type->code () != TYPE_CODE_FLT)
245 warning (_("Cannot convert non-floating-point type "
246 "to floating-point register value."));
247 return;
250 /* Convert from TYPE. */
251 target_float_convert (from, type, to, fpreg_type);
252 put_frame_register (frame, regnum, to);
256 /* There is a fair number of calling conventions that are in somewhat
257 wide use. The 68000/08/10 don't support an FPU, not even as a
258 coprocessor. All function return values are stored in %d0/%d1.
259 Structures are returned in a static buffer, a pointer to which is
260 returned in %d0. This means that functions returning a structure
261 are not re-entrant. To avoid this problem some systems use a
262 convention where the caller passes a pointer to a buffer in %a1
263 where the return values is to be stored. This convention is the
264 default, and is implemented in the function m68k_return_value.
266 The 68020/030/040/060 do support an FPU, either as a coprocessor
267 (68881/2) or built-in (68040/68060). That's why System V release 4
268 (SVR4) introduces a new calling convention specified by the SVR4
269 psABI. Integer values are returned in %d0/%d1, pointer return
270 values in %a0 and floating values in %fp0. When calling functions
271 returning a structure the caller should pass a pointer to a buffer
272 for the return value in %a0. This convention is implemented in the
273 function m68k_svr4_return_value, and by appropriately setting the
274 struct_value_regnum member of `struct gdbarch_tdep'.
276 GNU/Linux returns values in the same way as SVR4 does, but uses %a1
277 for passing the structure return value buffer.
279 GCC can also generate code where small structures are returned in
280 %d0/%d1 instead of in memory by using -freg-struct-return. This is
281 the default on NetBSD a.out, OpenBSD and GNU/Linux and several
282 embedded systems. This convention is implemented by setting the
283 struct_return member of `struct gdbarch_tdep' to reg_struct_return.
285 GCC also has an "embedded" ABI. This works like the SVR4 ABI,
286 except that pointers are returned in %D0. This is implemented by
287 setting the pointer_result_regnum member of `struct gdbarch_tdep'
288 as appropriate. */
290 /* Read a function return value of TYPE from REGCACHE, and copy that
291 into VALBUF. */
293 static void
294 m68k_extract_return_value (struct type *type, struct regcache *regcache,
295 gdb_byte *valbuf)
297 int len = TYPE_LENGTH (type);
298 gdb_byte buf[M68K_MAX_REGISTER_SIZE];
300 if (type->code () == TYPE_CODE_PTR && len == 4)
302 struct gdbarch *gdbarch = regcache->arch ();
303 m68k_gdbarch_tdep *tdep = (m68k_gdbarch_tdep *) gdbarch_tdep (gdbarch);
304 regcache->raw_read (tdep->pointer_result_regnum, valbuf);
306 else if (len <= 4)
308 regcache->raw_read (M68K_D0_REGNUM, buf);
309 memcpy (valbuf, buf + (4 - len), len);
311 else if (len <= 8)
313 regcache->raw_read (M68K_D0_REGNUM, buf);
314 memcpy (valbuf, buf + (8 - len), len - 4);
315 regcache->raw_read (M68K_D1_REGNUM, valbuf + (len - 4));
317 else
318 internal_error (__FILE__, __LINE__,
319 _("Cannot extract return value of %d bytes long."), len);
322 static void
323 m68k_svr4_extract_return_value (struct type *type, struct regcache *regcache,
324 gdb_byte *valbuf)
326 gdb_byte buf[M68K_MAX_REGISTER_SIZE];
327 struct gdbarch *gdbarch = regcache->arch ();
328 m68k_gdbarch_tdep *tdep = (m68k_gdbarch_tdep *) gdbarch_tdep (gdbarch);
330 if (tdep->float_return && type->code () == TYPE_CODE_FLT)
332 struct type *fpreg_type = register_type (gdbarch, M68K_FP0_REGNUM);
333 regcache->raw_read (M68K_FP0_REGNUM, buf);
334 target_float_convert (buf, fpreg_type, valbuf, type);
336 else
337 m68k_extract_return_value (type, regcache, valbuf);
340 /* Write a function return value of TYPE from VALBUF into REGCACHE. */
342 static void
343 m68k_store_return_value (struct type *type, struct regcache *regcache,
344 const gdb_byte *valbuf)
346 int len = TYPE_LENGTH (type);
348 if (type->code () == TYPE_CODE_PTR && len == 4)
350 struct gdbarch *gdbarch = regcache->arch ();
351 m68k_gdbarch_tdep *tdep = (m68k_gdbarch_tdep *) gdbarch_tdep (gdbarch);
352 regcache->raw_write (tdep->pointer_result_regnum, valbuf);
353 /* gdb historically also set D0 in the SVR4 case. */
354 if (tdep->pointer_result_regnum != M68K_D0_REGNUM)
355 regcache->raw_write (M68K_D0_REGNUM, valbuf);
357 else if (len <= 4)
358 regcache->raw_write_part (M68K_D0_REGNUM, 4 - len, len, valbuf);
359 else if (len <= 8)
361 regcache->raw_write_part (M68K_D0_REGNUM, 8 - len, len - 4, valbuf);
362 regcache->raw_write (M68K_D1_REGNUM, valbuf + (len - 4));
364 else
365 internal_error (__FILE__, __LINE__,
366 _("Cannot store return value of %d bytes long."), len);
369 static void
370 m68k_svr4_store_return_value (struct type *type, struct regcache *regcache,
371 const gdb_byte *valbuf)
373 struct gdbarch *gdbarch = regcache->arch ();
374 m68k_gdbarch_tdep *tdep = (m68k_gdbarch_tdep *) gdbarch_tdep (gdbarch);
376 if (tdep->float_return && type->code () == TYPE_CODE_FLT)
378 struct type *fpreg_type = register_type (gdbarch, M68K_FP0_REGNUM);
379 gdb_byte buf[M68K_MAX_REGISTER_SIZE];
380 target_float_convert (valbuf, type, buf, fpreg_type);
381 regcache->raw_write (M68K_FP0_REGNUM, buf);
383 else
384 m68k_store_return_value (type, regcache, valbuf);
387 /* Return non-zero if TYPE, which is assumed to be a structure, union or
388 complex type, should be returned in registers for architecture
389 GDBARCH. */
391 static int
392 m68k_reg_struct_return_p (struct gdbarch *gdbarch, struct type *type)
394 m68k_gdbarch_tdep *tdep = (m68k_gdbarch_tdep *) gdbarch_tdep (gdbarch);
395 enum type_code code = type->code ();
396 int len = TYPE_LENGTH (type);
398 gdb_assert (code == TYPE_CODE_STRUCT || code == TYPE_CODE_UNION
399 || code == TYPE_CODE_COMPLEX || code == TYPE_CODE_ARRAY);
401 if (tdep->struct_return == pcc_struct_return)
402 return 0;
404 const bool is_vector = code == TYPE_CODE_ARRAY && type->is_vector ();
406 if (is_vector
407 && check_typedef (TYPE_TARGET_TYPE (type))->code () == TYPE_CODE_FLT)
408 return 0;
410 /* According to m68k_return_in_memory in the m68k GCC back-end,
411 strange things happen for small aggregate types. Aggregate types
412 with only one component are always returned like the type of the
413 component. Aggregate types whose size is 2, 4, or 8 are returned
414 in registers if their natural alignment is at least 16 bits.
416 We reject vectors here, as experimentally this gives the correct
417 answer. */
418 if (!is_vector && (len == 2 || len == 4 || len == 8))
419 return type_align (type) >= 2;
421 return (len == 1 || len == 2 || len == 4 || len == 8);
424 /* Determine, for architecture GDBARCH, how a return value of TYPE
425 should be returned. If it is supposed to be returned in registers,
426 and READBUF is non-zero, read the appropriate value from REGCACHE,
427 and copy it into READBUF. If WRITEBUF is non-zero, write the value
428 from WRITEBUF into REGCACHE. */
430 static enum return_value_convention
431 m68k_return_value (struct gdbarch *gdbarch, struct value *function,
432 struct type *type, struct regcache *regcache,
433 gdb_byte *readbuf, const gdb_byte *writebuf)
435 enum type_code code = type->code ();
437 /* GCC returns a `long double' in memory too. */
438 if (((code == TYPE_CODE_STRUCT || code == TYPE_CODE_UNION
439 || code == TYPE_CODE_COMPLEX || code == TYPE_CODE_ARRAY)
440 && !m68k_reg_struct_return_p (gdbarch, type))
441 || (code == TYPE_CODE_FLT && TYPE_LENGTH (type) == 12))
443 /* The default on m68k is to return structures in static memory.
444 Consequently a function must return the address where we can
445 find the return value. */
447 if (readbuf)
449 ULONGEST addr;
451 regcache_raw_read_unsigned (regcache, M68K_D0_REGNUM, &addr);
452 read_memory (addr, readbuf, TYPE_LENGTH (type));
455 return RETURN_VALUE_ABI_RETURNS_ADDRESS;
458 if (readbuf)
459 m68k_extract_return_value (type, regcache, readbuf);
460 if (writebuf)
461 m68k_store_return_value (type, regcache, writebuf);
463 return RETURN_VALUE_REGISTER_CONVENTION;
466 static enum return_value_convention
467 m68k_svr4_return_value (struct gdbarch *gdbarch, struct value *function,
468 struct type *type, struct regcache *regcache,
469 gdb_byte *readbuf, const gdb_byte *writebuf)
471 enum type_code code = type->code ();
472 m68k_gdbarch_tdep *tdep = (m68k_gdbarch_tdep *) gdbarch_tdep (gdbarch);
474 /* Aggregates with a single member are always returned like their
475 sole element. */
476 if ((code == TYPE_CODE_STRUCT || code == TYPE_CODE_UNION)
477 && type->num_fields () == 1)
479 type = check_typedef (type->field (0).type ());
480 return m68k_svr4_return_value (gdbarch, function, type, regcache,
481 readbuf, writebuf);
484 if (((code == TYPE_CODE_STRUCT || code == TYPE_CODE_UNION
485 || code == TYPE_CODE_COMPLEX || code == TYPE_CODE_ARRAY)
486 && !m68k_reg_struct_return_p (gdbarch, type))
487 /* GCC may return a `long double' in memory too. */
488 || (!tdep->float_return
489 && code == TYPE_CODE_FLT
490 && TYPE_LENGTH (type) == 12))
492 /* The System V ABI says that:
494 "A function returning a structure or union also sets %a0 to
495 the value it finds in %a0. Thus when the caller receives
496 control again, the address of the returned object resides in
497 register %a0."
499 So the ABI guarantees that we can always find the return
500 value just after the function has returned.
502 However, GCC also implements the "embedded" ABI. That ABI
503 does not preserve %a0 across calls, but does write the value
504 back to %d0. */
506 if (readbuf)
508 ULONGEST addr;
510 regcache_raw_read_unsigned (regcache, tdep->pointer_result_regnum,
511 &addr);
512 read_memory (addr, readbuf, TYPE_LENGTH (type));
515 return RETURN_VALUE_ABI_RETURNS_ADDRESS;
518 if (readbuf)
519 m68k_svr4_extract_return_value (type, regcache, readbuf);
520 if (writebuf)
521 m68k_svr4_store_return_value (type, regcache, writebuf);
523 return RETURN_VALUE_REGISTER_CONVENTION;
527 /* Always align the frame to a 4-byte boundary. This is required on
528 coldfire and harmless on the rest. */
530 static CORE_ADDR
531 m68k_frame_align (struct gdbarch *gdbarch, CORE_ADDR sp)
533 /* Align the stack to four bytes. */
534 return sp & ~3;
537 static CORE_ADDR
538 m68k_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
539 struct regcache *regcache, CORE_ADDR bp_addr, int nargs,
540 struct value **args, CORE_ADDR sp,
541 function_call_return_method return_method,
542 CORE_ADDR struct_addr)
544 m68k_gdbarch_tdep *tdep = (m68k_gdbarch_tdep *) gdbarch_tdep (gdbarch);
545 enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
546 gdb_byte buf[4];
547 int i;
549 /* Push arguments in reverse order. */
550 for (i = nargs - 1; i >= 0; i--)
552 struct type *value_type = value_enclosing_type (args[i]);
553 int len = TYPE_LENGTH (value_type);
554 int container_len = (len + 3) & ~3;
555 int offset;
557 /* Non-scalars bigger than 4 bytes are left aligned, others are
558 right aligned. */
559 if ((value_type->code () == TYPE_CODE_STRUCT
560 || value_type->code () == TYPE_CODE_UNION
561 || value_type->code () == TYPE_CODE_ARRAY)
562 && len > 4)
563 offset = 0;
564 else
565 offset = container_len - len;
566 sp -= container_len;
567 write_memory (sp + offset, value_contents_all (args[i]).data (), len);
570 /* Store struct value address. */
571 if (return_method == return_method_struct)
573 store_unsigned_integer (buf, 4, byte_order, struct_addr);
574 regcache->cooked_write (tdep->struct_value_regnum, buf);
577 /* Store return address. */
578 sp -= 4;
579 store_unsigned_integer (buf, 4, byte_order, bp_addr);
580 write_memory (sp, buf, 4);
582 /* Finally, update the stack pointer... */
583 store_unsigned_integer (buf, 4, byte_order, sp);
584 regcache->cooked_write (M68K_SP_REGNUM, buf);
586 /* ...and fake a frame pointer. */
587 regcache->cooked_write (M68K_FP_REGNUM, buf);
589 /* DWARF2/GCC uses the stack address *before* the function call as a
590 frame's CFA. */
591 return sp + 8;
594 /* Convert a dwarf or dwarf2 regnumber to a GDB regnum. */
596 static int
597 m68k_dwarf_reg_to_regnum (struct gdbarch *gdbarch, int num)
599 m68k_gdbarch_tdep *tdep = (m68k_gdbarch_tdep *) gdbarch_tdep (gdbarch);
601 if (num < 8)
602 /* d0..7 */
603 return (num - 0) + M68K_D0_REGNUM;
604 else if (num < 16)
605 /* a0..7 */
606 return (num - 8) + M68K_A0_REGNUM;
607 else if (num < 24 && tdep->fpregs_present)
608 /* fp0..7 */
609 return (num - 16) + M68K_FP0_REGNUM;
610 else if (num == 25)
611 /* pc */
612 return M68K_PC_REGNUM;
613 else
614 return -1;
618 struct m68k_frame_cache
620 /* Base address. */
621 CORE_ADDR base;
622 CORE_ADDR sp_offset;
623 CORE_ADDR pc;
625 /* Saved registers. */
626 CORE_ADDR saved_regs[M68K_NUM_REGS];
627 CORE_ADDR saved_sp;
629 /* Stack space reserved for local variables. */
630 long locals;
633 /* Allocate and initialize a frame cache. */
635 static struct m68k_frame_cache *
636 m68k_alloc_frame_cache (void)
638 struct m68k_frame_cache *cache;
639 int i;
641 cache = FRAME_OBSTACK_ZALLOC (struct m68k_frame_cache);
643 /* Base address. */
644 cache->base = 0;
645 cache->sp_offset = -4;
646 cache->pc = 0;
648 /* Saved registers. We initialize these to -1 since zero is a valid
649 offset (that's where %fp is supposed to be stored). */
650 for (i = 0; i < M68K_NUM_REGS; i++)
651 cache->saved_regs[i] = -1;
653 /* Frameless until proven otherwise. */
654 cache->locals = -1;
656 return cache;
659 /* Check whether PC points at a code that sets up a new stack frame.
660 If so, it updates CACHE and returns the address of the first
661 instruction after the sequence that sets removes the "hidden"
662 argument from the stack or CURRENT_PC, whichever is smaller.
663 Otherwise, return PC. */
665 static CORE_ADDR
666 m68k_analyze_frame_setup (struct gdbarch *gdbarch,
667 CORE_ADDR pc, CORE_ADDR current_pc,
668 struct m68k_frame_cache *cache)
670 enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
671 int op;
673 if (pc >= current_pc)
674 return current_pc;
676 op = read_memory_unsigned_integer (pc, 2, byte_order);
678 if (op == P_LINKW_FP || op == P_LINKL_FP || op == P_PEA_FP)
680 cache->saved_regs[M68K_FP_REGNUM] = 0;
681 cache->sp_offset += 4;
682 if (op == P_LINKW_FP)
684 /* link.w %fp, #-N */
685 /* link.w %fp, #0; adda.l #-N, %sp */
686 cache->locals = -read_memory_integer (pc + 2, 2, byte_order);
688 if (pc + 4 < current_pc && cache->locals == 0)
690 op = read_memory_unsigned_integer (pc + 4, 2, byte_order);
691 if (op == P_ADDAL_SP)
693 cache->locals = read_memory_integer (pc + 6, 4, byte_order);
694 return pc + 10;
698 return pc + 4;
700 else if (op == P_LINKL_FP)
702 /* link.l %fp, #-N */
703 cache->locals = -read_memory_integer (pc + 2, 4, byte_order);
704 return pc + 6;
706 else
708 /* pea (%fp); movea.l %sp, %fp */
709 cache->locals = 0;
711 if (pc + 2 < current_pc)
713 op = read_memory_unsigned_integer (pc + 2, 2, byte_order);
715 if (op == P_MOVEAL_SP_FP)
717 /* move.l %sp, %fp */
718 return pc + 4;
722 return pc + 2;
725 else if ((op & 0170777) == P_SUBQW_SP || (op & 0170777) == P_SUBQL_SP)
727 /* subq.[wl] #N,%sp */
728 /* subq.[wl] #8,%sp; subq.[wl] #N,%sp */
729 cache->locals = (op & 07000) == 0 ? 8 : (op & 07000) >> 9;
730 if (pc + 2 < current_pc)
732 op = read_memory_unsigned_integer (pc + 2, 2, byte_order);
733 if ((op & 0170777) == P_SUBQW_SP || (op & 0170777) == P_SUBQL_SP)
735 cache->locals += (op & 07000) == 0 ? 8 : (op & 07000) >> 9;
736 return pc + 4;
739 return pc + 2;
741 else if (op == P_ADDAW_SP || op == P_LEA_SP_SP)
743 /* adda.w #-N,%sp */
744 /* lea (-N,%sp),%sp */
745 cache->locals = -read_memory_integer (pc + 2, 2, byte_order);
746 return pc + 4;
748 else if (op == P_ADDAL_SP)
750 /* adda.l #-N,%sp */
751 cache->locals = -read_memory_integer (pc + 2, 4, byte_order);
752 return pc + 6;
755 return pc;
758 /* Check whether PC points at code that saves registers on the stack.
759 If so, it updates CACHE and returns the address of the first
760 instruction after the register saves or CURRENT_PC, whichever is
761 smaller. Otherwise, return PC. */
763 static CORE_ADDR
764 m68k_analyze_register_saves (struct gdbarch *gdbarch, CORE_ADDR pc,
765 CORE_ADDR current_pc,
766 struct m68k_frame_cache *cache)
768 enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
769 m68k_gdbarch_tdep *tdep = (m68k_gdbarch_tdep *) gdbarch_tdep (gdbarch);
771 if (cache->locals >= 0)
773 CORE_ADDR offset;
774 int op;
775 int i, mask, regno;
777 offset = -4 - cache->locals;
778 while (pc < current_pc)
780 op = read_memory_unsigned_integer (pc, 2, byte_order);
781 if (op == P_FMOVEMX_SP
782 && tdep->fpregs_present)
784 /* fmovem.x REGS,-(%sp) */
785 op = read_memory_unsigned_integer (pc + 2, 2, byte_order);
786 if ((op & 0xff00) == 0xe000)
788 mask = op & 0xff;
789 for (i = 0; i < 16; i++, mask >>= 1)
791 if (mask & 1)
793 cache->saved_regs[i + M68K_FP0_REGNUM] = offset;
794 offset -= 12;
797 pc += 4;
799 else
800 break;
802 else if ((op & 0177760) == P_MOVEL_SP)
804 /* move.l %R,-(%sp) */
805 regno = op & 017;
806 cache->saved_regs[regno] = offset;
807 offset -= 4;
808 pc += 2;
810 else if (op == P_MOVEML_SP)
812 /* movem.l REGS,-(%sp) */
813 mask = read_memory_unsigned_integer (pc + 2, 2, byte_order);
814 for (i = 0; i < 16; i++, mask >>= 1)
816 if (mask & 1)
818 cache->saved_regs[15 - i] = offset;
819 offset -= 4;
822 pc += 4;
824 else
825 break;
829 return pc;
833 /* Do a full analysis of the prologue at PC and update CACHE
834 accordingly. Bail out early if CURRENT_PC is reached. Return the
835 address where the analysis stopped.
837 We handle all cases that can be generated by gcc.
839 For allocating a stack frame:
841 link.w %a6,#-N
842 link.l %a6,#-N
843 pea (%fp); move.l %sp,%fp
844 link.w %a6,#0; add.l #-N,%sp
845 subq.l #N,%sp
846 subq.w #N,%sp
847 subq.w #8,%sp; subq.w #N-8,%sp
848 add.w #-N,%sp
849 lea (-N,%sp),%sp
850 add.l #-N,%sp
852 For saving registers:
854 fmovem.x REGS,-(%sp)
855 move.l R1,-(%sp)
856 move.l R1,-(%sp); move.l R2,-(%sp)
857 movem.l REGS,-(%sp)
859 For setting up the PIC register:
861 lea (%pc,N),%a5
865 static CORE_ADDR
866 m68k_analyze_prologue (struct gdbarch *gdbarch, CORE_ADDR pc,
867 CORE_ADDR current_pc, struct m68k_frame_cache *cache)
869 enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
870 unsigned int op;
872 pc = m68k_analyze_frame_setup (gdbarch, pc, current_pc, cache);
873 pc = m68k_analyze_register_saves (gdbarch, pc, current_pc, cache);
874 if (pc >= current_pc)
875 return current_pc;
877 /* Check for GOT setup. */
878 op = read_memory_unsigned_integer (pc, 4, byte_order);
879 if (op == P_LEA_PC_A5)
881 /* lea (%pc,N),%a5 */
882 return pc + 8;
885 return pc;
888 /* Return PC of first real instruction. */
890 static CORE_ADDR
891 m68k_skip_prologue (struct gdbarch *gdbarch, CORE_ADDR start_pc)
893 struct m68k_frame_cache cache;
894 CORE_ADDR pc;
896 cache.locals = -1;
897 pc = m68k_analyze_prologue (gdbarch, start_pc, (CORE_ADDR) -1, &cache);
898 if (cache.locals < 0)
899 return start_pc;
900 return pc;
903 static CORE_ADDR
904 m68k_unwind_pc (struct gdbarch *gdbarch, struct frame_info *next_frame)
906 gdb_byte buf[8];
908 frame_unwind_register (next_frame, gdbarch_pc_regnum (gdbarch), buf);
909 return extract_typed_address (buf, builtin_type (gdbarch)->builtin_func_ptr);
912 /* Normal frames. */
914 static struct m68k_frame_cache *
915 m68k_frame_cache (struct frame_info *this_frame, void **this_cache)
917 struct gdbarch *gdbarch = get_frame_arch (this_frame);
918 enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
919 struct m68k_frame_cache *cache;
920 gdb_byte buf[4];
921 int i;
923 if (*this_cache)
924 return (struct m68k_frame_cache *) *this_cache;
926 cache = m68k_alloc_frame_cache ();
927 *this_cache = cache;
929 /* In principle, for normal frames, %fp holds the frame pointer,
930 which holds the base address for the current stack frame.
931 However, for functions that don't need it, the frame pointer is
932 optional. For these "frameless" functions the frame pointer is
933 actually the frame pointer of the calling frame. Signal
934 trampolines are just a special case of a "frameless" function.
935 They (usually) share their frame pointer with the frame that was
936 in progress when the signal occurred. */
938 get_frame_register (this_frame, M68K_FP_REGNUM, buf);
939 cache->base = extract_unsigned_integer (buf, 4, byte_order);
940 if (cache->base == 0)
941 return cache;
943 /* For normal frames, %pc is stored at 4(%fp). */
944 cache->saved_regs[M68K_PC_REGNUM] = 4;
946 cache->pc = get_frame_func (this_frame);
947 if (cache->pc != 0)
948 m68k_analyze_prologue (get_frame_arch (this_frame), cache->pc,
949 get_frame_pc (this_frame), cache);
951 if (cache->locals < 0)
953 /* We didn't find a valid frame, which means that CACHE->base
954 currently holds the frame pointer for our calling frame. If
955 we're at the start of a function, or somewhere half-way its
956 prologue, the function's frame probably hasn't been fully
957 setup yet. Try to reconstruct the base address for the stack
958 frame by looking at the stack pointer. For truly "frameless"
959 functions this might work too. */
961 get_frame_register (this_frame, M68K_SP_REGNUM, buf);
962 cache->base = extract_unsigned_integer (buf, 4, byte_order)
963 + cache->sp_offset;
966 /* Now that we have the base address for the stack frame we can
967 calculate the value of %sp in the calling frame. */
968 cache->saved_sp = cache->base + 8;
970 /* Adjust all the saved registers such that they contain addresses
971 instead of offsets. */
972 for (i = 0; i < M68K_NUM_REGS; i++)
973 if (cache->saved_regs[i] != -1)
974 cache->saved_regs[i] += cache->base;
976 return cache;
979 static void
980 m68k_frame_this_id (struct frame_info *this_frame, void **this_cache,
981 struct frame_id *this_id)
983 struct m68k_frame_cache *cache = m68k_frame_cache (this_frame, this_cache);
985 /* This marks the outermost frame. */
986 if (cache->base == 0)
987 return;
989 /* See the end of m68k_push_dummy_call. */
990 *this_id = frame_id_build (cache->base + 8, cache->pc);
993 static struct value *
994 m68k_frame_prev_register (struct frame_info *this_frame, void **this_cache,
995 int regnum)
997 struct m68k_frame_cache *cache = m68k_frame_cache (this_frame, this_cache);
999 gdb_assert (regnum >= 0);
1001 if (regnum == M68K_SP_REGNUM && cache->saved_sp)
1002 return frame_unwind_got_constant (this_frame, regnum, cache->saved_sp);
1004 if (regnum < M68K_NUM_REGS && cache->saved_regs[regnum] != -1)
1005 return frame_unwind_got_memory (this_frame, regnum,
1006 cache->saved_regs[regnum]);
1008 return frame_unwind_got_register (this_frame, regnum, regnum);
1011 static const struct frame_unwind m68k_frame_unwind =
1013 "m68k prologue",
1014 NORMAL_FRAME,
1015 default_frame_unwind_stop_reason,
1016 m68k_frame_this_id,
1017 m68k_frame_prev_register,
1018 NULL,
1019 default_frame_sniffer
1022 static CORE_ADDR
1023 m68k_frame_base_address (struct frame_info *this_frame, void **this_cache)
1025 struct m68k_frame_cache *cache = m68k_frame_cache (this_frame, this_cache);
1027 return cache->base;
1030 static const struct frame_base m68k_frame_base =
1032 &m68k_frame_unwind,
1033 m68k_frame_base_address,
1034 m68k_frame_base_address,
1035 m68k_frame_base_address
1038 static struct frame_id
1039 m68k_dummy_id (struct gdbarch *gdbarch, struct frame_info *this_frame)
1041 CORE_ADDR fp;
1043 fp = get_frame_register_unsigned (this_frame, M68K_FP_REGNUM);
1045 /* See the end of m68k_push_dummy_call. */
1046 return frame_id_build (fp + 8, get_frame_pc (this_frame));
1050 /* Figure out where the longjmp will land. Slurp the args out of the stack.
1051 We expect the first arg to be a pointer to the jmp_buf structure from which
1052 we extract the pc (JB_PC) that we will land at. The pc is copied into PC.
1053 This routine returns true on success. */
1055 static int
1056 m68k_get_longjmp_target (struct frame_info *frame, CORE_ADDR *pc)
1058 gdb_byte *buf;
1059 CORE_ADDR sp, jb_addr;
1060 struct gdbarch *gdbarch = get_frame_arch (frame);
1061 m68k_gdbarch_tdep *tdep = (m68k_gdbarch_tdep *) gdbarch_tdep (gdbarch);
1062 enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
1064 if (tdep->jb_pc < 0)
1066 internal_error (__FILE__, __LINE__,
1067 _("m68k_get_longjmp_target: not implemented"));
1068 return 0;
1071 buf = (gdb_byte *) alloca (gdbarch_ptr_bit (gdbarch) / TARGET_CHAR_BIT);
1072 sp = get_frame_register_unsigned (frame, gdbarch_sp_regnum (gdbarch));
1074 if (target_read_memory (sp + SP_ARG0, /* Offset of first arg on stack. */
1075 buf, gdbarch_ptr_bit (gdbarch) / TARGET_CHAR_BIT))
1076 return 0;
1078 jb_addr = extract_unsigned_integer (buf, gdbarch_ptr_bit (gdbarch)
1079 / TARGET_CHAR_BIT, byte_order);
1081 if (target_read_memory (jb_addr + tdep->jb_pc * tdep->jb_elt_size, buf,
1082 gdbarch_ptr_bit (gdbarch) / TARGET_CHAR_BIT),
1083 byte_order)
1084 return 0;
1086 *pc = extract_unsigned_integer (buf, gdbarch_ptr_bit (gdbarch)
1087 / TARGET_CHAR_BIT, byte_order);
1088 return 1;
1092 /* This is the implementation of gdbarch method
1093 return_in_first_hidden_param_p. */
1095 static int
1096 m68k_return_in_first_hidden_param_p (struct gdbarch *gdbarch,
1097 struct type *type)
1099 return 0;
1102 /* System V Release 4 (SVR4). */
1104 void
1105 m68k_svr4_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
1107 m68k_gdbarch_tdep *tdep = (m68k_gdbarch_tdep *) gdbarch_tdep (gdbarch);
1109 /* SVR4 uses a different calling convention. */
1110 set_gdbarch_return_value (gdbarch, m68k_svr4_return_value);
1112 /* SVR4 uses %a0 instead of %a1. */
1113 tdep->struct_value_regnum = M68K_A0_REGNUM;
1115 /* SVR4 returns pointers in %a0. */
1116 tdep->pointer_result_regnum = M68K_A0_REGNUM;
1119 /* GCC's m68k "embedded" ABI. This is like the SVR4 ABI, but pointer
1120 values are returned in %d0, not %a0. */
1122 static void
1123 m68k_embedded_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
1125 m68k_gdbarch_tdep *tdep = (m68k_gdbarch_tdep *) gdbarch_tdep (gdbarch);
1127 m68k_svr4_init_abi (info, gdbarch);
1128 tdep->pointer_result_regnum = M68K_D0_REGNUM;
1133 /* Function: m68k_gdbarch_init
1134 Initializer function for the m68k gdbarch vector.
1135 Called by gdbarch. Sets up the gdbarch vector(s) for this target. */
1137 static struct gdbarch *
1138 m68k_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
1140 struct gdbarch *gdbarch;
1141 struct gdbarch_list *best_arch;
1142 tdesc_arch_data_up tdesc_data;
1143 int i;
1144 enum m68k_flavour flavour = m68k_no_flavour;
1145 int has_fp = 1;
1146 const struct floatformat **long_double_format = floatformats_m68881_ext;
1148 /* Check any target description for validity. */
1149 if (tdesc_has_registers (info.target_desc))
1151 const struct tdesc_feature *feature;
1152 int valid_p;
1154 feature = tdesc_find_feature (info.target_desc,
1155 "org.gnu.gdb.m68k.core");
1157 if (feature == NULL)
1159 feature = tdesc_find_feature (info.target_desc,
1160 "org.gnu.gdb.coldfire.core");
1161 if (feature != NULL)
1162 flavour = m68k_coldfire_flavour;
1165 if (feature == NULL)
1167 feature = tdesc_find_feature (info.target_desc,
1168 "org.gnu.gdb.fido.core");
1169 if (feature != NULL)
1170 flavour = m68k_fido_flavour;
1173 if (feature == NULL)
1174 return NULL;
1176 tdesc_data = tdesc_data_alloc ();
1178 valid_p = 1;
1179 for (i = 0; i <= M68K_PC_REGNUM; i++)
1180 valid_p &= tdesc_numbered_register (feature, tdesc_data.get (), i,
1181 m68k_register_names[i]);
1183 if (!valid_p)
1184 return NULL;
1186 feature = tdesc_find_feature (info.target_desc,
1187 "org.gnu.gdb.coldfire.fp");
1188 if (feature != NULL)
1190 valid_p = 1;
1191 for (i = M68K_FP0_REGNUM; i <= M68K_FPI_REGNUM; i++)
1192 valid_p &= tdesc_numbered_register (feature, tdesc_data.get (), i,
1193 m68k_register_names[i]);
1194 if (!valid_p)
1195 return NULL;
1197 else
1198 has_fp = 0;
1201 /* The mechanism for returning floating values from function
1202 and the type of long double depend on whether we're
1203 on ColdFire or standard m68k. */
1205 if (info.bfd_arch_info && info.bfd_arch_info->mach != 0)
1207 const bfd_arch_info_type *coldfire_arch =
1208 bfd_lookup_arch (bfd_arch_m68k, bfd_mach_mcf_isa_a_nodiv);
1210 if (coldfire_arch
1211 && ((*info.bfd_arch_info->compatible)
1212 (info.bfd_arch_info, coldfire_arch)))
1213 flavour = m68k_coldfire_flavour;
1216 /* Try to figure out if the arch uses floating registers to return
1217 floating point values from functions. On ColdFire, floating
1218 point values are returned in D0. */
1219 int float_return = 0;
1220 if (has_fp && flavour != m68k_coldfire_flavour)
1221 float_return = 1;
1222 #ifdef HAVE_ELF
1223 if (info.abfd && bfd_get_flavour (info.abfd) == bfd_target_elf_flavour)
1225 int fp_abi = bfd_elf_get_obj_attr_int (info.abfd, OBJ_ATTR_GNU,
1226 Tag_GNU_M68K_ABI_FP);
1227 if (fp_abi == 1)
1228 float_return = 1;
1229 else if (fp_abi == 2)
1230 float_return = 0;
1232 #endif /* HAVE_ELF */
1234 /* If there is already a candidate, use it. */
1235 for (best_arch = gdbarch_list_lookup_by_info (arches, &info);
1236 best_arch != NULL;
1237 best_arch = gdbarch_list_lookup_by_info (best_arch->next, &info))
1239 m68k_gdbarch_tdep *tdep
1240 = (m68k_gdbarch_tdep *) gdbarch_tdep (best_arch->gdbarch);
1242 if (flavour != tdep->flavour)
1243 continue;
1245 if (has_fp != tdep->fpregs_present)
1246 continue;
1248 if (float_return != tdep->float_return)
1249 continue;
1251 break;
1254 if (best_arch != NULL)
1255 return best_arch->gdbarch;
1257 m68k_gdbarch_tdep *tdep = new m68k_gdbarch_tdep;
1258 gdbarch = gdbarch_alloc (&info, tdep);
1259 tdep->fpregs_present = has_fp;
1260 tdep->float_return = float_return;
1261 tdep->flavour = flavour;
1263 if (flavour == m68k_coldfire_flavour || flavour == m68k_fido_flavour)
1264 long_double_format = floatformats_ieee_double;
1265 set_gdbarch_long_double_format (gdbarch, long_double_format);
1266 set_gdbarch_long_double_bit (gdbarch, long_double_format[0]->totalsize);
1268 set_gdbarch_skip_prologue (gdbarch, m68k_skip_prologue);
1269 set_gdbarch_breakpoint_kind_from_pc (gdbarch, m68k_breakpoint::kind_from_pc);
1270 set_gdbarch_sw_breakpoint_from_kind (gdbarch, m68k_breakpoint::bp_from_kind);
1272 /* Stack grows down. */
1273 set_gdbarch_inner_than (gdbarch, core_addr_lessthan);
1274 set_gdbarch_frame_align (gdbarch, m68k_frame_align);
1276 set_gdbarch_believe_pcc_promotion (gdbarch, 1);
1277 if (flavour == m68k_coldfire_flavour || flavour == m68k_fido_flavour)
1278 set_gdbarch_decr_pc_after_break (gdbarch, 2);
1280 set_gdbarch_frame_args_skip (gdbarch, 8);
1281 set_gdbarch_dwarf2_reg_to_regnum (gdbarch, m68k_dwarf_reg_to_regnum);
1283 set_gdbarch_register_type (gdbarch, m68k_register_type);
1284 set_gdbarch_register_name (gdbarch, m68k_register_name);
1285 set_gdbarch_num_regs (gdbarch, M68K_NUM_REGS);
1286 set_gdbarch_sp_regnum (gdbarch, M68K_SP_REGNUM);
1287 set_gdbarch_pc_regnum (gdbarch, M68K_PC_REGNUM);
1288 set_gdbarch_ps_regnum (gdbarch, M68K_PS_REGNUM);
1289 set_gdbarch_convert_register_p (gdbarch, m68k_convert_register_p);
1290 set_gdbarch_register_to_value (gdbarch, m68k_register_to_value);
1291 set_gdbarch_value_to_register (gdbarch, m68k_value_to_register);
1293 if (has_fp)
1294 set_gdbarch_fp0_regnum (gdbarch, M68K_FP0_REGNUM);
1296 /* Function call & return. */
1297 set_gdbarch_push_dummy_call (gdbarch, m68k_push_dummy_call);
1298 set_gdbarch_return_value (gdbarch, m68k_return_value);
1299 set_gdbarch_return_in_first_hidden_param_p (gdbarch,
1300 m68k_return_in_first_hidden_param_p);
1302 #if defined JB_PC && defined JB_ELEMENT_SIZE
1303 tdep->jb_pc = JB_PC;
1304 tdep->jb_elt_size = JB_ELEMENT_SIZE;
1305 #else
1306 tdep->jb_pc = -1;
1307 #endif
1308 tdep->pointer_result_regnum = M68K_D0_REGNUM;
1309 tdep->struct_value_regnum = M68K_A1_REGNUM;
1310 tdep->struct_return = reg_struct_return;
1312 /* Frame unwinder. */
1313 set_gdbarch_dummy_id (gdbarch, m68k_dummy_id);
1314 set_gdbarch_unwind_pc (gdbarch, m68k_unwind_pc);
1316 /* Hook in the DWARF CFI frame unwinder. */
1317 dwarf2_append_unwinders (gdbarch);
1319 frame_base_set_default (gdbarch, &m68k_frame_base);
1321 /* Hook in ABI-specific overrides, if they have been registered. */
1322 gdbarch_init_osabi (info, gdbarch);
1324 /* Now we have tuned the configuration, set a few final things,
1325 based on what the OS ABI has told us. */
1327 if (tdep->jb_pc >= 0)
1328 set_gdbarch_get_longjmp_target (gdbarch, m68k_get_longjmp_target);
1330 frame_unwind_append_unwinder (gdbarch, &m68k_frame_unwind);
1332 if (tdesc_data != nullptr)
1333 tdesc_use_registers (gdbarch, info.target_desc, std::move (tdesc_data));
1335 return gdbarch;
1339 static void
1340 m68k_dump_tdep (struct gdbarch *gdbarch, struct ui_file *file)
1342 m68k_gdbarch_tdep *tdep = (m68k_gdbarch_tdep *) gdbarch_tdep (gdbarch);
1344 if (tdep == NULL)
1345 return;
1348 /* OSABI sniffer for m68k. */
1350 static enum gdb_osabi
1351 m68k_osabi_sniffer (bfd *abfd)
1353 unsigned int elfosabi = elf_elfheader (abfd)->e_ident[EI_OSABI];
1355 if (elfosabi == ELFOSABI_NONE)
1356 return GDB_OSABI_SVR4;
1358 return GDB_OSABI_UNKNOWN;
1361 void _initialize_m68k_tdep ();
1362 void
1363 _initialize_m68k_tdep ()
1365 gdbarch_register (bfd_arch_m68k, m68k_gdbarch_init, m68k_dump_tdep);
1367 gdbarch_register_osabi_sniffer (bfd_arch_m68k, bfd_target_elf_flavour,
1368 m68k_osabi_sniffer);
1369 gdbarch_register_osabi (bfd_arch_m68k, 0, GDB_OSABI_SVR4,
1370 m68k_embedded_init_abi);