Commit | Line | Data |
---|---|---|
7b112f9c JT |
1 | /* Target-dependent code for PowerPC systems using the SVR4 ABI |
2 | for GDB, the GNU debugger. | |
3 | ||
6066c3de | 4 | Copyright 2000, 2001, 2002, 2003 Free Software Foundation, Inc. |
7b112f9c JT |
5 | |
6 | This file is part of GDB. | |
7 | ||
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 2 of the License, or | |
11 | (at your option) any later version. | |
12 | ||
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. | |
17 | ||
18 | You should have received a copy of the GNU General Public License | |
19 | along with this program; if not, write to the Free Software | |
20 | Foundation, Inc., 59 Temple Place - Suite 330, | |
21 | Boston, MA 02111-1307, USA. */ | |
22 | ||
23 | #include "defs.h" | |
24 | #include "gdbcore.h" | |
25 | #include "inferior.h" | |
26 | #include "regcache.h" | |
27 | #include "value.h" | |
bdf64bac | 28 | #include "gdb_string.h" |
8be9034a | 29 | #include "gdb_assert.h" |
7b112f9c | 30 | #include "ppc-tdep.h" |
6066c3de | 31 | #include "target.h" |
0a90bcdd | 32 | #include "objfiles.h" |
7b112f9c | 33 | |
7b112f9c JT |
34 | /* Pass the arguments in either registers, or in the stack. Using the |
35 | ppc sysv ABI, the first eight words of the argument list (that might | |
36 | be less than eight parameters if some parameters occupy more than one | |
37 | word) are passed in r3..r10 registers. float and double parameters are | |
38 | passed in fpr's, in addition to that. Rest of the parameters if any | |
39 | are passed in user stack. | |
40 | ||
41 | If the function is returning a structure, then the return address is passed | |
42 | in r3, then the first 7 words of the parametes can be passed in registers, | |
43 | starting from r4. */ | |
44 | ||
45 | CORE_ADDR | |
77b2b6d4 AC |
46 | ppc_sysv_abi_push_dummy_call (struct gdbarch *gdbarch, CORE_ADDR func_addr, |
47 | struct regcache *regcache, CORE_ADDR bp_addr, | |
48 | int nargs, struct value **args, CORE_ADDR sp, | |
49 | int struct_return, CORE_ADDR struct_addr) | |
7b112f9c | 50 | { |
0a613259 | 51 | struct gdbarch_tdep *tdep = gdbarch_tdep (current_gdbarch); |
68856ea3 AC |
52 | const CORE_ADDR saved_sp = read_sp (); |
53 | int argspace = 0; /* 0 is an initial wrong guess. */ | |
54 | int write_pass; | |
7b112f9c | 55 | |
68856ea3 | 56 | /* Go through the argument list twice. |
7b112f9c | 57 | |
68856ea3 AC |
58 | Pass 1: Figure out how much new stack space is required for |
59 | arguments and pushed values. Unlike the PowerOpen ABI, the SysV | |
60 | ABI doesn't reserve any extra space for parameters which are put | |
61 | in registers, but does always push structures and then pass their | |
62 | address. | |
7a41266b | 63 | |
68856ea3 AC |
64 | Pass 2: Replay the same computation but this time also write the |
65 | values out to the target. */ | |
7b112f9c | 66 | |
68856ea3 AC |
67 | for (write_pass = 0; write_pass < 2; write_pass++) |
68 | { | |
69 | int argno; | |
70 | /* Next available floating point register for float and double | |
71 | arguments. */ | |
72 | int freg = 1; | |
73 | /* Next available general register for non-float, non-vector | |
74 | arguments. */ | |
75 | int greg = 3; | |
76 | /* Next available vector register for vector arguments. */ | |
77 | int vreg = 2; | |
78 | /* Arguments start above the "LR save word" and "Back chain". */ | |
79 | int argoffset = 2 * tdep->wordsize; | |
80 | /* Structures start after the arguments. */ | |
81 | int structoffset = argoffset + argspace; | |
82 | ||
83 | /* If the function is returning a `struct', then the first word | |
944fcfab AC |
84 | (which will be passed in r3) is used for struct return |
85 | address. In that case we should advance one word and start | |
86 | from r4 register to copy parameters. */ | |
68856ea3 | 87 | if (struct_return) |
7b112f9c | 88 | { |
68856ea3 AC |
89 | if (write_pass) |
90 | regcache_cooked_write_signed (regcache, | |
91 | tdep->ppc_gp0_regnum + greg, | |
92 | struct_addr); | |
93 | greg++; | |
7b112f9c | 94 | } |
68856ea3 AC |
95 | |
96 | for (argno = 0; argno < nargs; argno++) | |
7b112f9c | 97 | { |
68856ea3 AC |
98 | struct value *arg = args[argno]; |
99 | struct type *type = check_typedef (VALUE_TYPE (arg)); | |
100 | int len = TYPE_LENGTH (type); | |
101 | char *val = VALUE_CONTENTS (arg); | |
102 | ||
103 | if (TYPE_CODE (type) == TYPE_CODE_FLT | |
944fcfab | 104 | && ppc_floating_point_unit_p (current_gdbarch) && len <= 8) |
7b112f9c | 105 | { |
68856ea3 | 106 | /* Floating point value converted to "double" then |
944fcfab AC |
107 | passed in an FP register, when the registers run out, |
108 | 8 byte aligned stack is used. */ | |
68856ea3 AC |
109 | if (freg <= 8) |
110 | { | |
111 | if (write_pass) | |
112 | { | |
113 | /* Always store the floating point value using | |
944fcfab | 114 | the register's floating-point format. */ |
68856ea3 AC |
115 | char regval[MAX_REGISTER_SIZE]; |
116 | struct type *regtype | |
117 | = register_type (gdbarch, FP0_REGNUM + freg); | |
118 | convert_typed_floating (val, type, regval, regtype); | |
119 | regcache_cooked_write (regcache, FP0_REGNUM + freg, | |
120 | regval); | |
121 | } | |
122 | freg++; | |
123 | } | |
7b112f9c JT |
124 | else |
125 | { | |
68856ea3 | 126 | /* SysV ABI converts floats to doubles before |
944fcfab | 127 | writing them to an 8 byte aligned stack location. */ |
68856ea3 AC |
128 | argoffset = align_up (argoffset, 8); |
129 | if (write_pass) | |
130 | { | |
131 | char memval[8]; | |
132 | struct type *memtype; | |
133 | switch (TARGET_BYTE_ORDER) | |
134 | { | |
135 | case BFD_ENDIAN_BIG: | |
136 | memtype = builtin_type_ieee_double_big; | |
137 | break; | |
138 | case BFD_ENDIAN_LITTLE: | |
139 | memtype = builtin_type_ieee_double_little; | |
140 | break; | |
141 | default: | |
142 | internal_error (__FILE__, __LINE__, "bad switch"); | |
143 | } | |
144 | convert_typed_floating (val, type, memval, memtype); | |
145 | write_memory (sp + argoffset, val, len); | |
146 | } | |
147 | argoffset += 8; | |
7b112f9c JT |
148 | } |
149 | } | |
944fcfab AC |
150 | else if (len == 8 && (TYPE_CODE (type) == TYPE_CODE_INT /* long long */ |
151 | || (!ppc_floating_point_unit_p (current_gdbarch) && TYPE_CODE (type) == TYPE_CODE_FLT))) /* double */ | |
7b112f9c | 152 | { |
68856ea3 | 153 | /* "long long" or "double" passed in an odd/even |
944fcfab AC |
154 | register pair with the low addressed word in the odd |
155 | register and the high addressed word in the even | |
156 | register, or when the registers run out an 8 byte | |
157 | aligned stack location. */ | |
68856ea3 AC |
158 | if (greg > 9) |
159 | { | |
160 | /* Just in case GREG was 10. */ | |
161 | greg = 11; | |
162 | argoffset = align_up (argoffset, 8); | |
163 | if (write_pass) | |
164 | write_memory (sp + argoffset, val, len); | |
165 | argoffset += 8; | |
166 | } | |
167 | else if (tdep->wordsize == 8) | |
168 | { | |
169 | if (write_pass) | |
170 | regcache_cooked_write (regcache, | |
944fcfab | 171 | tdep->ppc_gp0_regnum + greg, val); |
68856ea3 AC |
172 | greg += 1; |
173 | } | |
174 | else | |
175 | { | |
176 | /* Must start on an odd register - r3/r4 etc. */ | |
177 | if ((greg & 1) == 0) | |
178 | greg++; | |
179 | if (write_pass) | |
180 | { | |
181 | regcache_cooked_write (regcache, | |
182 | tdep->ppc_gp0_regnum + greg + 0, | |
183 | val + 0); | |
184 | regcache_cooked_write (regcache, | |
185 | tdep->ppc_gp0_regnum + greg + 1, | |
186 | val + 4); | |
187 | } | |
188 | greg += 2; | |
189 | } | |
7b112f9c | 190 | } |
68856ea3 AC |
191 | else if (len == 16 |
192 | && TYPE_CODE (type) == TYPE_CODE_ARRAY | |
944fcfab | 193 | && TYPE_VECTOR (type) && tdep->ppc_vr0_regnum >= 0) |
7b112f9c | 194 | { |
68856ea3 | 195 | /* Vector parameter passed in an Altivec register, or |
944fcfab | 196 | when that runs out, 16 byte aligned stack location. */ |
7b112f9c JT |
197 | if (vreg <= 13) |
198 | { | |
68856ea3 AC |
199 | if (write_pass) |
200 | regcache_cooked_write (current_regcache, | |
944fcfab | 201 | tdep->ppc_vr0_regnum + vreg, val); |
7b112f9c JT |
202 | vreg++; |
203 | } | |
204 | else | |
205 | { | |
68856ea3 AC |
206 | argoffset = align_up (argoffset, 16); |
207 | if (write_pass) | |
208 | write_memory (sp + argoffset, val, 16); | |
7b112f9c JT |
209 | argoffset += 16; |
210 | } | |
211 | } | |
944fcfab | 212 | else if (len == 8 |
0a613259 | 213 | && TYPE_CODE (type) == TYPE_CODE_ARRAY |
944fcfab AC |
214 | && TYPE_VECTOR (type) && tdep->ppc_ev0_regnum >= 0) |
215 | { | |
68856ea3 | 216 | /* Vector parameter passed in an e500 register, or when |
944fcfab AC |
217 | that runs out, 8 byte aligned stack location. Note |
218 | that since e500 vector and general purpose registers | |
219 | both map onto the same underlying register set, a | |
220 | "greg" and not a "vreg" is consumed here. A cooked | |
221 | write stores the value in the correct locations | |
222 | within the raw register cache. */ | |
223 | if (greg <= 10) | |
224 | { | |
68856ea3 AC |
225 | if (write_pass) |
226 | regcache_cooked_write (current_regcache, | |
944fcfab AC |
227 | tdep->ppc_ev0_regnum + greg, val); |
228 | greg++; | |
229 | } | |
230 | else | |
231 | { | |
68856ea3 AC |
232 | argoffset = align_up (argoffset, 8); |
233 | if (write_pass) | |
234 | write_memory (sp + argoffset, val, 8); | |
944fcfab AC |
235 | argoffset += 8; |
236 | } | |
237 | } | |
68856ea3 AC |
238 | else |
239 | { | |
240 | /* Reduce the parameter down to something that fits in a | |
944fcfab | 241 | "word". */ |
68856ea3 AC |
242 | char word[MAX_REGISTER_SIZE]; |
243 | memset (word, 0, MAX_REGISTER_SIZE); | |
244 | if (len > tdep->wordsize | |
245 | || TYPE_CODE (type) == TYPE_CODE_STRUCT | |
246 | || TYPE_CODE (type) == TYPE_CODE_UNION) | |
247 | { | |
248 | /* Structs and large values are put on an 8 byte | |
944fcfab | 249 | aligned stack ... */ |
68856ea3 AC |
250 | structoffset = align_up (structoffset, 8); |
251 | if (write_pass) | |
252 | write_memory (sp + structoffset, val, len); | |
253 | /* ... and then a "word" pointing to that address is | |
944fcfab | 254 | passed as the parameter. */ |
68856ea3 AC |
255 | store_unsigned_integer (word, tdep->wordsize, |
256 | sp + structoffset); | |
257 | structoffset += len; | |
258 | } | |
259 | else if (TYPE_CODE (type) == TYPE_CODE_INT) | |
260 | /* Sign or zero extend the "int" into a "word". */ | |
261 | store_unsigned_integer (word, tdep->wordsize, | |
262 | unpack_long (type, val)); | |
263 | else | |
264 | /* Always goes in the low address. */ | |
265 | memcpy (word, val, len); | |
266 | /* Store that "word" in a register, or on the stack. | |
944fcfab | 267 | The words have "4" byte alignment. */ |
68856ea3 AC |
268 | if (greg <= 10) |
269 | { | |
270 | if (write_pass) | |
271 | regcache_cooked_write (regcache, | |
944fcfab | 272 | tdep->ppc_gp0_regnum + greg, word); |
68856ea3 AC |
273 | greg++; |
274 | } | |
275 | else | |
276 | { | |
277 | argoffset = align_up (argoffset, tdep->wordsize); | |
278 | if (write_pass) | |
279 | write_memory (sp + argoffset, word, tdep->wordsize); | |
280 | argoffset += tdep->wordsize; | |
281 | } | |
282 | } | |
283 | } | |
284 | ||
285 | /* Compute the actual stack space requirements. */ | |
286 | if (!write_pass) | |
287 | { | |
288 | /* Remember the amount of space needed by the arguments. */ | |
289 | argspace = argoffset; | |
290 | /* Allocate space for both the arguments and the structures. */ | |
291 | sp -= (argoffset + structoffset); | |
292 | /* Ensure that the stack is still 16 byte aligned. */ | |
293 | sp = align_down (sp, 16); | |
294 | } | |
7b112f9c JT |
295 | } |
296 | ||
68856ea3 AC |
297 | /* Update %sp. */ |
298 | regcache_cooked_write_signed (regcache, SP_REGNUM, sp); | |
299 | ||
300 | /* Write the backchain (it occupies WORDSIZED bytes). */ | |
301 | write_memory_signed_integer (sp, tdep->wordsize, saved_sp); | |
302 | ||
e56a0ecc AC |
303 | /* Point the inferior function call's return address at the dummy's |
304 | breakpoint. */ | |
68856ea3 | 305 | regcache_cooked_write_signed (regcache, tdep->ppc_lr_regnum, bp_addr); |
e56a0ecc | 306 | |
7b112f9c JT |
307 | return sp; |
308 | } | |
309 | ||
e754ae69 AC |
310 | /* Handle the return-value conventions specified by the SysV 32-bit |
311 | PowerPC ABI (including all the supplements): | |
312 | ||
313 | no floating-point: floating-point values returned using 32-bit | |
314 | general-purpose registers. | |
315 | ||
316 | Altivec: 128-bit vectors returned using vector registers. | |
317 | ||
318 | e500: 64-bit vectors returned using the full full 64 bit EV | |
319 | register, floating-point values returned using 32-bit | |
320 | general-purpose registers. | |
321 | ||
322 | GCC (broken): Small struct values right (instead of left) aligned | |
323 | when returned in general-purpose registers. */ | |
324 | ||
325 | static enum return_value_convention | |
05580c65 | 326 | do_ppc_sysv_return_value (struct gdbarch *gdbarch, struct type *type, |
963e2bb7 AC |
327 | struct regcache *regcache, void *readbuf, |
328 | const void *writebuf, int broken_gcc) | |
e754ae69 | 329 | { |
05580c65 | 330 | struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); |
e754ae69 AC |
331 | gdb_assert (tdep->wordsize == 4); |
332 | if (TYPE_CODE (type) == TYPE_CODE_FLT | |
333 | && TYPE_LENGTH (type) <= 8 | |
05580c65 | 334 | && ppc_floating_point_unit_p (gdbarch)) |
e754ae69 | 335 | { |
963e2bb7 | 336 | if (readbuf) |
e754ae69 AC |
337 | { |
338 | /* Floats and doubles stored in "f1". Convert the value to | |
339 | the required type. */ | |
340 | char regval[MAX_REGISTER_SIZE]; | |
05580c65 | 341 | struct type *regtype = register_type (gdbarch, FP0_REGNUM + 1); |
e754ae69 | 342 | regcache_cooked_read (regcache, FP0_REGNUM + 1, regval); |
963e2bb7 | 343 | convert_typed_floating (regval, regtype, readbuf, type); |
e754ae69 | 344 | } |
963e2bb7 | 345 | if (writebuf) |
e754ae69 AC |
346 | { |
347 | /* Floats and doubles stored in "f1". Convert the value to | |
348 | the register's "double" type. */ | |
349 | char regval[MAX_REGISTER_SIZE]; | |
05580c65 | 350 | struct type *regtype = register_type (gdbarch, FP0_REGNUM); |
963e2bb7 | 351 | convert_typed_floating (writebuf, type, regval, regtype); |
e754ae69 AC |
352 | regcache_cooked_write (regcache, FP0_REGNUM + 1, regval); |
353 | } | |
354 | return RETURN_VALUE_REGISTER_CONVENTION; | |
355 | } | |
356 | if ((TYPE_CODE (type) == TYPE_CODE_INT && TYPE_LENGTH (type) == 8) | |
357 | || (TYPE_CODE (type) == TYPE_CODE_FLT && TYPE_LENGTH (type) == 8)) | |
358 | { | |
963e2bb7 | 359 | if (readbuf) |
e754ae69 AC |
360 | { |
361 | /* A long long, or a double stored in the 32 bit r3/r4. */ | |
362 | regcache_cooked_read (regcache, tdep->ppc_gp0_regnum + 3, | |
963e2bb7 | 363 | (bfd_byte *) readbuf + 0); |
e754ae69 | 364 | regcache_cooked_read (regcache, tdep->ppc_gp0_regnum + 4, |
963e2bb7 | 365 | (bfd_byte *) readbuf + 4); |
e754ae69 | 366 | } |
963e2bb7 | 367 | if (writebuf) |
e754ae69 AC |
368 | { |
369 | /* A long long, or a double stored in the 32 bit r3/r4. */ | |
370 | regcache_cooked_write (regcache, tdep->ppc_gp0_regnum + 3, | |
963e2bb7 | 371 | (const bfd_byte *) writebuf + 0); |
e754ae69 | 372 | regcache_cooked_write (regcache, tdep->ppc_gp0_regnum + 4, |
963e2bb7 | 373 | (const bfd_byte *) writebuf + 4); |
e754ae69 AC |
374 | } |
375 | return RETURN_VALUE_REGISTER_CONVENTION; | |
376 | } | |
377 | if (TYPE_CODE (type) == TYPE_CODE_INT | |
378 | && TYPE_LENGTH (type) <= tdep->wordsize) | |
379 | { | |
963e2bb7 | 380 | if (readbuf) |
e754ae69 AC |
381 | { |
382 | /* Some sort of integer stored in r3. Since TYPE isn't | |
383 | bigger than the register, sign extension isn't a problem | |
384 | - just do everything unsigned. */ | |
385 | ULONGEST regval; | |
386 | regcache_cooked_read_unsigned (regcache, tdep->ppc_gp0_regnum + 3, | |
387 | ®val); | |
963e2bb7 | 388 | store_unsigned_integer (readbuf, TYPE_LENGTH (type), regval); |
e754ae69 | 389 | } |
963e2bb7 | 390 | if (writebuf) |
e754ae69 AC |
391 | { |
392 | /* Some sort of integer stored in r3. Use unpack_long since | |
393 | that should handle any required sign extension. */ | |
394 | regcache_cooked_write_unsigned (regcache, tdep->ppc_gp0_regnum + 3, | |
963e2bb7 | 395 | unpack_long (type, writebuf)); |
e754ae69 AC |
396 | } |
397 | return RETURN_VALUE_REGISTER_CONVENTION; | |
398 | } | |
399 | if (TYPE_LENGTH (type) == 16 | |
400 | && TYPE_CODE (type) == TYPE_CODE_ARRAY | |
401 | && TYPE_VECTOR (type) && tdep->ppc_vr0_regnum >= 0) | |
402 | { | |
963e2bb7 | 403 | if (readbuf) |
e754ae69 AC |
404 | { |
405 | /* Altivec places the return value in "v2". */ | |
963e2bb7 | 406 | regcache_cooked_read (regcache, tdep->ppc_vr0_regnum + 2, readbuf); |
e754ae69 | 407 | } |
963e2bb7 | 408 | if (writebuf) |
e754ae69 AC |
409 | { |
410 | /* Altivec places the return value in "v2". */ | |
963e2bb7 | 411 | regcache_cooked_write (regcache, tdep->ppc_vr0_regnum + 2, writebuf); |
e754ae69 AC |
412 | } |
413 | return RETURN_VALUE_REGISTER_CONVENTION; | |
414 | } | |
415 | if (TYPE_LENGTH (type) == 8 | |
416 | && TYPE_CODE (type) == TYPE_CODE_ARRAY | |
417 | && TYPE_VECTOR (type) && tdep->ppc_ev0_regnum >= 0) | |
418 | { | |
419 | /* The e500 ABI places return values for the 64-bit DSP types | |
420 | (__ev64_opaque__) in r3. However, in GDB-speak, ev3 | |
421 | corresponds to the entire r3 value for e500, whereas GDB's r3 | |
422 | only corresponds to the least significant 32-bits. So place | |
423 | the 64-bit DSP type's value in ev3. */ | |
963e2bb7 AC |
424 | if (readbuf) |
425 | regcache_cooked_read (regcache, tdep->ppc_ev0_regnum + 3, readbuf); | |
426 | if (writebuf) | |
427 | regcache_cooked_write (regcache, tdep->ppc_ev0_regnum + 3, writebuf); | |
e754ae69 AC |
428 | return RETURN_VALUE_REGISTER_CONVENTION; |
429 | } | |
430 | if (broken_gcc && TYPE_LENGTH (type) <= 8) | |
431 | { | |
963e2bb7 | 432 | if (readbuf) |
e754ae69 AC |
433 | { |
434 | /* GCC screwed up. The last register isn't "left" aligned. | |
435 | Need to extract the least significant part of each | |
436 | register and then store that. */ | |
437 | /* Transfer any full words. */ | |
438 | int word = 0; | |
439 | while (1) | |
440 | { | |
441 | ULONGEST reg; | |
442 | int len = TYPE_LENGTH (type) - word * tdep->wordsize; | |
443 | if (len <= 0) | |
444 | break; | |
445 | if (len > tdep->wordsize) | |
446 | len = tdep->wordsize; | |
447 | regcache_cooked_read_unsigned (regcache, | |
448 | tdep->ppc_gp0_regnum + 3 + word, | |
449 | ®); | |
963e2bb7 | 450 | store_unsigned_integer (((bfd_byte *) readbuf |
e754ae69 AC |
451 | + word * tdep->wordsize), len, reg); |
452 | word++; | |
453 | } | |
454 | } | |
963e2bb7 | 455 | if (writebuf) |
e754ae69 AC |
456 | { |
457 | /* GCC screwed up. The last register isn't "left" aligned. | |
458 | Need to extract the least significant part of each | |
459 | register and then store that. */ | |
460 | /* Transfer any full words. */ | |
461 | int word = 0; | |
462 | while (1) | |
463 | { | |
464 | ULONGEST reg; | |
465 | int len = TYPE_LENGTH (type) - word * tdep->wordsize; | |
466 | if (len <= 0) | |
467 | break; | |
468 | if (len > tdep->wordsize) | |
469 | len = tdep->wordsize; | |
963e2bb7 | 470 | reg = extract_unsigned_integer (((const bfd_byte *) writebuf |
e754ae69 AC |
471 | + word * tdep->wordsize), len); |
472 | regcache_cooked_write_unsigned (regcache, | |
473 | tdep->ppc_gp0_regnum + 3 + word, | |
474 | reg); | |
475 | word++; | |
476 | } | |
477 | } | |
478 | return RETURN_VALUE_REGISTER_CONVENTION; | |
479 | } | |
480 | if (TYPE_LENGTH (type) <= 8) | |
481 | { | |
963e2bb7 | 482 | if (readbuf) |
e754ae69 AC |
483 | { |
484 | /* This matches SVr4 PPC, it does not match GCC. */ | |
485 | /* The value is right-padded to 8 bytes and then loaded, as | |
486 | two "words", into r3/r4. */ | |
487 | char regvals[MAX_REGISTER_SIZE * 2]; | |
488 | regcache_cooked_read (regcache, tdep->ppc_gp0_regnum + 3, | |
489 | regvals + 0 * tdep->wordsize); | |
490 | if (TYPE_LENGTH (type) > tdep->wordsize) | |
491 | regcache_cooked_read (regcache, tdep->ppc_gp0_regnum + 4, | |
492 | regvals + 1 * tdep->wordsize); | |
963e2bb7 | 493 | memcpy (readbuf, regvals, TYPE_LENGTH (type)); |
e754ae69 | 494 | } |
963e2bb7 | 495 | if (writebuf) |
e754ae69 AC |
496 | { |
497 | /* This matches SVr4 PPC, it does not match GCC. */ | |
498 | /* The value is padded out to 8 bytes and then loaded, as | |
499 | two "words" into r3/r4. */ | |
500 | char regvals[MAX_REGISTER_SIZE * 2]; | |
501 | memset (regvals, 0, sizeof regvals); | |
963e2bb7 | 502 | memcpy (regvals, writebuf, TYPE_LENGTH (type)); |
e754ae69 AC |
503 | regcache_cooked_write (regcache, tdep->ppc_gp0_regnum + 3, |
504 | regvals + 0 * tdep->wordsize); | |
505 | if (TYPE_LENGTH (type) > tdep->wordsize) | |
506 | regcache_cooked_write (regcache, tdep->ppc_gp0_regnum + 4, | |
507 | regvals + 1 * tdep->wordsize); | |
508 | } | |
509 | return RETURN_VALUE_REGISTER_CONVENTION; | |
510 | } | |
511 | return RETURN_VALUE_STRUCT_CONVENTION; | |
512 | } | |
513 | ||
05580c65 AC |
514 | enum return_value_convention |
515 | ppc_sysv_abi_return_value (struct gdbarch *gdbarch, struct type *valtype, | |
963e2bb7 AC |
516 | struct regcache *regcache, void *readbuf, |
517 | const void *writebuf) | |
e754ae69 | 518 | { |
963e2bb7 AC |
519 | return do_ppc_sysv_return_value (gdbarch, valtype, regcache, readbuf, |
520 | writebuf, 0); | |
e754ae69 AC |
521 | } |
522 | ||
05580c65 | 523 | enum return_value_convention |
963e2bb7 AC |
524 | ppc_sysv_abi_broken_return_value (struct gdbarch *gdbarch, |
525 | struct type *valtype, | |
526 | struct regcache *regcache, | |
527 | void *readbuf, const void *writebuf) | |
e754ae69 | 528 | { |
963e2bb7 AC |
529 | return do_ppc_sysv_return_value (gdbarch, valtype, regcache, readbuf, |
530 | writebuf, 1); | |
944fcfab | 531 | } |
afd48b75 | 532 | |
8be9034a AC |
533 | /* Pass the arguments in either registers, or in the stack. Using the |
534 | ppc 64 bit SysV ABI. | |
535 | ||
536 | This implements a dumbed down version of the ABI. It always writes | |
537 | values to memory, GPR and FPR, even when not necessary. Doing this | |
538 | greatly simplifies the logic. */ | |
539 | ||
540 | CORE_ADDR | |
541 | ppc64_sysv_abi_push_dummy_call (struct gdbarch *gdbarch, CORE_ADDR func_addr, | |
542 | struct regcache *regcache, CORE_ADDR bp_addr, | |
543 | int nargs, struct value **args, CORE_ADDR sp, | |
544 | int struct_return, CORE_ADDR struct_addr) | |
545 | { | |
546 | struct gdbarch_tdep *tdep = gdbarch_tdep (current_gdbarch); | |
547 | /* By this stage in the proceedings, SP has been decremented by "red | |
548 | zone size" + "struct return size". Fetch the stack-pointer from | |
549 | before this and use that as the BACK_CHAIN. */ | |
550 | const CORE_ADDR back_chain = read_sp (); | |
551 | /* See for-loop comment below. */ | |
552 | int write_pass; | |
553 | /* Size of the Altivec's vector parameter region, the final value is | |
554 | computed in the for-loop below. */ | |
555 | LONGEST vparam_size = 0; | |
556 | /* Size of the general parameter region, the final value is computed | |
557 | in the for-loop below. */ | |
558 | LONGEST gparam_size = 0; | |
559 | /* Kevin writes ... I don't mind seeing tdep->wordsize used in the | |
560 | calls to align_up(), align_down(), etc. because this makes it | |
561 | easier to reuse this code (in a copy/paste sense) in the future, | |
562 | but it is a 64-bit ABI and asserting that the wordsize is 8 bytes | |
563 | at some point makes it easier to verify that this function is | |
564 | correct without having to do a non-local analysis to figure out | |
565 | the possible values of tdep->wordsize. */ | |
566 | gdb_assert (tdep->wordsize == 8); | |
567 | ||
568 | /* Go through the argument list twice. | |
569 | ||
570 | Pass 1: Compute the function call's stack space and register | |
571 | requirements. | |
572 | ||
573 | Pass 2: Replay the same computation but this time also write the | |
574 | values out to the target. */ | |
575 | ||
576 | for (write_pass = 0; write_pass < 2; write_pass++) | |
577 | { | |
578 | int argno; | |
579 | /* Next available floating point register for float and double | |
580 | arguments. */ | |
581 | int freg = 1; | |
582 | /* Next available general register for non-vector (but possibly | |
583 | float) arguments. */ | |
584 | int greg = 3; | |
585 | /* Next available vector register for vector arguments. */ | |
586 | int vreg = 2; | |
587 | /* The address, at which the next general purpose parameter | |
588 | (integer, struct, float, ...) should be saved. */ | |
589 | CORE_ADDR gparam; | |
590 | /* Address, at which the next Altivec vector parameter should be | |
591 | saved. */ | |
592 | CORE_ADDR vparam; | |
593 | ||
594 | if (!write_pass) | |
595 | { | |
596 | /* During the first pass, GPARAM and VPARAM are more like | |
597 | offsets (start address zero) than addresses. That way | |
598 | the accumulate the total stack space each region | |
599 | requires. */ | |
600 | gparam = 0; | |
601 | vparam = 0; | |
602 | } | |
603 | else | |
604 | { | |
605 | /* Decrement the stack pointer making space for the Altivec | |
606 | and general on-stack parameters. Set vparam and gparam | |
607 | to their corresponding regions. */ | |
608 | vparam = align_down (sp - vparam_size, 16); | |
609 | gparam = align_down (vparam - gparam_size, 16); | |
610 | /* Add in space for the TOC, link editor double word, | |
611 | compiler double word, LR save area, CR save area. */ | |
612 | sp = align_down (gparam - 48, 16); | |
613 | } | |
614 | ||
615 | /* If the function is returning a `struct', then there is an | |
616 | extra hidden parameter (which will be passed in r3) | |
617 | containing the address of that struct.. In that case we | |
618 | should advance one word and start from r4 register to copy | |
619 | parameters. This also consumes one on-stack parameter slot. */ | |
620 | if (struct_return) | |
621 | { | |
622 | if (write_pass) | |
623 | regcache_cooked_write_signed (regcache, | |
624 | tdep->ppc_gp0_regnum + greg, | |
625 | struct_addr); | |
626 | greg++; | |
627 | gparam = align_up (gparam + tdep->wordsize, tdep->wordsize); | |
628 | } | |
629 | ||
630 | for (argno = 0; argno < nargs; argno++) | |
631 | { | |
632 | struct value *arg = args[argno]; | |
633 | struct type *type = check_typedef (VALUE_TYPE (arg)); | |
634 | char *val = VALUE_CONTENTS (arg); | |
635 | if (TYPE_CODE (type) == TYPE_CODE_FLT && TYPE_LENGTH (type) <= 8) | |
636 | { | |
637 | /* Floats and Doubles go in f1 .. f13. They also | |
638 | consume a left aligned GREG,, and can end up in | |
639 | memory. */ | |
640 | if (write_pass) | |
641 | { | |
642 | if (ppc_floating_point_unit_p (current_gdbarch) | |
643 | && freg <= 13) | |
644 | { | |
645 | char regval[MAX_REGISTER_SIZE]; | |
646 | struct type *regtype = register_type (gdbarch, | |
647 | FP0_REGNUM); | |
648 | convert_typed_floating (val, type, regval, regtype); | |
649 | regcache_cooked_write (regcache, FP0_REGNUM + freg, | |
650 | regval); | |
651 | } | |
652 | if (greg <= 10) | |
653 | { | |
654 | /* The ABI states "Single precision floating | |
655 | point values are mapped to the first word in | |
656 | a single doubleword" and "... floating point | |
657 | values mapped to the first eight doublewords | |
658 | of the parameter save area are also passed in | |
659 | general registers"). | |
660 | ||
661 | This code interprets that to mean: store it, | |
662 | left aligned, in the general register. */ | |
663 | char regval[MAX_REGISTER_SIZE]; | |
664 | memset (regval, 0, sizeof regval); | |
665 | memcpy (regval, val, TYPE_LENGTH (type)); | |
666 | regcache_cooked_write (regcache, | |
667 | tdep->ppc_gp0_regnum + greg, | |
668 | regval); | |
669 | } | |
670 | write_memory (gparam, val, TYPE_LENGTH (type)); | |
671 | } | |
672 | /* Always consume parameter stack space. */ | |
673 | freg++; | |
674 | greg++; | |
675 | gparam = align_up (gparam + TYPE_LENGTH (type), tdep->wordsize); | |
676 | } | |
677 | else if (TYPE_LENGTH (type) == 16 && TYPE_VECTOR (type) | |
678 | && TYPE_CODE (type) == TYPE_CODE_ARRAY | |
679 | && tdep->ppc_vr0_regnum >= 0) | |
680 | { | |
681 | /* In the Altivec ABI, vectors go in the vector | |
682 | registers v2 .. v13, or when that runs out, a vector | |
683 | annex which goes above all the normal parameters. | |
684 | NOTE: cagney/2003-09-21: This is a guess based on the | |
685 | PowerOpen Altivec ABI. */ | |
686 | if (vreg <= 13) | |
687 | { | |
688 | if (write_pass) | |
689 | regcache_cooked_write (regcache, | |
690 | tdep->ppc_vr0_regnum + vreg, val); | |
691 | vreg++; | |
692 | } | |
693 | else | |
694 | { | |
695 | if (write_pass) | |
696 | write_memory (vparam, val, TYPE_LENGTH (type)); | |
697 | vparam = align_up (vparam + TYPE_LENGTH (type), 16); | |
698 | } | |
699 | } | |
700 | else if ((TYPE_CODE (type) == TYPE_CODE_INT | |
701 | || TYPE_CODE (type) == TYPE_CODE_ENUM) | |
702 | && TYPE_LENGTH (type) <= 8) | |
703 | { | |
704 | /* Scalars get sign[un]extended and go in gpr3 .. gpr10. | |
705 | They can also end up in memory. */ | |
706 | if (write_pass) | |
707 | { | |
708 | /* Sign extend the value, then store it unsigned. */ | |
709 | ULONGEST word = unpack_long (type, val); | |
710 | if (greg <= 10) | |
711 | regcache_cooked_write_unsigned (regcache, | |
712 | tdep->ppc_gp0_regnum + | |
713 | greg, word); | |
714 | write_memory_unsigned_integer (gparam, tdep->wordsize, | |
715 | word); | |
716 | } | |
717 | greg++; | |
718 | gparam = align_up (gparam + TYPE_LENGTH (type), tdep->wordsize); | |
719 | } | |
720 | else | |
721 | { | |
722 | int byte; | |
723 | for (byte = 0; byte < TYPE_LENGTH (type); | |
724 | byte += tdep->wordsize) | |
725 | { | |
726 | if (write_pass && greg <= 10) | |
727 | { | |
728 | char regval[MAX_REGISTER_SIZE]; | |
729 | int len = TYPE_LENGTH (type) - byte; | |
730 | if (len > tdep->wordsize) | |
731 | len = tdep->wordsize; | |
732 | memset (regval, 0, sizeof regval); | |
733 | /* WARNING: cagney/2003-09-21: As best I can | |
734 | tell, the ABI specifies that the value should | |
735 | be left aligned. Unfortunately, GCC doesn't | |
736 | do this - it instead right aligns even sized | |
737 | values and puts odd sized values on the | |
738 | stack. Work around that by putting both a | |
739 | left and right aligned value into the | |
740 | register (hopefully no one notices :-^). | |
741 | Arrrgh! */ | |
742 | /* Left aligned (8 byte values such as pointers | |
743 | fill the buffer). */ | |
744 | memcpy (regval, val + byte, len); | |
745 | /* Right aligned (but only if even). */ | |
746 | if (len == 1 || len == 2 || len == 4) | |
747 | memcpy (regval + tdep->wordsize - len, | |
748 | val + byte, len); | |
749 | regcache_cooked_write (regcache, greg, regval); | |
750 | } | |
751 | greg++; | |
752 | } | |
753 | if (write_pass) | |
754 | /* WARNING: cagney/2003-09-21: Strictly speaking, this | |
755 | isn't necessary, unfortunately, GCC appears to get | |
756 | "struct convention" parameter passing wrong putting | |
757 | odd sized structures in memory instead of in a | |
758 | register. Work around this by always writing the | |
759 | value to memory. Fortunately, doing this | |
760 | simplifies the code. */ | |
761 | write_memory (gparam, val, TYPE_LENGTH (type)); | |
762 | /* Always consume parameter stack space. */ | |
763 | gparam = align_up (gparam + TYPE_LENGTH (type), tdep->wordsize); | |
764 | } | |
765 | } | |
766 | ||
767 | if (!write_pass) | |
768 | { | |
769 | /* Save the true region sizes ready for the second pass. */ | |
770 | vparam_size = vparam; | |
771 | /* Make certain that the general parameter save area is at | |
772 | least the minimum 8 registers (or doublewords) in size. */ | |
773 | if (greg < 8) | |
774 | gparam_size = 8 * tdep->wordsize; | |
775 | else | |
776 | gparam_size = gparam; | |
777 | } | |
778 | } | |
779 | ||
780 | /* Update %sp. */ | |
781 | regcache_cooked_write_signed (regcache, SP_REGNUM, sp); | |
782 | ||
783 | /* Write the backchain (it occupies WORDSIZED bytes). */ | |
784 | write_memory_signed_integer (sp, tdep->wordsize, back_chain); | |
785 | ||
786 | /* Point the inferior function call's return address at the dummy's | |
787 | breakpoint. */ | |
788 | regcache_cooked_write_signed (regcache, tdep->ppc_lr_regnum, bp_addr); | |
789 | ||
790 | /* Find a value for the TOC register. Every symbol should have both | |
791 | ".FN" and "FN" in the minimal symbol table. "FN" points at the | |
792 | FN's descriptor, while ".FN" points at the entry point (which | |
793 | matches FUNC_ADDR). Need to reverse from FUNC_ADDR back to the | |
0a90bcdd AC |
794 | FN's descriptor address (while at the same time being careful to |
795 | find "FN" in the same object file as ".FN"). */ | |
8be9034a AC |
796 | { |
797 | /* Find the minimal symbol that corresponds to FUNC_ADDR (should | |
798 | have the name ".FN"). */ | |
799 | struct minimal_symbol *dot_fn = lookup_minimal_symbol_by_pc (func_addr); | |
800 | if (dot_fn != NULL && SYMBOL_LINKAGE_NAME (dot_fn)[0] == '.') | |
801 | { | |
0a90bcdd AC |
802 | /* Get the section that contains FUNC_ADR. Need this for the |
803 | "objfile" that it contains. */ | |
804 | struct obj_section *dot_fn_section = find_pc_section (func_addr); | |
805 | if (dot_fn_section != NULL && dot_fn_section->objfile != NULL) | |
8be9034a | 806 | { |
0a90bcdd AC |
807 | /* Now find the corresponding "FN" (dropping ".") minimal |
808 | symbol's address. Only look for the minimal symbol in | |
809 | ".FN"'s object file - avoids problems when two object | |
810 | files (i.e., shared libraries) contain a minimal symbol | |
811 | with the same name. */ | |
812 | struct minimal_symbol *fn = | |
813 | lookup_minimal_symbol (SYMBOL_LINKAGE_NAME (dot_fn) + 1, NULL, | |
814 | dot_fn_section->objfile); | |
815 | if (fn != NULL) | |
816 | { | |
817 | /* Got the address of that descriptor. The TOC is the | |
818 | second double word. */ | |
819 | CORE_ADDR toc = | |
820 | read_memory_unsigned_integer (SYMBOL_VALUE_ADDRESS (fn) | |
821 | + tdep->wordsize, | |
822 | tdep->wordsize); | |
823 | regcache_cooked_write_unsigned (regcache, | |
824 | tdep->ppc_gp0_regnum + 2, toc); | |
825 | } | |
8be9034a AC |
826 | } |
827 | } | |
828 | } | |
829 | ||
830 | return sp; | |
831 | } | |
832 | ||
afd48b75 AC |
833 | |
834 | /* The 64 bit ABI retun value convention. | |
835 | ||
836 | Return non-zero if the return-value is stored in a register, return | |
837 | 0 if the return-value is instead stored on the stack (a.k.a., | |
838 | struct return convention). | |
839 | ||
963e2bb7 | 840 | For a return-value stored in a register: when WRITEBUF is non-NULL, |
afd48b75 | 841 | copy the buffer to the corresponding register return-value location |
963e2bb7 | 842 | location; when READBUF is non-NULL, fill the buffer from the |
afd48b75 | 843 | corresponding register return-value location. */ |
05580c65 AC |
844 | enum return_value_convention |
845 | ppc64_sysv_abi_return_value (struct gdbarch *gdbarch, struct type *valtype, | |
963e2bb7 AC |
846 | struct regcache *regcache, void *readbuf, |
847 | const void *writebuf) | |
afd48b75 | 848 | { |
05580c65 | 849 | struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); |
afd48b75 | 850 | /* Floats and doubles in F1. */ |
944fcfab | 851 | if (TYPE_CODE (valtype) == TYPE_CODE_FLT && TYPE_LENGTH (valtype) <= 8) |
afd48b75 AC |
852 | { |
853 | char regval[MAX_REGISTER_SIZE]; | |
05580c65 | 854 | struct type *regtype = register_type (gdbarch, FP0_REGNUM); |
963e2bb7 | 855 | if (writebuf != NULL) |
afd48b75 | 856 | { |
963e2bb7 | 857 | convert_typed_floating (writebuf, valtype, regval, regtype); |
afd48b75 AC |
858 | regcache_cooked_write (regcache, FP0_REGNUM + 1, regval); |
859 | } | |
963e2bb7 | 860 | if (readbuf != NULL) |
afd48b75 AC |
861 | { |
862 | regcache_cooked_read (regcache, FP0_REGNUM + 1, regval); | |
963e2bb7 | 863 | convert_typed_floating (regval, regtype, readbuf, valtype); |
afd48b75 AC |
864 | } |
865 | return RETURN_VALUE_REGISTER_CONVENTION; | |
866 | } | |
944fcfab | 867 | if (TYPE_CODE (valtype) == TYPE_CODE_INT && TYPE_LENGTH (valtype) <= 8) |
afd48b75 AC |
868 | { |
869 | /* Integers in r3. */ | |
963e2bb7 | 870 | if (writebuf != NULL) |
afd48b75 AC |
871 | { |
872 | /* Be careful to sign extend the value. */ | |
873 | regcache_cooked_write_unsigned (regcache, tdep->ppc_gp0_regnum + 3, | |
963e2bb7 | 874 | unpack_long (valtype, writebuf)); |
afd48b75 | 875 | } |
963e2bb7 | 876 | if (readbuf != NULL) |
afd48b75 AC |
877 | { |
878 | /* Extract the integer from r3. Since this is truncating the | |
879 | value, there isn't a sign extension problem. */ | |
880 | ULONGEST regval; | |
881 | regcache_cooked_read_unsigned (regcache, tdep->ppc_gp0_regnum + 3, | |
882 | ®val); | |
963e2bb7 | 883 | store_unsigned_integer (readbuf, TYPE_LENGTH (valtype), regval); |
afd48b75 AC |
884 | } |
885 | return RETURN_VALUE_REGISTER_CONVENTION; | |
886 | } | |
887 | /* All pointers live in r3. */ | |
888 | if (TYPE_CODE (valtype) == TYPE_CODE_PTR) | |
889 | { | |
890 | /* All pointers live in r3. */ | |
963e2bb7 AC |
891 | if (writebuf != NULL) |
892 | regcache_cooked_write (regcache, tdep->ppc_gp0_regnum + 3, writebuf); | |
893 | if (readbuf != NULL) | |
894 | regcache_cooked_read (regcache, tdep->ppc_gp0_regnum + 3, readbuf); | |
afd48b75 AC |
895 | return RETURN_VALUE_REGISTER_CONVENTION; |
896 | } | |
897 | if (TYPE_CODE (valtype) == TYPE_CODE_ARRAY | |
898 | && TYPE_LENGTH (valtype) <= 8 | |
899 | && TYPE_CODE (TYPE_TARGET_TYPE (valtype)) == TYPE_CODE_INT | |
900 | && TYPE_LENGTH (TYPE_TARGET_TYPE (valtype)) == 1) | |
901 | { | |
902 | /* Small character arrays are returned, right justified, in r3. */ | |
05580c65 | 903 | int offset = (register_size (gdbarch, tdep->ppc_gp0_regnum + 3) |
afd48b75 | 904 | - TYPE_LENGTH (valtype)); |
963e2bb7 | 905 | if (writebuf != NULL) |
afd48b75 | 906 | regcache_cooked_write_part (regcache, tdep->ppc_gp0_regnum + 3, |
963e2bb7 AC |
907 | offset, TYPE_LENGTH (valtype), writebuf); |
908 | if (readbuf != NULL) | |
afd48b75 | 909 | regcache_cooked_read_part (regcache, tdep->ppc_gp0_regnum + 3, |
963e2bb7 | 910 | offset, TYPE_LENGTH (valtype), readbuf); |
afd48b75 AC |
911 | return RETURN_VALUE_REGISTER_CONVENTION; |
912 | } | |
913 | /* Big floating point values get stored in adjacent floating | |
914 | point registers. */ | |
915 | if (TYPE_CODE (valtype) == TYPE_CODE_FLT | |
944fcfab | 916 | && (TYPE_LENGTH (valtype) == 16 || TYPE_LENGTH (valtype) == 32)) |
afd48b75 | 917 | { |
963e2bb7 | 918 | if (writebuf || readbuf != NULL) |
afd48b75 AC |
919 | { |
920 | int i; | |
921 | for (i = 0; i < TYPE_LENGTH (valtype) / 8; i++) | |
922 | { | |
963e2bb7 | 923 | if (writebuf != NULL) |
afd48b75 | 924 | regcache_cooked_write (regcache, FP0_REGNUM + 1 + i, |
963e2bb7 AC |
925 | (const bfd_byte *) writebuf + i * 8); |
926 | if (readbuf != NULL) | |
afd48b75 | 927 | regcache_cooked_read (regcache, FP0_REGNUM + 1 + i, |
963e2bb7 | 928 | (bfd_byte *) readbuf + i * 8); |
afd48b75 AC |
929 | } |
930 | } | |
931 | return RETURN_VALUE_REGISTER_CONVENTION; | |
932 | } | |
933 | /* Complex values get returned in f1:f2, need to convert. */ | |
934 | if (TYPE_CODE (valtype) == TYPE_CODE_COMPLEX | |
935 | && (TYPE_LENGTH (valtype) == 8 || TYPE_LENGTH (valtype) == 16)) | |
936 | { | |
937 | if (regcache != NULL) | |
938 | { | |
939 | int i; | |
940 | for (i = 0; i < 2; i++) | |
941 | { | |
942 | char regval[MAX_REGISTER_SIZE]; | |
944fcfab AC |
943 | struct type *regtype = |
944 | register_type (current_gdbarch, FP0_REGNUM); | |
963e2bb7 | 945 | if (writebuf != NULL) |
afd48b75 | 946 | { |
963e2bb7 | 947 | convert_typed_floating ((const bfd_byte *) writebuf + |
944fcfab | 948 | i * (TYPE_LENGTH (valtype) / 2), |
afd48b75 | 949 | valtype, regval, regtype); |
944fcfab AC |
950 | regcache_cooked_write (regcache, FP0_REGNUM + 1 + i, |
951 | regval); | |
afd48b75 | 952 | } |
963e2bb7 | 953 | if (readbuf != NULL) |
afd48b75 AC |
954 | { |
955 | regcache_cooked_read (regcache, FP0_REGNUM + 1 + i, regval); | |
956 | convert_typed_floating (regval, regtype, | |
963e2bb7 | 957 | (bfd_byte *) readbuf + |
944fcfab | 958 | i * (TYPE_LENGTH (valtype) / 2), |
afd48b75 AC |
959 | valtype); |
960 | } | |
961 | } | |
962 | } | |
963 | return RETURN_VALUE_REGISTER_CONVENTION; | |
964 | } | |
965 | /* Big complex values get stored in f1:f4. */ | |
944fcfab | 966 | if (TYPE_CODE (valtype) == TYPE_CODE_COMPLEX && TYPE_LENGTH (valtype) == 32) |
afd48b75 AC |
967 | { |
968 | if (regcache != NULL) | |
969 | { | |
970 | int i; | |
971 | for (i = 0; i < 4; i++) | |
972 | { | |
963e2bb7 | 973 | if (writebuf != NULL) |
afd48b75 | 974 | regcache_cooked_write (regcache, FP0_REGNUM + 1 + i, |
963e2bb7 AC |
975 | (const bfd_byte *) writebuf + i * 8); |
976 | if (readbuf != NULL) | |
afd48b75 | 977 | regcache_cooked_read (regcache, FP0_REGNUM + 1 + i, |
963e2bb7 | 978 | (bfd_byte *) readbuf + i * 8); |
afd48b75 AC |
979 | } |
980 | } | |
981 | return RETURN_VALUE_REGISTER_CONVENTION; | |
982 | } | |
983 | return RETURN_VALUE_STRUCT_CONVENTION; | |
984 | } | |
985 | ||
6066c3de AC |
986 | CORE_ADDR |
987 | ppc64_sysv_abi_adjust_breakpoint_address (struct gdbarch *gdbarch, | |
988 | CORE_ADDR bpaddr) | |
989 | { | |
990 | /* PPC64 SYSV specifies that the minimal-symbol "FN" should point at | |
991 | a function-descriptor while the corresponding minimal-symbol | |
992 | ".FN" should point at the entry point. Consequently, a command | |
993 | like "break FN" applied to an object file with only minimal | |
994 | symbols, will insert the breakpoint into the descriptor at "FN" | |
995 | and not the function at ".FN". Avoid this confusion by adjusting | |
996 | any attempt to set a descriptor breakpoint into a corresponding | |
997 | function breakpoint. Note that GDB warns the user when this | |
998 | adjustment is applied - that's ok as otherwise the user will have | |
999 | no way of knowing why their breakpoint at "FN" resulted in the | |
1000 | program stopping at ".FN". */ | |
1001 | return gdbarch_convert_from_func_ptr_addr (gdbarch, bpaddr, ¤t_target); | |
1002 | } |