x86: Move x86-specific linker options to elf_linker_x86_params
[deliverable/binutils-gdb.git] / gdb / amd64-sol2-tdep.c
CommitLineData
0bbc026e
JM
1/* Target-dependent code for AMD64 Solaris.
2
42a4f53d 3 Copyright (C) 2001-2019 Free Software Foundation, Inc.
081bf9da 4
0bbc026e
JM
5 Contributed by Joseph Myers, CodeSourcery, LLC.
6
7 This file is part of GDB.
8
9 This program is free software; you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
a9762ec7 11 the Free Software Foundation; either version 3 of the License, or
0bbc026e
JM
12 (at your option) any later version.
13
14 This program is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
18
19 You should have received a copy of the GNU General Public License
a9762ec7 20 along with this program. If not, see <http://www.gnu.org/licenses/>. */
0bbc026e
JM
21
22#include "defs.h"
d55e5aa6
TT
23
24/* Local non-gdb includes. */
25#include "amd64-tdep.h"
26#include "common/x86-xstate.h"
0bbc026e
JM
27#include "frame.h"
28#include "gdbcore.h"
0bbc026e 29#include "osabi.h"
d55e5aa6 30#include "regcache.h"
081bf9da 31#include "sol2-tdep.h"
0bbc026e 32#include "solib-svr4.h"
d55e5aa6 33#include "symtab.h"
0bbc026e
JM
34
35/* Mapping between the general-purpose registers in gregset_t format
36 and GDB's register cache layout. */
37
38/* From <sys/regset.h>. */
39static int amd64_sol2_gregset_reg_offset[] = {
40 14 * 8, /* %rax */
41 11 * 8, /* %rbx */
42 13 * 8, /* %rcx */
43 12 * 8, /* %rdx */
44 9 * 8, /* %rsi */
45 8 * 8, /* %rdi */
46 10 * 8, /* %rbp */
47 20 * 8, /* %rsp */
0963b4bd 48 7 * 8, /* %r8 ... */
0bbc026e
JM
49 6 * 8,
50 5 * 8,
51 4 * 8,
52 3 * 8,
53 2 * 8,
54 1 * 8,
55 0 * 8, /* ... %r15 */
56 17 * 8, /* %rip */
c71bb1cf 57 19 * 8, /* %eflags */
0bbc026e
JM
58 18 * 8, /* %cs */
59 21 * 8, /* %ss */
60 25 * 8, /* %ds */
61 24 * 8, /* %es */
62 22 * 8, /* %fs */
63 23 * 8 /* %gs */
64};
65\f
66
10458914
DJ
67/* Return whether THIS_FRAME corresponds to a Solaris sigtramp
68 routine. */
0bbc026e
JM
69
70static int
10458914 71amd64_sol2_sigtramp_p (struct frame_info *this_frame)
0bbc026e 72{
10458914 73 CORE_ADDR pc = get_frame_pc (this_frame);
2c02bd72 74 const char *name;
0bbc026e
JM
75
76 find_pc_partial_function (pc, &name, NULL, NULL);
77 return (name && (strcmp ("sigacthandler", name) == 0
1db88d22
RO
78 || strcmp (name, "ucbsigvechandler") == 0
79 || strcmp (name, "__sighndlr") == 0));
0bbc026e
JM
80}
81
82/* Solaris doesn't have a 'struct sigcontext', but it does have a
83 'mcontext_t' that contains the saved set of machine registers. */
84
85static CORE_ADDR
10458914 86amd64_sol2_mcontext_addr (struct frame_info *this_frame)
0bbc026e
JM
87{
88 CORE_ADDR sp, ucontext_addr;
89
10458914
DJ
90 sp = get_frame_register_unsigned (this_frame, AMD64_RSP_REGNUM);
91 ucontext_addr = get_frame_memory_unsigned (this_frame, sp + 8, 8);
0bbc026e
JM
92
93 return ucontext_addr + 72;
94}
95
96static void
97amd64_sol2_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
98{
99 struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
100
101 tdep->gregset_reg_offset = amd64_sol2_gregset_reg_offset;
102 tdep->gregset_num_regs = ARRAY_SIZE (amd64_sol2_gregset_reg_offset);
103 tdep->sizeof_gregset = 28 * 8;
104
2434b019 105 amd64_init_abi (info, gdbarch,
41206e32 106 amd64_target_description (X86_XSTATE_SSE_MASK, true));
0bbc026e
JM
107
108 tdep->sigtramp_p = amd64_sol2_sigtramp_p;
109 tdep->sigcontext_addr = amd64_sol2_mcontext_addr;
110 tdep->sc_reg_offset = tdep->gregset_reg_offset;
111 tdep->sc_num_regs = tdep->gregset_num_regs;
112
113 /* Solaris uses SVR4-style shared libraries. */
081bf9da 114 set_gdbarch_skip_solib_resolver (gdbarch, sol2_skip_solib_resolver);
0bbc026e
JM
115 set_solib_svr4_fetch_link_map_offsets
116 (gdbarch, svr4_lp64_fetch_link_map_offsets);
959b8724 117
28439f5e
PA
118 /* How to print LWP PTIDs from core files. */
119 set_gdbarch_core_pid_to_str (gdbarch, sol2_core_pid_to_str);
0bbc026e 120}
0bbc026e
JM
121
122void
123_initialize_amd64_sol2_tdep (void)
124{
125 gdbarch_register_osabi (bfd_arch_i386, bfd_mach_x86_64,
126 GDB_OSABI_SOLARIS, amd64_sol2_init_abi);
127}
This page took 0.821174 seconds and 4 git commands to generate.