ld x86_64 tests: Accept x86-64-v3 as a needed ISA
[binutils-gdb.git] / gdb / m68k-tdep.c
blob5b2a29a350e53d2a7d366dcfcd95213d57b63897
1 /* Target-dependent code for the Motorola 68000 series.
3 Copyright (C) 1990-2023 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 = gdbarch_tdep<m68k_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 = gdbarch_tdep<m68k_gdbarch_tdep> (gdbarch);
104 if (!tdep->m68881_ext_type)
106 type_allocator alloc (gdbarch);
107 tdep->m68881_ext_type
108 = init_float_type (alloc, -1, "builtin_type_m68881_ext",
109 floatformats_m68881_ext);
112 return tdep->m68881_ext_type;
115 /* Return the GDB type object for the "standard" data type of data in
116 register N. This should be int for D0-D7, SR, FPCONTROL and
117 FPSTATUS, long double for FP0-FP7, and void pointer for all others
118 (A0-A7, PC, FPIADDR). Note, for registers which contain
119 addresses return pointer to void, not pointer to char, because we
120 don't want to attempt to print the string after printing the
121 address. */
123 static struct type *
124 m68k_register_type (struct gdbarch *gdbarch, int regnum)
126 m68k_gdbarch_tdep *tdep = gdbarch_tdep<m68k_gdbarch_tdep> (gdbarch);
128 if (tdep->fpregs_present)
130 if (regnum >= gdbarch_fp0_regnum (gdbarch)
131 && regnum <= gdbarch_fp0_regnum (gdbarch) + 7)
133 if (tdep->flavour == m68k_coldfire_flavour)
134 return builtin_type (gdbarch)->builtin_double;
135 else
136 return m68881_ext_type (gdbarch);
139 if (regnum == M68K_FPI_REGNUM)
140 return builtin_type (gdbarch)->builtin_func_ptr;
142 if (regnum == M68K_FPC_REGNUM || regnum == M68K_FPS_REGNUM)
143 return builtin_type (gdbarch)->builtin_int32;
145 else
147 if (regnum >= M68K_FP0_REGNUM && regnum <= M68K_FPI_REGNUM)
148 return builtin_type (gdbarch)->builtin_int0;
151 if (regnum == gdbarch_pc_regnum (gdbarch))
152 return builtin_type (gdbarch)->builtin_func_ptr;
154 if (regnum >= M68K_A0_REGNUM && regnum <= M68K_A0_REGNUM + 7)
155 return builtin_type (gdbarch)->builtin_data_ptr;
157 if (regnum == M68K_PS_REGNUM)
158 return m68k_ps_type (gdbarch);
160 return builtin_type (gdbarch)->builtin_int32;
163 static const char * const m68k_register_names[] = {
164 "d0", "d1", "d2", "d3", "d4", "d5", "d6", "d7",
165 "a0", "a1", "a2", "a3", "a4", "a5", "fp", "sp",
166 "ps", "pc",
167 "fp0", "fp1", "fp2", "fp3", "fp4", "fp5", "fp6", "fp7",
168 "fpcontrol", "fpstatus", "fpiaddr"
171 /* Function: m68k_register_name
172 Returns the name of the standard m68k register regnum. */
174 static const char *
175 m68k_register_name (struct gdbarch *gdbarch, int regnum)
177 m68k_gdbarch_tdep *tdep = gdbarch_tdep<m68k_gdbarch_tdep> (gdbarch);
179 gdb_static_assert (ARRAY_SIZE (m68k_register_names) == M68K_NUM_REGS);
180 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 = gdbarch_tdep<m68k_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 (frame_info_ptr 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 (frame_info_ptr 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 ();
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 = gdbarch_tdep<m68k_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 (_("Cannot extract return value of %d bytes long."), len);
321 static void
322 m68k_svr4_extract_return_value (struct type *type, struct regcache *regcache,
323 gdb_byte *valbuf)
325 gdb_byte buf[M68K_MAX_REGISTER_SIZE];
326 struct gdbarch *gdbarch = regcache->arch ();
327 m68k_gdbarch_tdep *tdep = gdbarch_tdep<m68k_gdbarch_tdep> (gdbarch);
329 if (tdep->float_return && type->code () == TYPE_CODE_FLT)
331 struct type *fpreg_type = register_type (gdbarch, M68K_FP0_REGNUM);
332 regcache->raw_read (M68K_FP0_REGNUM, buf);
333 target_float_convert (buf, fpreg_type, valbuf, type);
335 else
336 m68k_extract_return_value (type, regcache, valbuf);
339 /* Write a function return value of TYPE from VALBUF into REGCACHE. */
341 static void
342 m68k_store_return_value (struct type *type, struct regcache *regcache,
343 const gdb_byte *valbuf)
345 int len = type->length ();
347 if (type->code () == TYPE_CODE_PTR && len == 4)
349 struct gdbarch *gdbarch = regcache->arch ();
350 m68k_gdbarch_tdep *tdep = gdbarch_tdep<m68k_gdbarch_tdep> (gdbarch);
351 regcache->raw_write (tdep->pointer_result_regnum, valbuf);
352 /* gdb historically also set D0 in the SVR4 case. */
353 if (tdep->pointer_result_regnum != M68K_D0_REGNUM)
354 regcache->raw_write (M68K_D0_REGNUM, valbuf);
356 else if (len <= 4)
357 regcache->raw_write_part (M68K_D0_REGNUM, 4 - len, len, valbuf);
358 else if (len <= 8)
360 regcache->raw_write_part (M68K_D0_REGNUM, 8 - len, len - 4, valbuf);
361 regcache->raw_write (M68K_D1_REGNUM, valbuf + (len - 4));
363 else
364 internal_error (_("Cannot store return value of %d bytes long."), len);
367 static void
368 m68k_svr4_store_return_value (struct type *type, struct regcache *regcache,
369 const gdb_byte *valbuf)
371 struct gdbarch *gdbarch = regcache->arch ();
372 m68k_gdbarch_tdep *tdep = gdbarch_tdep<m68k_gdbarch_tdep> (gdbarch);
374 if (tdep->float_return && type->code () == TYPE_CODE_FLT)
376 struct type *fpreg_type = register_type (gdbarch, M68K_FP0_REGNUM);
377 gdb_byte buf[M68K_MAX_REGISTER_SIZE];
378 target_float_convert (valbuf, type, buf, fpreg_type);
379 regcache->raw_write (M68K_FP0_REGNUM, buf);
381 else
382 m68k_store_return_value (type, regcache, valbuf);
385 /* Return non-zero if TYPE, which is assumed to be a structure, union or
386 complex type, should be returned in registers for architecture
387 GDBARCH. */
389 static int
390 m68k_reg_struct_return_p (struct gdbarch *gdbarch, struct type *type)
392 m68k_gdbarch_tdep *tdep = gdbarch_tdep<m68k_gdbarch_tdep> (gdbarch);
393 enum type_code code = type->code ();
394 int len = type->length ();
396 gdb_assert (code == TYPE_CODE_STRUCT || code == TYPE_CODE_UNION
397 || code == TYPE_CODE_COMPLEX || code == TYPE_CODE_ARRAY);
399 if (tdep->struct_return == pcc_struct_return)
400 return 0;
402 const bool is_vector = code == TYPE_CODE_ARRAY && type->is_vector ();
404 if (is_vector
405 && check_typedef (type->target_type ())->code () == TYPE_CODE_FLT)
406 return 0;
408 /* According to m68k_return_in_memory in the m68k GCC back-end,
409 strange things happen for small aggregate types. Aggregate types
410 with only one component are always returned like the type of the
411 component. Aggregate types whose size is 2, 4, or 8 are returned
412 in registers if their natural alignment is at least 16 bits.
414 We reject vectors here, as experimentally this gives the correct
415 answer. */
416 if (!is_vector && (len == 2 || len == 4 || len == 8))
417 return type_align (type) >= 2;
419 return (len == 1 || len == 2 || len == 4 || len == 8);
422 /* Determine, for architecture GDBARCH, how a return value of TYPE
423 should be returned. If it is supposed to be returned in registers,
424 and READBUF is non-zero, read the appropriate value from REGCACHE,
425 and copy it into READBUF. If WRITEBUF is non-zero, write the value
426 from WRITEBUF into REGCACHE. */
428 static enum return_value_convention
429 m68k_return_value (struct gdbarch *gdbarch, struct value *function,
430 struct type *type, struct regcache *regcache,
431 gdb_byte *readbuf, const gdb_byte *writebuf)
433 enum type_code code = type->code ();
435 /* GCC returns a `long double' in memory too. */
436 if (((code == TYPE_CODE_STRUCT || code == TYPE_CODE_UNION
437 || code == TYPE_CODE_COMPLEX || code == TYPE_CODE_ARRAY)
438 && !m68k_reg_struct_return_p (gdbarch, type))
439 || (code == TYPE_CODE_FLT && type->length () == 12))
441 /* The default on m68k is to return structures in static memory.
442 Consequently a function must return the address where we can
443 find the return value. */
445 if (readbuf)
447 ULONGEST addr;
449 regcache_raw_read_unsigned (regcache, M68K_D0_REGNUM, &addr);
450 read_memory (addr, readbuf, type->length ());
453 return RETURN_VALUE_ABI_RETURNS_ADDRESS;
456 if (readbuf)
457 m68k_extract_return_value (type, regcache, readbuf);
458 if (writebuf)
459 m68k_store_return_value (type, regcache, writebuf);
461 return RETURN_VALUE_REGISTER_CONVENTION;
464 static enum return_value_convention
465 m68k_svr4_return_value (struct gdbarch *gdbarch, struct value *function,
466 struct type *type, struct regcache *regcache,
467 gdb_byte *readbuf, const gdb_byte *writebuf)
469 enum type_code code = type->code ();
470 m68k_gdbarch_tdep *tdep = gdbarch_tdep<m68k_gdbarch_tdep> (gdbarch);
472 /* Aggregates with a single member are always returned like their
473 sole element. */
474 if ((code == TYPE_CODE_STRUCT || code == TYPE_CODE_UNION)
475 && type->num_fields () == 1)
477 type = check_typedef (type->field (0).type ());
478 return m68k_svr4_return_value (gdbarch, function, type, regcache,
479 readbuf, writebuf);
482 if (((code == TYPE_CODE_STRUCT || code == TYPE_CODE_UNION
483 || code == TYPE_CODE_COMPLEX || code == TYPE_CODE_ARRAY)
484 && !m68k_reg_struct_return_p (gdbarch, type))
485 /* GCC may return a `long double' in memory too. */
486 || (!tdep->float_return
487 && code == TYPE_CODE_FLT
488 && type->length () == 12))
490 /* The System V ABI says that:
492 "A function returning a structure or union also sets %a0 to
493 the value it finds in %a0. Thus when the caller receives
494 control again, the address of the returned object resides in
495 register %a0."
497 So the ABI guarantees that we can always find the return
498 value just after the function has returned.
500 However, GCC also implements the "embedded" ABI. That ABI
501 does not preserve %a0 across calls, but does write the value
502 back to %d0. */
504 if (readbuf)
506 ULONGEST addr;
508 regcache_raw_read_unsigned (regcache, tdep->pointer_result_regnum,
509 &addr);
510 read_memory (addr, readbuf, type->length ());
513 return RETURN_VALUE_ABI_RETURNS_ADDRESS;
516 if (readbuf)
517 m68k_svr4_extract_return_value (type, regcache, readbuf);
518 if (writebuf)
519 m68k_svr4_store_return_value (type, regcache, writebuf);
521 return RETURN_VALUE_REGISTER_CONVENTION;
525 /* Always align the frame to a 4-byte boundary. This is required on
526 coldfire and harmless on the rest. */
528 static CORE_ADDR
529 m68k_frame_align (struct gdbarch *gdbarch, CORE_ADDR sp)
531 /* Align the stack to four bytes. */
532 return sp & ~3;
535 static CORE_ADDR
536 m68k_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
537 struct regcache *regcache, CORE_ADDR bp_addr, int nargs,
538 struct value **args, CORE_ADDR sp,
539 function_call_return_method return_method,
540 CORE_ADDR struct_addr)
542 m68k_gdbarch_tdep *tdep = gdbarch_tdep<m68k_gdbarch_tdep> (gdbarch);
543 enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
544 gdb_byte buf[4];
545 int i;
547 /* Push arguments in reverse order. */
548 for (i = nargs - 1; i >= 0; i--)
550 struct type *value_type = args[i]->enclosing_type ();
551 int len = value_type->length ();
552 int container_len = (len + 3) & ~3;
553 int offset;
555 /* Non-scalars bigger than 4 bytes are left aligned, others are
556 right aligned. */
557 if ((value_type->code () == TYPE_CODE_STRUCT
558 || value_type->code () == TYPE_CODE_UNION
559 || value_type->code () == TYPE_CODE_ARRAY)
560 && len > 4)
561 offset = 0;
562 else
563 offset = container_len - len;
564 sp -= container_len;
565 write_memory (sp + offset, args[i]->contents_all ().data (), len);
568 /* Store struct value address. */
569 if (return_method == return_method_struct)
571 store_unsigned_integer (buf, 4, byte_order, struct_addr);
572 regcache->cooked_write (tdep->struct_value_regnum, buf);
575 /* Store return address. */
576 sp -= 4;
577 store_unsigned_integer (buf, 4, byte_order, bp_addr);
578 write_memory (sp, buf, 4);
580 /* Finally, update the stack pointer... */
581 store_unsigned_integer (buf, 4, byte_order, sp);
582 regcache->cooked_write (M68K_SP_REGNUM, buf);
584 /* ...and fake a frame pointer. */
585 regcache->cooked_write (M68K_FP_REGNUM, buf);
587 /* DWARF2/GCC uses the stack address *before* the function call as a
588 frame's CFA. */
589 return sp + 8;
592 /* Convert a dwarf or dwarf2 regnumber to a GDB regnum. */
594 static int
595 m68k_dwarf_reg_to_regnum (struct gdbarch *gdbarch, int num)
597 m68k_gdbarch_tdep *tdep = gdbarch_tdep<m68k_gdbarch_tdep> (gdbarch);
599 if (num < 8)
600 /* d0..7 */
601 return (num - 0) + M68K_D0_REGNUM;
602 else if (num < 16)
603 /* a0..7 */
604 return (num - 8) + M68K_A0_REGNUM;
605 else if (num < 24 && tdep->fpregs_present)
606 /* fp0..7 */
607 return (num - 16) + M68K_FP0_REGNUM;
608 else if (num == 25)
609 /* pc */
610 return M68K_PC_REGNUM;
611 else
612 return -1;
616 struct m68k_frame_cache
618 /* Base address. */
619 CORE_ADDR base;
620 CORE_ADDR sp_offset;
621 CORE_ADDR pc;
623 /* Saved registers. */
624 CORE_ADDR saved_regs[M68K_NUM_REGS];
625 CORE_ADDR saved_sp;
627 /* Stack space reserved for local variables. */
628 long locals;
631 /* Allocate and initialize a frame cache. */
633 static struct m68k_frame_cache *
634 m68k_alloc_frame_cache (void)
636 struct m68k_frame_cache *cache;
637 int i;
639 cache = FRAME_OBSTACK_ZALLOC (struct m68k_frame_cache);
641 /* Base address. */
642 cache->base = 0;
643 cache->sp_offset = -4;
644 cache->pc = 0;
646 /* Saved registers. We initialize these to -1 since zero is a valid
647 offset (that's where %fp is supposed to be stored). */
648 for (i = 0; i < M68K_NUM_REGS; i++)
649 cache->saved_regs[i] = -1;
651 /* Frameless until proven otherwise. */
652 cache->locals = -1;
654 return cache;
657 /* Check whether PC points at a code that sets up a new stack frame.
658 If so, it updates CACHE and returns the address of the first
659 instruction after the sequence that sets removes the "hidden"
660 argument from the stack or CURRENT_PC, whichever is smaller.
661 Otherwise, return PC. */
663 static CORE_ADDR
664 m68k_analyze_frame_setup (struct gdbarch *gdbarch,
665 CORE_ADDR pc, CORE_ADDR current_pc,
666 struct m68k_frame_cache *cache)
668 enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
669 int op;
671 if (pc >= current_pc)
672 return current_pc;
674 op = read_memory_unsigned_integer (pc, 2, byte_order);
676 if (op == P_LINKW_FP || op == P_LINKL_FP || op == P_PEA_FP)
678 cache->saved_regs[M68K_FP_REGNUM] = 0;
679 cache->sp_offset += 4;
680 if (op == P_LINKW_FP)
682 /* link.w %fp, #-N */
683 /* link.w %fp, #0; adda.l #-N, %sp */
684 cache->locals = -read_memory_integer (pc + 2, 2, byte_order);
686 if (pc + 4 < current_pc && cache->locals == 0)
688 op = read_memory_unsigned_integer (pc + 4, 2, byte_order);
689 if (op == P_ADDAL_SP)
691 cache->locals = read_memory_integer (pc + 6, 4, byte_order);
692 return pc + 10;
696 return pc + 4;
698 else if (op == P_LINKL_FP)
700 /* link.l %fp, #-N */
701 cache->locals = -read_memory_integer (pc + 2, 4, byte_order);
702 return pc + 6;
704 else
706 /* pea (%fp); movea.l %sp, %fp */
707 cache->locals = 0;
709 if (pc + 2 < current_pc)
711 op = read_memory_unsigned_integer (pc + 2, 2, byte_order);
713 if (op == P_MOVEAL_SP_FP)
715 /* move.l %sp, %fp */
716 return pc + 4;
720 return pc + 2;
723 else if ((op & 0170777) == P_SUBQW_SP || (op & 0170777) == P_SUBQL_SP)
725 /* subq.[wl] #N,%sp */
726 /* subq.[wl] #8,%sp; subq.[wl] #N,%sp */
727 cache->locals = (op & 07000) == 0 ? 8 : (op & 07000) >> 9;
728 if (pc + 2 < current_pc)
730 op = read_memory_unsigned_integer (pc + 2, 2, byte_order);
731 if ((op & 0170777) == P_SUBQW_SP || (op & 0170777) == P_SUBQL_SP)
733 cache->locals += (op & 07000) == 0 ? 8 : (op & 07000) >> 9;
734 return pc + 4;
737 return pc + 2;
739 else if (op == P_ADDAW_SP || op == P_LEA_SP_SP)
741 /* adda.w #-N,%sp */
742 /* lea (-N,%sp),%sp */
743 cache->locals = -read_memory_integer (pc + 2, 2, byte_order);
744 return pc + 4;
746 else if (op == P_ADDAL_SP)
748 /* adda.l #-N,%sp */
749 cache->locals = -read_memory_integer (pc + 2, 4, byte_order);
750 return pc + 6;
753 return pc;
756 /* Check whether PC points at code that saves registers on the stack.
757 If so, it updates CACHE and returns the address of the first
758 instruction after the register saves or CURRENT_PC, whichever is
759 smaller. Otherwise, return PC. */
761 static CORE_ADDR
762 m68k_analyze_register_saves (struct gdbarch *gdbarch, CORE_ADDR pc,
763 CORE_ADDR current_pc,
764 struct m68k_frame_cache *cache)
766 enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
767 m68k_gdbarch_tdep *tdep = gdbarch_tdep<m68k_gdbarch_tdep> (gdbarch);
769 if (cache->locals >= 0)
771 CORE_ADDR offset;
772 int op;
773 int i, mask, regno;
775 offset = -4 - cache->locals;
776 while (pc < current_pc)
778 op = read_memory_unsigned_integer (pc, 2, byte_order);
779 if (op == P_FMOVEMX_SP
780 && tdep->fpregs_present)
782 /* fmovem.x REGS,-(%sp) */
783 op = read_memory_unsigned_integer (pc + 2, 2, byte_order);
784 if ((op & 0xff00) == 0xe000)
786 mask = op & 0xff;
787 for (i = 0; i < 16; i++, mask >>= 1)
789 if (mask & 1)
791 cache->saved_regs[i + M68K_FP0_REGNUM] = offset;
792 offset -= 12;
795 pc += 4;
797 else
798 break;
800 else if ((op & 0177760) == P_MOVEL_SP)
802 /* move.l %R,-(%sp) */
803 regno = op & 017;
804 cache->saved_regs[regno] = offset;
805 offset -= 4;
806 pc += 2;
808 else if (op == P_MOVEML_SP)
810 /* movem.l REGS,-(%sp) */
811 mask = read_memory_unsigned_integer (pc + 2, 2, byte_order);
812 for (i = 0; i < 16; i++, mask >>= 1)
814 if (mask & 1)
816 cache->saved_regs[15 - i] = offset;
817 offset -= 4;
820 pc += 4;
822 else
823 break;
827 return pc;
831 /* Do a full analysis of the prologue at PC and update CACHE
832 accordingly. Bail out early if CURRENT_PC is reached. Return the
833 address where the analysis stopped.
835 We handle all cases that can be generated by gcc.
837 For allocating a stack frame:
839 link.w %a6,#-N
840 link.l %a6,#-N
841 pea (%fp); move.l %sp,%fp
842 link.w %a6,#0; add.l #-N,%sp
843 subq.l #N,%sp
844 subq.w #N,%sp
845 subq.w #8,%sp; subq.w #N-8,%sp
846 add.w #-N,%sp
847 lea (-N,%sp),%sp
848 add.l #-N,%sp
850 For saving registers:
852 fmovem.x REGS,-(%sp)
853 move.l R1,-(%sp)
854 move.l R1,-(%sp); move.l R2,-(%sp)
855 movem.l REGS,-(%sp)
857 For setting up the PIC register:
859 lea (%pc,N),%a5
863 static CORE_ADDR
864 m68k_analyze_prologue (struct gdbarch *gdbarch, CORE_ADDR pc,
865 CORE_ADDR current_pc, struct m68k_frame_cache *cache)
867 enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
868 unsigned int op;
870 pc = m68k_analyze_frame_setup (gdbarch, pc, current_pc, cache);
871 pc = m68k_analyze_register_saves (gdbarch, pc, current_pc, cache);
872 if (pc >= current_pc)
873 return current_pc;
875 /* Check for GOT setup. */
876 op = read_memory_unsigned_integer (pc, 4, byte_order);
877 if (op == P_LEA_PC_A5)
879 /* lea (%pc,N),%a5 */
880 return pc + 8;
883 return pc;
886 /* Return PC of first real instruction. */
888 static CORE_ADDR
889 m68k_skip_prologue (struct gdbarch *gdbarch, CORE_ADDR start_pc)
891 struct m68k_frame_cache cache;
892 CORE_ADDR pc;
894 cache.locals = -1;
895 pc = m68k_analyze_prologue (gdbarch, start_pc, (CORE_ADDR) -1, &cache);
896 if (cache.locals < 0)
897 return start_pc;
898 return pc;
901 static CORE_ADDR
902 m68k_unwind_pc (struct gdbarch *gdbarch, frame_info_ptr next_frame)
904 gdb_byte buf[8];
906 frame_unwind_register (next_frame, gdbarch_pc_regnum (gdbarch), buf);
907 return extract_typed_address (buf, builtin_type (gdbarch)->builtin_func_ptr);
910 /* Normal frames. */
912 static struct m68k_frame_cache *
913 m68k_frame_cache (frame_info_ptr this_frame, void **this_cache)
915 struct gdbarch *gdbarch = get_frame_arch (this_frame);
916 enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
917 struct m68k_frame_cache *cache;
918 gdb_byte buf[4];
919 int i;
921 if (*this_cache)
922 return (struct m68k_frame_cache *) *this_cache;
924 cache = m68k_alloc_frame_cache ();
925 *this_cache = cache;
927 /* In principle, for normal frames, %fp holds the frame pointer,
928 which holds the base address for the current stack frame.
929 However, for functions that don't need it, the frame pointer is
930 optional. For these "frameless" functions the frame pointer is
931 actually the frame pointer of the calling frame. Signal
932 trampolines are just a special case of a "frameless" function.
933 They (usually) share their frame pointer with the frame that was
934 in progress when the signal occurred. */
936 get_frame_register (this_frame, M68K_FP_REGNUM, buf);
937 cache->base = extract_unsigned_integer (buf, 4, byte_order);
938 if (cache->base == 0)
939 return cache;
941 /* For normal frames, %pc is stored at 4(%fp). */
942 cache->saved_regs[M68K_PC_REGNUM] = 4;
944 cache->pc = get_frame_func (this_frame);
945 if (cache->pc != 0)
946 m68k_analyze_prologue (get_frame_arch (this_frame), cache->pc,
947 get_frame_pc (this_frame), cache);
949 if (cache->locals < 0)
951 /* We didn't find a valid frame, which means that CACHE->base
952 currently holds the frame pointer for our calling frame. If
953 we're at the start of a function, or somewhere half-way its
954 prologue, the function's frame probably hasn't been fully
955 setup yet. Try to reconstruct the base address for the stack
956 frame by looking at the stack pointer. For truly "frameless"
957 functions this might work too. */
959 get_frame_register (this_frame, M68K_SP_REGNUM, buf);
960 cache->base = extract_unsigned_integer (buf, 4, byte_order)
961 + cache->sp_offset;
964 /* Now that we have the base address for the stack frame we can
965 calculate the value of %sp in the calling frame. */
966 cache->saved_sp = cache->base + 8;
968 /* Adjust all the saved registers such that they contain addresses
969 instead of offsets. */
970 for (i = 0; i < M68K_NUM_REGS; i++)
971 if (cache->saved_regs[i] != -1)
972 cache->saved_regs[i] += cache->base;
974 return cache;
977 static void
978 m68k_frame_this_id (frame_info_ptr this_frame, void **this_cache,
979 struct frame_id *this_id)
981 struct m68k_frame_cache *cache = m68k_frame_cache (this_frame, this_cache);
983 /* This marks the outermost frame. */
984 if (cache->base == 0)
985 return;
987 /* See the end of m68k_push_dummy_call. */
988 *this_id = frame_id_build (cache->base + 8, cache->pc);
991 static struct value *
992 m68k_frame_prev_register (frame_info_ptr this_frame, void **this_cache,
993 int regnum)
995 struct m68k_frame_cache *cache = m68k_frame_cache (this_frame, this_cache);
997 gdb_assert (regnum >= 0);
999 if (regnum == M68K_SP_REGNUM && cache->saved_sp)
1000 return frame_unwind_got_constant (this_frame, regnum, cache->saved_sp);
1002 if (regnum < M68K_NUM_REGS && cache->saved_regs[regnum] != -1)
1003 return frame_unwind_got_memory (this_frame, regnum,
1004 cache->saved_regs[regnum]);
1006 return frame_unwind_got_register (this_frame, regnum, regnum);
1009 static const struct frame_unwind m68k_frame_unwind =
1011 "m68k prologue",
1012 NORMAL_FRAME,
1013 default_frame_unwind_stop_reason,
1014 m68k_frame_this_id,
1015 m68k_frame_prev_register,
1016 NULL,
1017 default_frame_sniffer
1020 static CORE_ADDR
1021 m68k_frame_base_address (frame_info_ptr this_frame, void **this_cache)
1023 struct m68k_frame_cache *cache = m68k_frame_cache (this_frame, this_cache);
1025 return cache->base;
1028 static const struct frame_base m68k_frame_base =
1030 &m68k_frame_unwind,
1031 m68k_frame_base_address,
1032 m68k_frame_base_address,
1033 m68k_frame_base_address
1036 static struct frame_id
1037 m68k_dummy_id (struct gdbarch *gdbarch, frame_info_ptr this_frame)
1039 CORE_ADDR fp;
1041 fp = get_frame_register_unsigned (this_frame, M68K_FP_REGNUM);
1043 /* See the end of m68k_push_dummy_call. */
1044 return frame_id_build (fp + 8, get_frame_pc (this_frame));
1048 /* Figure out where the longjmp will land. Slurp the args out of the stack.
1049 We expect the first arg to be a pointer to the jmp_buf structure from which
1050 we extract the pc (JB_PC) that we will land at. The pc is copied into PC.
1051 This routine returns true on success. */
1053 static int
1054 m68k_get_longjmp_target (frame_info_ptr frame, CORE_ADDR *pc)
1056 gdb_byte *buf;
1057 CORE_ADDR sp, jb_addr;
1058 struct gdbarch *gdbarch = get_frame_arch (frame);
1059 m68k_gdbarch_tdep *tdep = gdbarch_tdep<m68k_gdbarch_tdep> (gdbarch);
1060 enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
1062 if (tdep->jb_pc < 0)
1064 internal_error (_("m68k_get_longjmp_target: not implemented"));
1065 return 0;
1068 buf = (gdb_byte *) alloca (gdbarch_ptr_bit (gdbarch) / TARGET_CHAR_BIT);
1069 sp = get_frame_register_unsigned (frame, gdbarch_sp_regnum (gdbarch));
1071 if (target_read_memory (sp + SP_ARG0, /* Offset of first arg on stack. */
1072 buf, gdbarch_ptr_bit (gdbarch) / TARGET_CHAR_BIT))
1073 return 0;
1075 jb_addr = extract_unsigned_integer (buf, gdbarch_ptr_bit (gdbarch)
1076 / TARGET_CHAR_BIT, byte_order);
1078 if (target_read_memory (jb_addr + tdep->jb_pc * tdep->jb_elt_size, buf,
1079 gdbarch_ptr_bit (gdbarch) / TARGET_CHAR_BIT),
1080 byte_order)
1081 return 0;
1083 *pc = extract_unsigned_integer (buf, gdbarch_ptr_bit (gdbarch)
1084 / TARGET_CHAR_BIT, byte_order);
1085 return 1;
1089 /* This is the implementation of gdbarch method
1090 return_in_first_hidden_param_p. */
1092 static int
1093 m68k_return_in_first_hidden_param_p (struct gdbarch *gdbarch,
1094 struct type *type)
1096 return 0;
1099 /* System V Release 4 (SVR4). */
1101 void
1102 m68k_svr4_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
1104 m68k_gdbarch_tdep *tdep = gdbarch_tdep<m68k_gdbarch_tdep> (gdbarch);
1106 /* SVR4 uses a different calling convention. */
1107 set_gdbarch_return_value (gdbarch, m68k_svr4_return_value);
1109 /* SVR4 uses %a0 instead of %a1. */
1110 tdep->struct_value_regnum = M68K_A0_REGNUM;
1112 /* SVR4 returns pointers in %a0. */
1113 tdep->pointer_result_regnum = M68K_A0_REGNUM;
1116 /* GCC's m68k "embedded" ABI. This is like the SVR4 ABI, but pointer
1117 values are returned in %d0, not %a0. */
1119 static void
1120 m68k_embedded_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
1122 m68k_gdbarch_tdep *tdep = gdbarch_tdep<m68k_gdbarch_tdep> (gdbarch);
1124 m68k_svr4_init_abi (info, gdbarch);
1125 tdep->pointer_result_regnum = M68K_D0_REGNUM;
1130 /* Function: m68k_gdbarch_init
1131 Initializer function for the m68k gdbarch vector.
1132 Called by gdbarch. Sets up the gdbarch vector(s) for this target. */
1134 static struct gdbarch *
1135 m68k_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
1137 struct gdbarch_list *best_arch;
1138 tdesc_arch_data_up tdesc_data;
1139 int i;
1140 enum m68k_flavour flavour = m68k_no_flavour;
1141 int has_fp = 1;
1142 const struct floatformat **long_double_format = floatformats_m68881_ext;
1144 /* Check any target description for validity. */
1145 if (tdesc_has_registers (info.target_desc))
1147 const struct tdesc_feature *feature;
1148 int valid_p;
1150 feature = tdesc_find_feature (info.target_desc,
1151 "org.gnu.gdb.m68k.core");
1153 if (feature == NULL)
1155 feature = tdesc_find_feature (info.target_desc,
1156 "org.gnu.gdb.coldfire.core");
1157 if (feature != NULL)
1158 flavour = m68k_coldfire_flavour;
1161 if (feature == NULL)
1163 feature = tdesc_find_feature (info.target_desc,
1164 "org.gnu.gdb.fido.core");
1165 if (feature != NULL)
1166 flavour = m68k_fido_flavour;
1169 if (feature == NULL)
1170 return NULL;
1172 tdesc_data = tdesc_data_alloc ();
1174 valid_p = 1;
1175 for (i = 0; i <= M68K_PC_REGNUM; i++)
1176 valid_p &= tdesc_numbered_register (feature, tdesc_data.get (), i,
1177 m68k_register_names[i]);
1179 if (!valid_p)
1180 return NULL;
1182 feature = tdesc_find_feature (info.target_desc,
1183 "org.gnu.gdb.coldfire.fp");
1184 if (feature != NULL)
1186 valid_p = 1;
1187 for (i = M68K_FP0_REGNUM; i <= M68K_FPI_REGNUM; i++)
1188 valid_p &= tdesc_numbered_register (feature, tdesc_data.get (), i,
1189 m68k_register_names[i]);
1190 if (!valid_p)
1191 return NULL;
1193 else
1194 has_fp = 0;
1197 /* The mechanism for returning floating values from function
1198 and the type of long double depend on whether we're
1199 on ColdFire or standard m68k. */
1201 if (info.bfd_arch_info && info.bfd_arch_info->mach != 0)
1203 const bfd_arch_info_type *coldfire_arch =
1204 bfd_lookup_arch (bfd_arch_m68k, bfd_mach_mcf_isa_a_nodiv);
1206 if (coldfire_arch
1207 && ((*info.bfd_arch_info->compatible)
1208 (info.bfd_arch_info, coldfire_arch)))
1209 flavour = m68k_coldfire_flavour;
1212 /* Try to figure out if the arch uses floating registers to return
1213 floating point values from functions. On ColdFire, floating
1214 point values are returned in D0. */
1215 int float_return = 0;
1216 if (has_fp && flavour != m68k_coldfire_flavour)
1217 float_return = 1;
1218 #ifdef HAVE_ELF
1219 if (info.abfd && bfd_get_flavour (info.abfd) == bfd_target_elf_flavour)
1221 int fp_abi = bfd_elf_get_obj_attr_int (info.abfd, OBJ_ATTR_GNU,
1222 Tag_GNU_M68K_ABI_FP);
1223 if (fp_abi == 1)
1224 float_return = 1;
1225 else if (fp_abi == 2)
1226 float_return = 0;
1228 #endif /* HAVE_ELF */
1230 /* If there is already a candidate, use it. */
1231 for (best_arch = gdbarch_list_lookup_by_info (arches, &info);
1232 best_arch != NULL;
1233 best_arch = gdbarch_list_lookup_by_info (best_arch->next, &info))
1235 m68k_gdbarch_tdep *tdep
1236 = gdbarch_tdep<m68k_gdbarch_tdep> (best_arch->gdbarch);
1238 if (flavour != tdep->flavour)
1239 continue;
1241 if (has_fp != tdep->fpregs_present)
1242 continue;
1244 if (float_return != tdep->float_return)
1245 continue;
1247 break;
1250 if (best_arch != NULL)
1251 return best_arch->gdbarch;
1253 gdbarch *gdbarch
1254 = gdbarch_alloc (&info, gdbarch_tdep_up (new m68k_gdbarch_tdep));
1255 m68k_gdbarch_tdep *tdep = gdbarch_tdep<m68k_gdbarch_tdep> (gdbarch);
1257 tdep->fpregs_present = has_fp;
1258 tdep->float_return = float_return;
1259 tdep->flavour = flavour;
1261 if (flavour == m68k_coldfire_flavour || flavour == m68k_fido_flavour)
1262 long_double_format = floatformats_ieee_double;
1263 set_gdbarch_long_double_format (gdbarch, long_double_format);
1264 set_gdbarch_long_double_bit (gdbarch, long_double_format[0]->totalsize);
1266 set_gdbarch_skip_prologue (gdbarch, m68k_skip_prologue);
1267 set_gdbarch_breakpoint_kind_from_pc (gdbarch, m68k_breakpoint::kind_from_pc);
1268 set_gdbarch_sw_breakpoint_from_kind (gdbarch, m68k_breakpoint::bp_from_kind);
1270 /* Stack grows down. */
1271 set_gdbarch_inner_than (gdbarch, core_addr_lessthan);
1272 set_gdbarch_frame_align (gdbarch, m68k_frame_align);
1274 set_gdbarch_believe_pcc_promotion (gdbarch, 1);
1275 if (flavour == m68k_coldfire_flavour || flavour == m68k_fido_flavour)
1276 set_gdbarch_decr_pc_after_break (gdbarch, 2);
1278 set_gdbarch_frame_args_skip (gdbarch, 8);
1279 set_gdbarch_dwarf2_reg_to_regnum (gdbarch, m68k_dwarf_reg_to_regnum);
1281 set_gdbarch_register_type (gdbarch, m68k_register_type);
1282 set_gdbarch_register_name (gdbarch, m68k_register_name);
1283 set_gdbarch_num_regs (gdbarch, M68K_NUM_REGS);
1284 set_gdbarch_sp_regnum (gdbarch, M68K_SP_REGNUM);
1285 set_gdbarch_pc_regnum (gdbarch, M68K_PC_REGNUM);
1286 set_gdbarch_ps_regnum (gdbarch, M68K_PS_REGNUM);
1287 set_gdbarch_convert_register_p (gdbarch, m68k_convert_register_p);
1288 set_gdbarch_register_to_value (gdbarch, m68k_register_to_value);
1289 set_gdbarch_value_to_register (gdbarch, m68k_value_to_register);
1291 if (has_fp)
1292 set_gdbarch_fp0_regnum (gdbarch, M68K_FP0_REGNUM);
1294 /* Function call & return. */
1295 set_gdbarch_push_dummy_call (gdbarch, m68k_push_dummy_call);
1296 set_gdbarch_return_value (gdbarch, m68k_return_value);
1297 set_gdbarch_return_in_first_hidden_param_p (gdbarch,
1298 m68k_return_in_first_hidden_param_p);
1300 #if defined JB_PC && defined JB_ELEMENT_SIZE
1301 tdep->jb_pc = JB_PC;
1302 tdep->jb_elt_size = JB_ELEMENT_SIZE;
1303 #else
1304 tdep->jb_pc = -1;
1305 #endif
1306 tdep->pointer_result_regnum = M68K_D0_REGNUM;
1307 tdep->struct_value_regnum = M68K_A1_REGNUM;
1308 tdep->struct_return = reg_struct_return;
1310 /* Frame unwinder. */
1311 set_gdbarch_dummy_id (gdbarch, m68k_dummy_id);
1312 set_gdbarch_unwind_pc (gdbarch, m68k_unwind_pc);
1314 /* Hook in the DWARF CFI frame unwinder. */
1315 dwarf2_append_unwinders (gdbarch);
1317 frame_base_set_default (gdbarch, &m68k_frame_base);
1319 /* Hook in ABI-specific overrides, if they have been registered. */
1320 gdbarch_init_osabi (info, gdbarch);
1322 /* Now we have tuned the configuration, set a few final things,
1323 based on what the OS ABI has told us. */
1325 if (tdep->jb_pc >= 0)
1326 set_gdbarch_get_longjmp_target (gdbarch, m68k_get_longjmp_target);
1328 frame_unwind_append_unwinder (gdbarch, &m68k_frame_unwind);
1330 if (tdesc_data != nullptr)
1331 tdesc_use_registers (gdbarch, info.target_desc, std::move (tdesc_data));
1333 return gdbarch;
1337 static void
1338 m68k_dump_tdep (struct gdbarch *gdbarch, struct ui_file *file)
1340 m68k_gdbarch_tdep *tdep = gdbarch_tdep<m68k_gdbarch_tdep> (gdbarch);
1342 if (tdep == NULL)
1343 return;
1346 /* OSABI sniffer for m68k. */
1348 static enum gdb_osabi
1349 m68k_osabi_sniffer (bfd *abfd)
1351 unsigned int elfosabi = elf_elfheader (abfd)->e_ident[EI_OSABI];
1353 if (elfosabi == ELFOSABI_NONE)
1354 return GDB_OSABI_SVR4;
1356 return GDB_OSABI_UNKNOWN;
1359 void _initialize_m68k_tdep ();
1360 void
1361 _initialize_m68k_tdep ()
1363 gdbarch_register (bfd_arch_m68k, m68k_gdbarch_init, m68k_dump_tdep);
1365 gdbarch_register_osabi_sniffer (bfd_arch_m68k, bfd_target_elf_flavour,
1366 m68k_osabi_sniffer);
1367 gdbarch_register_osabi (bfd_arch_m68k, 0, GDB_OSABI_SVR4,
1368 m68k_embedded_init_abi);