]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blame - gdb/amd64-windows-tdep.c
amd64-windows: memory args passed by pointer during function calls.
[thirdparty/binutils-gdb.git] / gdb / amd64-windows-tdep.c
CommitLineData
4c38e0a4 1/* Copyright (C) 2009, 2010 Free Software Foundation, Inc.
d0761299
JB
2
3 This file is part of GDB.
4
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 3 of the License, or
8 (at your option) any later version.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>. */
17
18#include "defs.h"
19#include "osabi.h"
20#include "amd64-tdep.h"
21#include "solib.h"
22#include "solib-target.h"
ba581dc1
JB
23#include "gdbtypes.h"
24
25/* The registers used to pass integer arguments during a function call. */
26static int amd64_windows_dummy_call_integer_regs[] =
27{
28 AMD64_RCX_REGNUM, /* %rcx */
29 AMD64_RDX_REGNUM, /* %rdx */
30 8, /* %r8 */
31 9 /* %r9 */
32};
33
34/* Implement the "classify" method in the gdbarch_tdep structure
35 for amd64-windows. */
36
37static void
38amd64_windows_classify (struct type *type, enum amd64_reg_class class[2])
39{
40 switch (TYPE_CODE (type))
41 {
42 case TYPE_CODE_ARRAY:
43 /* Arrays are always passed by memory. */
44 class[0] = class[1] = AMD64_MEMORY;
45 break;
46
47 case TYPE_CODE_STRUCT:
48 case TYPE_CODE_UNION:
49 /* Struct/Union types whose size is 1, 2, 4, or 8 bytes
50 are passed as if they were integers of the same size.
51 Types of different sizes are passed by memory. */
52 if (TYPE_LENGTH (type) == 1
53 || TYPE_LENGTH (type) == 2
54 || TYPE_LENGTH (type) == 4
55 || TYPE_LENGTH (type) == 8)
56 {
57 class[0] = AMD64_INTEGER;
58 class[1] = AMD64_NO_CLASS;
59 }
60 else
61 class[0] = class[1] = AMD64_MEMORY;
62 break;
63
64 default:
65 /* For all the other types, the conventions are the same as
66 with the System V ABI. */
67 amd64_classify (type, class);
68 }
69}
d0761299
JB
70
71static void
72amd64_windows_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
73{
ba581dc1
JB
74 struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
75
d0761299
JB
76 amd64_init_abi (info, gdbarch);
77
78 /* On Windows, "long"s are only 32bit. */
79 set_gdbarch_long_bit (gdbarch, 32);
80
ba581dc1
JB
81 /* Function calls. */
82 tdep->call_dummy_num_integer_regs =
83 ARRAY_SIZE (amd64_windows_dummy_call_integer_regs);
84 tdep->call_dummy_integer_regs = amd64_windows_dummy_call_integer_regs;
85 tdep->classify = amd64_windows_classify;
80d19a06 86 tdep->memory_args_by_pointer = 1;
ba581dc1 87
d0761299
JB
88 set_solib_ops (gdbarch, &solib_target_so_ops);
89}
90
91void
92_initialize_amd64_windows_tdep (void)
93{
94 gdbarch_register_osabi (bfd_arch_i386, bfd_mach_x86_64, GDB_OSABI_CYGWIN,
95 amd64_windows_init_abi);
96}
97