1 /* Target-dependent code for GNU/Linux on MIPS processors.
3 Copyright (C) 2001, 2002, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011
4 Free Software Foundation, Inc.
6 This file is part of GDB.
8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 3 of the License, or
11 (at your option) any later version.
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with this program. If not, see <http://www.gnu.org/licenses/>. */
24 #include "solib-svr4.h"
26 #include "mips-tdep.h"
27 #include "gdb_string.h"
28 #include "gdb_assert.h"
31 #include "trad-frame.h"
32 #include "tramp-frame.h"
35 #include "solib-svr4.h"
38 #include "target-descriptions.h"
40 #include "mips-linux-tdep.h"
41 #include "glibc-tdep.h"
42 #include "linux-tdep.h"
43 #include "xml-syscall.h"
45 static struct target_so_ops mips_svr4_so_ops;
47 /* Figure out where the longjmp will land.
48 We expect the first arg to be a pointer to the jmp_buf structure
49 from which we extract the pc (MIPS_LINUX_JB_PC) that we will land
50 at. The pc is copied into PC. This routine returns 1 on
53 #define MIPS_LINUX_JB_ELEMENT_SIZE 4
54 #define MIPS_LINUX_JB_PC 0
57 mips_linux_get_longjmp_target (struct frame_info *frame, CORE_ADDR *pc)
60 struct gdbarch *gdbarch = get_frame_arch (frame);
61 enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
62 char buf[gdbarch_ptr_bit (gdbarch) / TARGET_CHAR_BIT];
64 jb_addr = get_frame_register_unsigned (frame, MIPS_A0_REGNUM);
66 if (target_read_memory (jb_addr
67 + MIPS_LINUX_JB_PC * MIPS_LINUX_JB_ELEMENT_SIZE,
68 buf, gdbarch_ptr_bit (gdbarch) / TARGET_CHAR_BIT))
71 *pc = extract_unsigned_integer (buf,
72 gdbarch_ptr_bit (gdbarch) / TARGET_CHAR_BIT,
78 /* Transform the bits comprising a 32-bit register to the right size
79 for regcache_raw_supply(). This is needed when mips_isa_regsize()
83 supply_32bit_reg (struct regcache *regcache, int regnum, const void *addr)
85 struct gdbarch *gdbarch = get_regcache_arch (regcache);
86 enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
87 gdb_byte buf[MAX_REGISTER_SIZE];
88 store_signed_integer (buf, register_size (gdbarch, regnum), byte_order,
89 extract_signed_integer (addr, 4, byte_order));
90 regcache_raw_supply (regcache, regnum, buf);
93 /* Unpack an elf_gregset_t into GDB's register cache. */
96 mips_supply_gregset (struct regcache *regcache,
97 const mips_elf_gregset_t *gregsetp)
100 const mips_elf_greg_t *regp = *gregsetp;
101 char zerobuf[MAX_REGISTER_SIZE];
102 struct gdbarch *gdbarch = get_regcache_arch (regcache);
104 memset (zerobuf, 0, MAX_REGISTER_SIZE);
106 for (regi = EF_REG0 + 1; regi <= EF_REG31; regi++)
107 supply_32bit_reg (regcache, regi - EF_REG0, regp + regi);
109 if (mips_linux_restart_reg_p (gdbarch))
110 supply_32bit_reg (regcache, MIPS_RESTART_REGNUM, regp + EF_REG0);
112 supply_32bit_reg (regcache, mips_regnum (gdbarch)->lo, regp + EF_LO);
113 supply_32bit_reg (regcache, mips_regnum (gdbarch)->hi, regp + EF_HI);
115 supply_32bit_reg (regcache, mips_regnum (gdbarch)->pc,
117 supply_32bit_reg (regcache, mips_regnum (gdbarch)->badvaddr,
118 regp + EF_CP0_BADVADDR);
119 supply_32bit_reg (regcache, MIPS_PS_REGNUM, regp + EF_CP0_STATUS);
120 supply_32bit_reg (regcache, mips_regnum (gdbarch)->cause,
121 regp + EF_CP0_CAUSE);
123 /* Fill inaccessible registers with zero. */
124 regcache_raw_supply (regcache, MIPS_ZERO_REGNUM, zerobuf);
125 regcache_raw_supply (regcache, MIPS_UNUSED_REGNUM, zerobuf);
126 for (regi = MIPS_FIRST_EMBED_REGNUM;
127 regi <= MIPS_LAST_EMBED_REGNUM;
129 regcache_raw_supply (regcache, regi, zerobuf);
133 mips_supply_gregset_wrapper (const struct regset *regset,
134 struct regcache *regcache,
135 int regnum, const void *gregs, size_t len)
137 gdb_assert (len == sizeof (mips_elf_gregset_t));
139 mips_supply_gregset (regcache, (const mips_elf_gregset_t *)gregs);
142 /* Pack our registers (or one register) into an elf_gregset_t. */
145 mips_fill_gregset (const struct regcache *regcache,
146 mips_elf_gregset_t *gregsetp, int regno)
148 struct gdbarch *gdbarch = get_regcache_arch (regcache);
150 mips_elf_greg_t *regp = *gregsetp;
155 memset (regp, 0, sizeof (mips_elf_gregset_t));
156 for (regi = 1; regi < 32; regi++)
157 mips_fill_gregset (regcache, gregsetp, regi);
158 mips_fill_gregset (regcache, gregsetp, mips_regnum (gdbarch)->lo);
159 mips_fill_gregset (regcache, gregsetp, mips_regnum (gdbarch)->hi);
160 mips_fill_gregset (regcache, gregsetp, mips_regnum (gdbarch)->pc);
161 mips_fill_gregset (regcache, gregsetp, mips_regnum (gdbarch)->badvaddr);
162 mips_fill_gregset (regcache, gregsetp, MIPS_PS_REGNUM);
163 mips_fill_gregset (regcache, gregsetp, mips_regnum (gdbarch)->cause);
164 mips_fill_gregset (regcache, gregsetp, MIPS_RESTART_REGNUM);
168 if (regno > 0 && regno < 32)
170 dst = regp + regno + EF_REG0;
171 regcache_raw_collect (regcache, regno, dst);
175 if (regno == mips_regnum (gdbarch)->lo)
177 else if (regno == mips_regnum (gdbarch)->hi)
179 else if (regno == mips_regnum (gdbarch)->pc)
180 regaddr = EF_CP0_EPC;
181 else if (regno == mips_regnum (gdbarch)->badvaddr)
182 regaddr = EF_CP0_BADVADDR;
183 else if (regno == MIPS_PS_REGNUM)
184 regaddr = EF_CP0_STATUS;
185 else if (regno == mips_regnum (gdbarch)->cause)
186 regaddr = EF_CP0_CAUSE;
187 else if (mips_linux_restart_reg_p (gdbarch)
188 && regno == MIPS_RESTART_REGNUM)
195 dst = regp + regaddr;
196 regcache_raw_collect (regcache, regno, dst);
201 mips_fill_gregset_wrapper (const struct regset *regset,
202 const struct regcache *regcache,
203 int regnum, void *gregs, size_t len)
205 gdb_assert (len == sizeof (mips_elf_gregset_t));
207 mips_fill_gregset (regcache, (mips_elf_gregset_t *)gregs, regnum);
210 /* Likewise, unpack an elf_fpregset_t. */
213 mips_supply_fpregset (struct regcache *regcache,
214 const mips_elf_fpregset_t *fpregsetp)
216 struct gdbarch *gdbarch = get_regcache_arch (regcache);
218 char zerobuf[MAX_REGISTER_SIZE];
220 memset (zerobuf, 0, MAX_REGISTER_SIZE);
222 for (regi = 0; regi < 32; regi++)
223 regcache_raw_supply (regcache,
224 gdbarch_fp0_regnum (gdbarch) + regi,
227 regcache_raw_supply (regcache,
228 mips_regnum (gdbarch)->fp_control_status,
231 /* FIXME: how can we supply FCRIR? The ABI doesn't tell us. */
232 regcache_raw_supply (regcache,
233 mips_regnum (gdbarch)->fp_implementation_revision,
238 mips_supply_fpregset_wrapper (const struct regset *regset,
239 struct regcache *regcache,
240 int regnum, const void *gregs, size_t len)
242 gdb_assert (len == sizeof (mips_elf_fpregset_t));
244 mips_supply_fpregset (regcache, (const mips_elf_fpregset_t *)gregs);
247 /* Likewise, pack one or all floating point registers into an
251 mips_fill_fpregset (const struct regcache *regcache,
252 mips_elf_fpregset_t *fpregsetp, int regno)
254 struct gdbarch *gdbarch = get_regcache_arch (regcache);
257 if ((regno >= gdbarch_fp0_regnum (gdbarch))
258 && (regno < gdbarch_fp0_regnum (gdbarch) + 32))
260 to = (char *) (*fpregsetp + regno - gdbarch_fp0_regnum (gdbarch));
261 regcache_raw_collect (regcache, regno, to);
263 else if (regno == mips_regnum (gdbarch)->fp_control_status)
265 to = (char *) (*fpregsetp + 32);
266 regcache_raw_collect (regcache, regno, to);
268 else if (regno == -1)
272 for (regi = 0; regi < 32; regi++)
273 mips_fill_fpregset (regcache, fpregsetp,
274 gdbarch_fp0_regnum (gdbarch) + regi);
275 mips_fill_fpregset (regcache, fpregsetp,
276 mips_regnum (gdbarch)->fp_control_status);
281 mips_fill_fpregset_wrapper (const struct regset *regset,
282 const struct regcache *regcache,
283 int regnum, void *gregs, size_t len)
285 gdb_assert (len == sizeof (mips_elf_fpregset_t));
287 mips_fill_fpregset (regcache, (mips_elf_fpregset_t *)gregs, regnum);
290 /* Support for 64-bit ABIs. */
292 /* Figure out where the longjmp will land.
293 We expect the first arg to be a pointer to the jmp_buf structure
294 from which we extract the pc (MIPS_LINUX_JB_PC) that we will land
295 at. The pc is copied into PC. This routine returns 1 on
298 /* Details about jmp_buf. */
300 #define MIPS64_LINUX_JB_PC 0
303 mips64_linux_get_longjmp_target (struct frame_info *frame, CORE_ADDR *pc)
306 struct gdbarch *gdbarch = get_frame_arch (frame);
307 enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
308 void *buf = alloca (gdbarch_ptr_bit (gdbarch) / TARGET_CHAR_BIT);
309 int element_size = gdbarch_ptr_bit (gdbarch) == 32 ? 4 : 8;
311 jb_addr = get_frame_register_unsigned (frame, MIPS_A0_REGNUM);
313 if (target_read_memory (jb_addr + MIPS64_LINUX_JB_PC * element_size,
315 gdbarch_ptr_bit (gdbarch) / TARGET_CHAR_BIT))
318 *pc = extract_unsigned_integer (buf,
319 gdbarch_ptr_bit (gdbarch) / TARGET_CHAR_BIT,
325 /* Register set support functions. These operate on standard 64-bit
326 regsets, but work whether the target is 32-bit or 64-bit. A 32-bit
327 target will still use the 64-bit format for PTRACE_GETREGS. */
329 /* Supply a 64-bit register. */
332 supply_64bit_reg (struct regcache *regcache, int regnum,
335 struct gdbarch *gdbarch = get_regcache_arch (regcache);
336 if (gdbarch_byte_order (gdbarch) == BFD_ENDIAN_BIG
337 && register_size (gdbarch, regnum) == 4)
338 regcache_raw_supply (regcache, regnum, buf + 4);
340 regcache_raw_supply (regcache, regnum, buf);
343 /* Unpack a 64-bit elf_gregset_t into GDB's register cache. */
346 mips64_supply_gregset (struct regcache *regcache,
347 const mips64_elf_gregset_t *gregsetp)
350 const mips64_elf_greg_t *regp = *gregsetp;
351 gdb_byte zerobuf[MAX_REGISTER_SIZE];
352 struct gdbarch *gdbarch = get_regcache_arch (regcache);
354 memset (zerobuf, 0, MAX_REGISTER_SIZE);
356 for (regi = MIPS64_EF_REG0 + 1; regi <= MIPS64_EF_REG31; regi++)
357 supply_64bit_reg (regcache, regi - MIPS64_EF_REG0,
358 (const gdb_byte *)(regp + regi));
360 if (mips_linux_restart_reg_p (gdbarch))
361 supply_64bit_reg (regcache, MIPS_RESTART_REGNUM,
362 (const gdb_byte *)(regp + MIPS64_EF_REG0));
364 supply_64bit_reg (regcache, mips_regnum (gdbarch)->lo,
365 (const gdb_byte *) (regp + MIPS64_EF_LO));
366 supply_64bit_reg (regcache, mips_regnum (gdbarch)->hi,
367 (const gdb_byte *) (regp + MIPS64_EF_HI));
369 supply_64bit_reg (regcache, mips_regnum (gdbarch)->pc,
370 (const gdb_byte *) (regp + MIPS64_EF_CP0_EPC));
371 supply_64bit_reg (regcache, mips_regnum (gdbarch)->badvaddr,
372 (const gdb_byte *) (regp + MIPS64_EF_CP0_BADVADDR));
373 supply_64bit_reg (regcache, MIPS_PS_REGNUM,
374 (const gdb_byte *) (regp + MIPS64_EF_CP0_STATUS));
375 supply_64bit_reg (regcache, mips_regnum (gdbarch)->cause,
376 (const gdb_byte *) (regp + MIPS64_EF_CP0_CAUSE));
378 /* Fill inaccessible registers with zero. */
379 regcache_raw_supply (regcache, MIPS_ZERO_REGNUM, zerobuf);
380 regcache_raw_supply (regcache, MIPS_UNUSED_REGNUM, zerobuf);
381 for (regi = MIPS_FIRST_EMBED_REGNUM;
382 regi <= MIPS_LAST_EMBED_REGNUM;
384 regcache_raw_supply (regcache, regi, zerobuf);
388 mips64_supply_gregset_wrapper (const struct regset *regset,
389 struct regcache *regcache,
390 int regnum, const void *gregs, size_t len)
392 gdb_assert (len == sizeof (mips64_elf_gregset_t));
394 mips64_supply_gregset (regcache, (const mips64_elf_gregset_t *)gregs);
397 /* Pack our registers (or one register) into a 64-bit elf_gregset_t. */
400 mips64_fill_gregset (const struct regcache *regcache,
401 mips64_elf_gregset_t *gregsetp, int regno)
403 struct gdbarch *gdbarch = get_regcache_arch (regcache);
404 enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
406 mips64_elf_greg_t *regp = *gregsetp;
411 memset (regp, 0, sizeof (mips64_elf_gregset_t));
412 for (regi = 1; regi < 32; regi++)
413 mips64_fill_gregset (regcache, gregsetp, regi);
414 mips64_fill_gregset (regcache, gregsetp, mips_regnum (gdbarch)->lo);
415 mips64_fill_gregset (regcache, gregsetp, mips_regnum (gdbarch)->hi);
416 mips64_fill_gregset (regcache, gregsetp, mips_regnum (gdbarch)->pc);
417 mips64_fill_gregset (regcache, gregsetp,
418 mips_regnum (gdbarch)->badvaddr);
419 mips64_fill_gregset (regcache, gregsetp, MIPS_PS_REGNUM);
420 mips64_fill_gregset (regcache, gregsetp, mips_regnum (gdbarch)->cause);
421 mips64_fill_gregset (regcache, gregsetp, MIPS_RESTART_REGNUM);
425 if (regno > 0 && regno < 32)
426 regaddr = regno + MIPS64_EF_REG0;
427 else if (regno == mips_regnum (gdbarch)->lo)
428 regaddr = MIPS64_EF_LO;
429 else if (regno == mips_regnum (gdbarch)->hi)
430 regaddr = MIPS64_EF_HI;
431 else if (regno == mips_regnum (gdbarch)->pc)
432 regaddr = MIPS64_EF_CP0_EPC;
433 else if (regno == mips_regnum (gdbarch)->badvaddr)
434 regaddr = MIPS64_EF_CP0_BADVADDR;
435 else if (regno == MIPS_PS_REGNUM)
436 regaddr = MIPS64_EF_CP0_STATUS;
437 else if (regno == mips_regnum (gdbarch)->cause)
438 regaddr = MIPS64_EF_CP0_CAUSE;
439 else if (mips_linux_restart_reg_p (gdbarch)
440 && regno == MIPS_RESTART_REGNUM)
441 regaddr = MIPS64_EF_REG0;
447 gdb_byte buf[MAX_REGISTER_SIZE];
450 regcache_raw_collect (regcache, regno, buf);
451 val = extract_signed_integer (buf, register_size (gdbarch, regno),
453 dst = regp + regaddr;
454 store_signed_integer (dst, 8, byte_order, val);
459 mips64_fill_gregset_wrapper (const struct regset *regset,
460 const struct regcache *regcache,
461 int regnum, void *gregs, size_t len)
463 gdb_assert (len == sizeof (mips64_elf_gregset_t));
465 mips64_fill_gregset (regcache, (mips64_elf_gregset_t *)gregs, regnum);
468 /* Likewise, unpack an elf_fpregset_t. */
471 mips64_supply_fpregset (struct regcache *regcache,
472 const mips64_elf_fpregset_t *fpregsetp)
474 struct gdbarch *gdbarch = get_regcache_arch (regcache);
477 /* See mips_linux_o32_sigframe_init for a description of the
478 peculiar FP register layout. */
479 if (register_size (gdbarch, gdbarch_fp0_regnum (gdbarch)) == 4)
480 for (regi = 0; regi < 32; regi++)
482 const gdb_byte *reg_ptr = (const gdb_byte *)(*fpregsetp + (regi & ~1));
483 if ((gdbarch_byte_order (gdbarch) == BFD_ENDIAN_BIG) != (regi & 1))
485 regcache_raw_supply (regcache,
486 gdbarch_fp0_regnum (gdbarch) + regi,
490 for (regi = 0; regi < 32; regi++)
491 regcache_raw_supply (regcache,
492 gdbarch_fp0_regnum (gdbarch) + regi,
493 (const char *)(*fpregsetp + regi));
495 supply_32bit_reg (regcache, mips_regnum (gdbarch)->fp_control_status,
496 (const gdb_byte *)(*fpregsetp + 32));
498 /* The ABI doesn't tell us how to supply FCRIR, and core dumps don't
499 include it - but the result of PTRACE_GETFPREGS does. The best we
500 can do is to assume that its value is present. */
501 supply_32bit_reg (regcache,
502 mips_regnum (gdbarch)->fp_implementation_revision,
503 (const gdb_byte *)(*fpregsetp + 32) + 4);
507 mips64_supply_fpregset_wrapper (const struct regset *regset,
508 struct regcache *regcache,
509 int regnum, const void *gregs, size_t len)
511 gdb_assert (len == sizeof (mips64_elf_fpregset_t));
513 mips64_supply_fpregset (regcache, (const mips64_elf_fpregset_t *)gregs);
516 /* Likewise, pack one or all floating point registers into an
520 mips64_fill_fpregset (const struct regcache *regcache,
521 mips64_elf_fpregset_t *fpregsetp, int regno)
523 struct gdbarch *gdbarch = get_regcache_arch (regcache);
524 enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
527 if ((regno >= gdbarch_fp0_regnum (gdbarch))
528 && (regno < gdbarch_fp0_regnum (gdbarch) + 32))
530 /* See mips_linux_o32_sigframe_init for a description of the
531 peculiar FP register layout. */
532 if (register_size (gdbarch, regno) == 4)
534 int regi = regno - gdbarch_fp0_regnum (gdbarch);
536 to = (gdb_byte *) (*fpregsetp + (regi & ~1));
537 if ((gdbarch_byte_order (gdbarch) == BFD_ENDIAN_BIG) != (regi & 1))
539 regcache_raw_collect (regcache, regno, to);
543 to = (gdb_byte *) (*fpregsetp + regno
544 - gdbarch_fp0_regnum (gdbarch));
545 regcache_raw_collect (regcache, regno, to);
548 else if (regno == mips_regnum (gdbarch)->fp_control_status)
550 gdb_byte buf[MAX_REGISTER_SIZE];
553 regcache_raw_collect (regcache, regno, buf);
554 val = extract_signed_integer (buf, register_size (gdbarch, regno),
556 to = (gdb_byte *) (*fpregsetp + 32);
557 store_signed_integer (to, 4, byte_order, val);
559 else if (regno == mips_regnum (gdbarch)->fp_implementation_revision)
561 gdb_byte buf[MAX_REGISTER_SIZE];
564 regcache_raw_collect (regcache, regno, buf);
565 val = extract_signed_integer (buf, register_size (gdbarch, regno),
567 to = (gdb_byte *) (*fpregsetp + 32) + 4;
568 store_signed_integer (to, 4, byte_order, val);
570 else if (regno == -1)
574 for (regi = 0; regi < 32; regi++)
575 mips64_fill_fpregset (regcache, fpregsetp,
576 gdbarch_fp0_regnum (gdbarch) + regi);
577 mips64_fill_fpregset (regcache, fpregsetp,
578 mips_regnum (gdbarch)->fp_control_status);
579 mips64_fill_fpregset (regcache, fpregsetp,
580 (mips_regnum (gdbarch)
581 ->fp_implementation_revision));
586 mips64_fill_fpregset_wrapper (const struct regset *regset,
587 const struct regcache *regcache,
588 int regnum, void *gregs, size_t len)
590 gdb_assert (len == sizeof (mips64_elf_fpregset_t));
592 mips64_fill_fpregset (regcache, (mips64_elf_fpregset_t *)gregs, regnum);
595 const struct regset *
596 mips_linux_regset_from_core_section (struct gdbarch *gdbarch,
597 const char *sect_name, size_t sect_size)
599 struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
600 mips_elf_gregset_t gregset;
601 mips_elf_fpregset_t fpregset;
602 mips64_elf_gregset_t gregset64;
603 mips64_elf_fpregset_t fpregset64;
605 if (strcmp (sect_name, ".reg") == 0)
607 if (sect_size == sizeof (gregset))
609 if (tdep->gregset == NULL)
610 tdep->gregset = regset_alloc (gdbarch,
611 mips_supply_gregset_wrapper,
612 mips_fill_gregset_wrapper);
613 return tdep->gregset;
615 else if (sect_size == sizeof (gregset64))
617 if (tdep->gregset64 == NULL)
618 tdep->gregset64 = regset_alloc (gdbarch,
619 mips64_supply_gregset_wrapper,
620 mips64_fill_gregset_wrapper);
621 return tdep->gregset64;
625 warning (_("wrong size gregset struct in core file"));
628 else if (strcmp (sect_name, ".reg2") == 0)
630 if (sect_size == sizeof (fpregset))
632 if (tdep->fpregset == NULL)
633 tdep->fpregset = regset_alloc (gdbarch,
634 mips_supply_fpregset_wrapper,
635 mips_fill_fpregset_wrapper);
636 return tdep->fpregset;
638 else if (sect_size == sizeof (fpregset64))
640 if (tdep->fpregset64 == NULL)
641 tdep->fpregset64 = regset_alloc (gdbarch,
642 mips64_supply_fpregset_wrapper,
643 mips64_fill_fpregset_wrapper);
644 return tdep->fpregset64;
648 warning (_("wrong size fpregset struct in core file"));
655 static const struct target_desc *
656 mips_linux_core_read_description (struct gdbarch *gdbarch,
657 struct target_ops *target,
660 asection *section = bfd_get_section_by_name (abfd, ".reg");
664 switch (bfd_section_size (abfd, section))
666 case sizeof (mips_elf_gregset_t):
667 return mips_tdesc_gp32;
669 case sizeof (mips64_elf_gregset_t):
670 return mips_tdesc_gp64;
678 /* Check the code at PC for a dynamic linker lazy resolution stub.
679 Because they aren't in the .plt section, we pattern-match on the
680 code generated by GNU ld. They look like this:
687 (with the appropriate doubleword instructions for N64). Also
688 return the dynamic symbol index used in the last instruction. */
691 mips_linux_in_dynsym_stub (CORE_ADDR pc, char *name)
693 unsigned char buf[28], *p;
694 ULONGEST insn, insn1;
695 int n64 = (mips_abi (target_gdbarch) == MIPS_ABI_N64);
696 enum bfd_endian byte_order = gdbarch_byte_order (target_gdbarch);
698 read_memory (pc - 12, buf, 28);
702 /* ld t9,0x8010(gp) */
707 /* lw t9,0x8010(gp) */
714 insn = extract_unsigned_integer (p, 4, byte_order);
722 insn = extract_unsigned_integer (p + 4, 4, byte_order);
726 if (insn != 0x03e0782d)
732 if (insn != 0x03e07821)
736 insn = extract_unsigned_integer (p + 8, 4, byte_order);
738 if (insn != 0x0320f809)
741 insn = extract_unsigned_integer (p + 12, 4, byte_order);
744 /* daddiu t8,zero,0 */
745 if ((insn & 0xffff0000) != 0x64180000)
750 /* addiu t8,zero,0 */
751 if ((insn & 0xffff0000) != 0x24180000)
755 return (insn & 0xffff);
758 /* Return non-zero iff PC belongs to the dynamic linker resolution
759 code, a PLT entry, or a lazy binding stub. */
762 mips_linux_in_dynsym_resolve_code (CORE_ADDR pc)
764 /* Check whether PC is in the dynamic linker. This also checks
765 whether it is in the .plt section, used by non-PIC executables. */
766 if (svr4_in_dynsym_resolve_code (pc))
769 /* Pattern match for the stub. It would be nice if there were a
770 more efficient way to avoid this check. */
771 if (mips_linux_in_dynsym_stub (pc, NULL))
777 /* See the comments for SKIP_SOLIB_RESOLVER at the top of infrun.c,
778 and glibc_skip_solib_resolver in glibc-tdep.c. The normal glibc
779 implementation of this triggers at "fixup" from the same objfile as
780 "_dl_runtime_resolve"; MIPS GNU/Linux can trigger at
781 "__dl_runtime_resolve" directly. An unresolved lazy binding
782 stub will point to _dl_runtime_resolve, which will first call
783 __dl_runtime_resolve, and then pass control to the resolved
787 mips_linux_skip_resolver (struct gdbarch *gdbarch, CORE_ADDR pc)
789 struct minimal_symbol *resolver;
791 resolver = lookup_minimal_symbol ("__dl_runtime_resolve", NULL, NULL);
793 if (resolver && SYMBOL_VALUE_ADDRESS (resolver) == pc)
794 return frame_unwind_caller_pc (get_current_frame ());
796 return glibc_skip_solib_resolver (gdbarch, pc);
799 /* Signal trampoline support. There are four supported layouts for a
800 signal frame: o32 sigframe, o32 rt_sigframe, n32 rt_sigframe, and
801 n64 rt_sigframe. We handle them all independently; not the most
802 efficient way, but simplest. First, declare all the unwinders. */
804 static void mips_linux_o32_sigframe_init (const struct tramp_frame *self,
805 struct frame_info *this_frame,
806 struct trad_frame_cache *this_cache,
809 static void mips_linux_n32n64_sigframe_init (const struct tramp_frame *self,
810 struct frame_info *this_frame,
811 struct trad_frame_cache *this_cache,
814 #define MIPS_NR_LINUX 4000
815 #define MIPS_NR_N64_LINUX 5000
816 #define MIPS_NR_N32_LINUX 6000
818 #define MIPS_NR_sigreturn MIPS_NR_LINUX + 119
819 #define MIPS_NR_rt_sigreturn MIPS_NR_LINUX + 193
820 #define MIPS_NR_N64_rt_sigreturn MIPS_NR_N64_LINUX + 211
821 #define MIPS_NR_N32_rt_sigreturn MIPS_NR_N32_LINUX + 211
823 #define MIPS_INST_LI_V0_SIGRETURN 0x24020000 + MIPS_NR_sigreturn
824 #define MIPS_INST_LI_V0_RT_SIGRETURN 0x24020000 + MIPS_NR_rt_sigreturn
825 #define MIPS_INST_LI_V0_N64_RT_SIGRETURN 0x24020000 + MIPS_NR_N64_rt_sigreturn
826 #define MIPS_INST_LI_V0_N32_RT_SIGRETURN 0x24020000 + MIPS_NR_N32_rt_sigreturn
827 #define MIPS_INST_SYSCALL 0x0000000c
829 static const struct tramp_frame mips_linux_o32_sigframe = {
833 { MIPS_INST_LI_V0_SIGRETURN, -1 },
834 { MIPS_INST_SYSCALL, -1 },
835 { TRAMP_SENTINEL_INSN, -1 }
837 mips_linux_o32_sigframe_init
840 static const struct tramp_frame mips_linux_o32_rt_sigframe = {
844 { MIPS_INST_LI_V0_RT_SIGRETURN, -1 },
845 { MIPS_INST_SYSCALL, -1 },
846 { TRAMP_SENTINEL_INSN, -1 } },
847 mips_linux_o32_sigframe_init
850 static const struct tramp_frame mips_linux_n32_rt_sigframe = {
854 { MIPS_INST_LI_V0_N32_RT_SIGRETURN, -1 },
855 { MIPS_INST_SYSCALL, -1 },
856 { TRAMP_SENTINEL_INSN, -1 }
858 mips_linux_n32n64_sigframe_init
861 static const struct tramp_frame mips_linux_n64_rt_sigframe = {
865 { MIPS_INST_LI_V0_N64_RT_SIGRETURN, -1 },
866 { MIPS_INST_SYSCALL, -1 },
867 { TRAMP_SENTINEL_INSN, -1 }
869 mips_linux_n32n64_sigframe_init
873 /* The unwinder for o32 signal frames. The legacy structures look
877 u32 sf_ass[4]; [argument save space for o32]
878 u32 sf_code[2]; [signal trampoline or fill]
879 struct sigcontext sf_sc;
884 unsigned int sc_regmask; [Unused]
885 unsigned int sc_status;
886 unsigned long long sc_pc;
887 unsigned long long sc_regs[32];
888 unsigned long long sc_fpregs[32];
889 unsigned int sc_ownedfp;
890 unsigned int sc_fpc_csr;
891 unsigned int sc_fpc_eir; [Unused]
892 unsigned int sc_used_math;
893 unsigned int sc_ssflags; [Unused]
894 [Alignment hole of four bytes]
895 unsigned long long sc_mdhi;
896 unsigned long long sc_mdlo;
898 unsigned int sc_cause; [Unused]
899 unsigned int sc_badvaddr; [Unused]
901 unsigned long sc_sigset[4]; [kernel's sigset_t]
904 The RT signal frames look like this:
907 u32 rs_ass[4]; [argument save space for o32]
908 u32 rs_code[2] [signal trampoline or fill]
909 struct siginfo rs_info;
910 struct ucontext rs_uc;
914 unsigned long uc_flags;
915 struct ucontext *uc_link;
917 [Alignment hole of four bytes]
918 struct sigcontext uc_mcontext;
923 #define SIGFRAME_SIGCONTEXT_OFFSET (6 * 4)
925 #define RTSIGFRAME_SIGINFO_SIZE 128
926 #define STACK_T_SIZE (3 * 4)
927 #define UCONTEXT_SIGCONTEXT_OFFSET (2 * 4 + STACK_T_SIZE + 4)
928 #define RTSIGFRAME_SIGCONTEXT_OFFSET (SIGFRAME_SIGCONTEXT_OFFSET \
929 + RTSIGFRAME_SIGINFO_SIZE \
930 + UCONTEXT_SIGCONTEXT_OFFSET)
932 #define SIGCONTEXT_PC (1 * 8)
933 #define SIGCONTEXT_REGS (2 * 8)
934 #define SIGCONTEXT_FPREGS (34 * 8)
935 #define SIGCONTEXT_FPCSR (66 * 8 + 4)
936 #define SIGCONTEXT_HI (69 * 8)
937 #define SIGCONTEXT_LO (70 * 8)
938 #define SIGCONTEXT_CAUSE (71 * 8 + 0)
939 #define SIGCONTEXT_BADVADDR (71 * 8 + 4)
941 #define SIGCONTEXT_REG_SIZE 8
944 mips_linux_o32_sigframe_init (const struct tramp_frame *self,
945 struct frame_info *this_frame,
946 struct trad_frame_cache *this_cache,
949 struct gdbarch *gdbarch = get_frame_arch (this_frame);
950 int ireg, reg_position;
951 CORE_ADDR frame_sp = get_frame_sp (this_frame);
952 CORE_ADDR sigcontext_base;
953 const struct mips_regnum *regs = mips_regnum (gdbarch);
956 if (self == &mips_linux_o32_sigframe)
957 sigcontext_base = frame_sp + SIGFRAME_SIGCONTEXT_OFFSET;
959 sigcontext_base = frame_sp + RTSIGFRAME_SIGCONTEXT_OFFSET;
961 /* I'm not proud of this hack. Eventually we will have the
962 infrastructure to indicate the size of saved registers on a
963 per-frame basis, but right now we don't; the kernel saves eight
964 bytes but we only want four. Use regs_base to access any
966 if (gdbarch_byte_order (gdbarch) == BFD_ENDIAN_BIG)
967 regs_base = sigcontext_base + 4;
969 regs_base = sigcontext_base;
971 if (mips_linux_restart_reg_p (gdbarch))
972 trad_frame_set_reg_addr (this_cache,
974 + gdbarch_num_regs (gdbarch)),
975 regs_base + SIGCONTEXT_REGS);
977 for (ireg = 1; ireg < 32; ireg++)
978 trad_frame_set_reg_addr (this_cache,
979 ireg + MIPS_ZERO_REGNUM
980 + gdbarch_num_regs (gdbarch),
981 regs_base + SIGCONTEXT_REGS
982 + ireg * SIGCONTEXT_REG_SIZE);
984 /* The way that floating point registers are saved, unfortunately,
985 depends on the architecture the kernel is built for. For the r3000 and
986 tx39, four bytes of each register are at the beginning of each of the
987 32 eight byte slots. For everything else, the registers are saved
988 using double precision; only the even-numbered slots are initialized,
989 and the high bits are the odd-numbered register. Assume the latter
990 layout, since we can't tell, and it's much more common. Which bits are
991 the "high" bits depends on endianness. */
992 for (ireg = 0; ireg < 32; ireg++)
993 if ((gdbarch_byte_order (gdbarch) == BFD_ENDIAN_BIG) != (ireg & 1))
994 trad_frame_set_reg_addr (this_cache,
996 gdbarch_num_regs (gdbarch),
997 sigcontext_base + SIGCONTEXT_FPREGS + 4
998 + (ireg & ~1) * SIGCONTEXT_REG_SIZE);
1000 trad_frame_set_reg_addr (this_cache,
1002 + gdbarch_num_regs (gdbarch),
1003 sigcontext_base + SIGCONTEXT_FPREGS
1004 + (ireg & ~1) * SIGCONTEXT_REG_SIZE);
1006 trad_frame_set_reg_addr (this_cache,
1007 regs->pc + gdbarch_num_regs (gdbarch),
1008 regs_base + SIGCONTEXT_PC);
1010 trad_frame_set_reg_addr (this_cache,
1011 regs->fp_control_status
1012 + gdbarch_num_regs (gdbarch),
1013 sigcontext_base + SIGCONTEXT_FPCSR);
1014 trad_frame_set_reg_addr (this_cache,
1015 regs->hi + gdbarch_num_regs (gdbarch),
1016 regs_base + SIGCONTEXT_HI);
1017 trad_frame_set_reg_addr (this_cache,
1018 regs->lo + gdbarch_num_regs (gdbarch),
1019 regs_base + SIGCONTEXT_LO);
1020 trad_frame_set_reg_addr (this_cache,
1021 regs->cause + gdbarch_num_regs (gdbarch),
1022 sigcontext_base + SIGCONTEXT_CAUSE);
1023 trad_frame_set_reg_addr (this_cache,
1024 regs->badvaddr + gdbarch_num_regs (gdbarch),
1025 sigcontext_base + SIGCONTEXT_BADVADDR);
1027 /* Choice of the bottom of the sigframe is somewhat arbitrary. */
1028 trad_frame_set_id (this_cache, frame_id_build (frame_sp, func));
1032 /* For N32/N64 things look different. There is no non-rt signal frame.
1034 struct rt_sigframe_n32 {
1035 u32 rs_ass[4]; [ argument save space for o32 ]
1036 u32 rs_code[2]; [ signal trampoline or fill ]
1037 struct siginfo rs_info;
1038 struct ucontextn32 rs_uc;
1041 struct ucontextn32 {
1045 struct sigcontext uc_mcontext;
1046 sigset_t uc_sigmask; [ mask last for extensibility ]
1049 struct rt_sigframe {
1050 u32 rs_ass[4]; [ argument save space for o32 ]
1051 u32 rs_code[2]; [ signal trampoline ]
1052 struct siginfo rs_info;
1053 struct ucontext rs_uc;
1057 unsigned long uc_flags;
1058 struct ucontext *uc_link;
1060 struct sigcontext uc_mcontext;
1061 sigset_t uc_sigmask; [ mask last for extensibility ]
1064 And the sigcontext is different (this is for both n32 and n64):
1067 unsigned long long sc_regs[32];
1068 unsigned long long sc_fpregs[32];
1069 unsigned long long sc_mdhi;
1070 unsigned long long sc_hi1;
1071 unsigned long long sc_hi2;
1072 unsigned long long sc_hi3;
1073 unsigned long long sc_mdlo;
1074 unsigned long long sc_lo1;
1075 unsigned long long sc_lo2;
1076 unsigned long long sc_lo3;
1077 unsigned long long sc_pc;
1078 unsigned int sc_fpc_csr;
1079 unsigned int sc_used_math;
1080 unsigned int sc_dsp;
1081 unsigned int sc_reserved;
1084 That is the post-2.6.12 definition of the 64-bit sigcontext; before
1085 then, there were no hi1-hi3 or lo1-lo3. Cause and badvaddr were
1089 #define N32_STACK_T_SIZE STACK_T_SIZE
1090 #define N64_STACK_T_SIZE (2 * 8 + 4)
1091 #define N32_UCONTEXT_SIGCONTEXT_OFFSET (2 * 4 + N32_STACK_T_SIZE + 4)
1092 #define N64_UCONTEXT_SIGCONTEXT_OFFSET (2 * 8 + N64_STACK_T_SIZE + 4)
1093 #define N32_SIGFRAME_SIGCONTEXT_OFFSET (SIGFRAME_SIGCONTEXT_OFFSET \
1094 + RTSIGFRAME_SIGINFO_SIZE \
1095 + N32_UCONTEXT_SIGCONTEXT_OFFSET)
1096 #define N64_SIGFRAME_SIGCONTEXT_OFFSET (SIGFRAME_SIGCONTEXT_OFFSET \
1097 + RTSIGFRAME_SIGINFO_SIZE \
1098 + N64_UCONTEXT_SIGCONTEXT_OFFSET)
1100 #define N64_SIGCONTEXT_REGS (0 * 8)
1101 #define N64_SIGCONTEXT_FPREGS (32 * 8)
1102 #define N64_SIGCONTEXT_HI (64 * 8)
1103 #define N64_SIGCONTEXT_LO (68 * 8)
1104 #define N64_SIGCONTEXT_PC (72 * 8)
1105 #define N64_SIGCONTEXT_FPCSR (73 * 8)
1107 #define N64_SIGCONTEXT_REG_SIZE 8
1110 mips_linux_n32n64_sigframe_init (const struct tramp_frame *self,
1111 struct frame_info *this_frame,
1112 struct trad_frame_cache *this_cache,
1115 struct gdbarch *gdbarch = get_frame_arch (this_frame);
1116 int ireg, reg_position;
1117 CORE_ADDR frame_sp = get_frame_sp (this_frame);
1118 CORE_ADDR sigcontext_base;
1119 const struct mips_regnum *regs = mips_regnum (gdbarch);
1121 if (self == &mips_linux_n32_rt_sigframe)
1122 sigcontext_base = frame_sp + N32_SIGFRAME_SIGCONTEXT_OFFSET;
1124 sigcontext_base = frame_sp + N64_SIGFRAME_SIGCONTEXT_OFFSET;
1126 if (mips_linux_restart_reg_p (gdbarch))
1127 trad_frame_set_reg_addr (this_cache,
1128 (MIPS_RESTART_REGNUM
1129 + gdbarch_num_regs (gdbarch)),
1130 sigcontext_base + N64_SIGCONTEXT_REGS);
1132 for (ireg = 1; ireg < 32; ireg++)
1133 trad_frame_set_reg_addr (this_cache,
1134 ireg + MIPS_ZERO_REGNUM
1135 + gdbarch_num_regs (gdbarch),
1136 sigcontext_base + N64_SIGCONTEXT_REGS
1137 + ireg * N64_SIGCONTEXT_REG_SIZE);
1139 for (ireg = 0; ireg < 32; ireg++)
1140 trad_frame_set_reg_addr (this_cache,
1142 + gdbarch_num_regs (gdbarch),
1143 sigcontext_base + N64_SIGCONTEXT_FPREGS
1144 + ireg * N64_SIGCONTEXT_REG_SIZE);
1146 trad_frame_set_reg_addr (this_cache,
1147 regs->pc + gdbarch_num_regs (gdbarch),
1148 sigcontext_base + N64_SIGCONTEXT_PC);
1150 trad_frame_set_reg_addr (this_cache,
1151 regs->fp_control_status
1152 + gdbarch_num_regs (gdbarch),
1153 sigcontext_base + N64_SIGCONTEXT_FPCSR);
1154 trad_frame_set_reg_addr (this_cache,
1155 regs->hi + gdbarch_num_regs (gdbarch),
1156 sigcontext_base + N64_SIGCONTEXT_HI);
1157 trad_frame_set_reg_addr (this_cache,
1158 regs->lo + gdbarch_num_regs (gdbarch),
1159 sigcontext_base + N64_SIGCONTEXT_LO);
1161 /* Choice of the bottom of the sigframe is somewhat arbitrary. */
1162 trad_frame_set_id (this_cache, frame_id_build (frame_sp, func));
1166 mips_linux_write_pc (struct regcache *regcache, CORE_ADDR pc)
1168 struct gdbarch *gdbarch = get_regcache_arch (regcache);
1169 regcache_cooked_write_unsigned (regcache, gdbarch_pc_regnum (gdbarch), pc);
1171 /* Clear the syscall restart flag. */
1172 if (mips_linux_restart_reg_p (gdbarch))
1173 regcache_cooked_write_unsigned (regcache, MIPS_RESTART_REGNUM, 0);
1176 /* Return 1 if MIPS_RESTART_REGNUM is usable. */
1179 mips_linux_restart_reg_p (struct gdbarch *gdbarch)
1181 /* If we do not have a target description with registers, then
1182 MIPS_RESTART_REGNUM will not be included in the register set. */
1183 if (!tdesc_has_registers (gdbarch_target_desc (gdbarch)))
1186 /* If we do, then MIPS_RESTART_REGNUM is safe to check; it will
1187 either be GPR-sized or missing. */
1188 return register_size (gdbarch, MIPS_RESTART_REGNUM) > 0;
1191 /* When FRAME is at a syscall instruction, return the PC of the next
1192 instruction to be executed. */
1195 mips_linux_syscall_next_pc (struct frame_info *frame)
1197 CORE_ADDR pc = get_frame_pc (frame);
1198 ULONGEST v0 = get_frame_register_unsigned (frame, MIPS_V0_REGNUM);
1200 /* If we are about to make a sigreturn syscall, use the unwinder to
1201 decode the signal frame. */
1202 if (v0 == MIPS_NR_sigreturn
1203 || v0 == MIPS_NR_rt_sigreturn
1204 || v0 == MIPS_NR_N64_rt_sigreturn
1205 || v0 == MIPS_NR_N32_rt_sigreturn)
1206 return frame_unwind_caller_pc (get_current_frame ());
1211 /* Return the current system call's number present in the
1212 v0 register. When the function fails, it returns -1. */
1215 mips_linux_get_syscall_number (struct gdbarch *gdbarch,
1218 struct regcache *regcache = get_thread_regcache (ptid);
1219 struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
1220 enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
1221 int regsize = register_size (gdbarch, MIPS_V0_REGNUM);
1222 /* The content of a register */
1227 /* Make sure we're in a known ABI */
1228 gdb_assert (tdep->mips_abi == MIPS_ABI_O32
1229 || tdep->mips_abi == MIPS_ABI_N32
1230 || tdep->mips_abi == MIPS_ABI_N64);
1232 gdb_assert (regsize <= sizeof (buf));
1234 /* Getting the system call number from the register.
1235 syscall number is in v0 or $2. */
1236 regcache_cooked_read (regcache, MIPS_V0_REGNUM, buf);
1238 ret = extract_signed_integer (buf, regsize, byte_order);
1243 /* Initialize one of the GNU/Linux OS ABIs. */
1246 mips_linux_init_abi (struct gdbarch_info info,
1247 struct gdbarch *gdbarch)
1249 struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
1250 enum mips_abi abi = mips_abi (gdbarch);
1251 struct tdesc_arch_data *tdesc_data = (void *) info.tdep_info;
1253 linux_init_abi (info, gdbarch);
1255 /* Get the syscall number from the arch's register. */
1256 set_gdbarch_get_syscall_number (gdbarch, mips_linux_get_syscall_number);
1261 set_gdbarch_get_longjmp_target (gdbarch,
1262 mips_linux_get_longjmp_target);
1263 set_solib_svr4_fetch_link_map_offsets
1264 (gdbarch, svr4_ilp32_fetch_link_map_offsets);
1265 tramp_frame_prepend_unwinder (gdbarch, &mips_linux_o32_sigframe);
1266 tramp_frame_prepend_unwinder (gdbarch, &mips_linux_o32_rt_sigframe);
1267 set_xml_syscall_file_name ("syscalls/mips-o32-linux.xml");
1270 set_gdbarch_get_longjmp_target (gdbarch,
1271 mips_linux_get_longjmp_target);
1272 set_solib_svr4_fetch_link_map_offsets
1273 (gdbarch, svr4_ilp32_fetch_link_map_offsets);
1274 set_gdbarch_long_double_bit (gdbarch, 128);
1275 /* These floatformats should probably be renamed. MIPS uses
1276 the same 128-bit IEEE floating point format that IA-64 uses,
1277 except that the quiet/signalling NaN bit is reversed (GDB
1278 does not distinguish between quiet and signalling NaNs). */
1279 set_gdbarch_long_double_format (gdbarch, floatformats_ia64_quad);
1280 tramp_frame_prepend_unwinder (gdbarch, &mips_linux_n32_rt_sigframe);
1281 set_xml_syscall_file_name ("syscalls/mips-n32-linux.xml");
1284 set_gdbarch_get_longjmp_target (gdbarch,
1285 mips64_linux_get_longjmp_target);
1286 set_solib_svr4_fetch_link_map_offsets
1287 (gdbarch, svr4_lp64_fetch_link_map_offsets);
1288 set_gdbarch_long_double_bit (gdbarch, 128);
1289 /* These floatformats should probably be renamed. MIPS uses
1290 the same 128-bit IEEE floating point format that IA-64 uses,
1291 except that the quiet/signalling NaN bit is reversed (GDB
1292 does not distinguish between quiet and signalling NaNs). */
1293 set_gdbarch_long_double_format (gdbarch, floatformats_ia64_quad);
1294 tramp_frame_prepend_unwinder (gdbarch, &mips_linux_n64_rt_sigframe);
1295 set_xml_syscall_file_name ("syscalls/mips-n64-linux.xml");
1301 set_gdbarch_skip_solib_resolver (gdbarch, mips_linux_skip_resolver);
1303 set_gdbarch_software_single_step (gdbarch, mips_software_single_step);
1305 /* Enable TLS support. */
1306 set_gdbarch_fetch_tls_load_module_address (gdbarch,
1307 svr4_fetch_objfile_link_map);
1309 /* Initialize this lazily, to avoid an initialization order
1310 dependency on solib-svr4.c's _initialize routine. */
1311 if (mips_svr4_so_ops.in_dynsym_resolve_code == NULL)
1313 mips_svr4_so_ops = svr4_so_ops;
1314 mips_svr4_so_ops.in_dynsym_resolve_code
1315 = mips_linux_in_dynsym_resolve_code;
1317 set_solib_ops (gdbarch, &mips_svr4_so_ops);
1319 set_gdbarch_write_pc (gdbarch, mips_linux_write_pc);
1321 set_gdbarch_core_read_description (gdbarch,
1322 mips_linux_core_read_description);
1324 set_gdbarch_regset_from_core_section (gdbarch,
1325 mips_linux_regset_from_core_section);
1327 tdep->syscall_next_pc = mips_linux_syscall_next_pc;
1331 const struct tdesc_feature *feature;
1333 /* If we have target-described registers, then we can safely
1334 reserve a number for MIPS_RESTART_REGNUM (whether it is
1335 described or not). */
1336 gdb_assert (gdbarch_num_regs (gdbarch) <= MIPS_RESTART_REGNUM);
1337 set_gdbarch_num_regs (gdbarch, MIPS_RESTART_REGNUM + 1);
1339 /* If it's present, then assign it to the reserved number. */
1340 feature = tdesc_find_feature (info.target_desc,
1341 "org.gnu.gdb.mips.linux");
1342 if (feature != NULL)
1343 tdesc_numbered_register (feature, tdesc_data, MIPS_RESTART_REGNUM,
1348 /* Provide a prototype to silence -Wmissing-prototypes. */
1349 extern initialize_file_ftype _initialize_mips_linux_tdep;
1352 _initialize_mips_linux_tdep (void)
1354 const struct bfd_arch_info *arch_info;
1356 for (arch_info = bfd_lookup_arch (bfd_arch_mips, 0);
1358 arch_info = arch_info->next)
1360 gdbarch_register_osabi (bfd_arch_mips, arch_info->mach,
1362 mips_linux_init_abi);