1 /* Target-dependent code for PowerPC systems using the SVR4 ABI
2 for GDB, the GNU debugger.
4 Copyright (C) 2000, 2001, 2002, 2003, 2005, 2007, 2008
5 Free Software Foundation, Inc.
7 This file is part of GDB.
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
11 the Free Software Foundation; either version 3 of the License, or
12 (at your option) any later version.
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.
19 You should have received a copy of the GNU General Public License
20 along with this program. If not, see <http://www.gnu.org/licenses/>. */
27 #include "gdb_string.h"
28 #include "gdb_assert.h"
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.
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,
46 ppc_sysv_abi_push_dummy_call (struct gdbarch
*gdbarch
, struct value
*function
,
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
)
51 struct gdbarch_tdep
*tdep
= gdbarch_tdep (gdbarch
);
53 int argspace
= 0; /* 0 is an initial wrong guess. */
56 gdb_assert (tdep
->wordsize
== 4);
58 regcache_cooked_read_unsigned (regcache
, gdbarch_sp_regnum (gdbarch
),
61 /* Go through the argument list twice.
63 Pass 1: Figure out how much new stack space is required for
64 arguments and pushed values. Unlike the PowerOpen ABI, the SysV
65 ABI doesn't reserve any extra space for parameters which are put
66 in registers, but does always push structures and then pass their
69 Pass 2: Replay the same computation but this time also write the
70 values out to the target. */
72 for (write_pass
= 0; write_pass
< 2; write_pass
++)
75 /* Next available floating point register for float and double
78 /* Next available general register for non-float, non-vector
81 /* Next available vector register for vector arguments. */
83 /* Arguments start above the "LR save word" and "Back chain". */
84 int argoffset
= 2 * tdep
->wordsize
;
85 /* Structures start after the arguments. */
86 int structoffset
= argoffset
+ argspace
;
88 /* If the function is returning a `struct', then the first word
89 (which will be passed in r3) is used for struct return
90 address. In that case we should advance one word and start
91 from r4 register to copy parameters. */
95 regcache_cooked_write_signed (regcache
,
96 tdep
->ppc_gp0_regnum
+ greg
,
101 for (argno
= 0; argno
< nargs
; argno
++)
103 struct value
*arg
= args
[argno
];
104 struct type
*type
= check_typedef (value_type (arg
));
105 int len
= TYPE_LENGTH (type
);
106 const bfd_byte
*val
= value_contents (arg
);
108 if (TYPE_CODE (type
) == TYPE_CODE_FLT
&& len
<= 8
109 && !tdep
->soft_float
)
111 /* Floating point value converted to "double" then
112 passed in an FP register, when the registers run out,
113 8 byte aligned stack is used. */
118 /* Always store the floating point value using
119 the register's floating-point format. */
120 gdb_byte regval
[MAX_REGISTER_SIZE
];
122 = register_type (gdbarch
, tdep
->ppc_fp0_regnum
+ freg
);
123 convert_typed_floating (val
, type
, regval
, regtype
);
124 regcache_cooked_write (regcache
,
125 tdep
->ppc_fp0_regnum
+ freg
,
132 /* SysV ABI converts floats to doubles before
133 writing them to an 8 byte aligned stack location. */
134 argoffset
= align_up (argoffset
, 8);
138 convert_typed_floating (val
, type
, memval
,
139 builtin_type_ieee_double
);
140 write_memory (sp
+ argoffset
, val
, len
);
145 else if (TYPE_CODE (type
) == TYPE_CODE_FLT
148 && (gdbarch_long_double_format (gdbarch
)
149 == floatformats_ibm_long_double
))
151 /* IBM long double passed in two FP registers if
152 available, otherwise 8-byte aligned stack. */
157 regcache_cooked_write (regcache
,
158 tdep
->ppc_fp0_regnum
+ freg
,
160 regcache_cooked_write (regcache
,
161 tdep
->ppc_fp0_regnum
+ freg
+ 1,
168 argoffset
= align_up (argoffset
, 8);
170 write_memory (sp
+ argoffset
, val
, len
);
175 && (TYPE_CODE (type
) == TYPE_CODE_INT
/* long long */
176 || TYPE_CODE (type
) == TYPE_CODE_FLT
)) /* double */
178 /* "long long" or soft-float "double" passed in an odd/even
179 register pair with the low addressed word in the odd
180 register and the high addressed word in the even
181 register, or when the registers run out an 8 byte
182 aligned stack location. */
185 /* Just in case GREG was 10. */
187 argoffset
= align_up (argoffset
, 8);
189 write_memory (sp
+ argoffset
, val
, len
);
194 /* Must start on an odd register - r3/r4 etc. */
199 regcache_cooked_write (regcache
,
200 tdep
->ppc_gp0_regnum
+ greg
+ 0,
202 regcache_cooked_write (regcache
,
203 tdep
->ppc_gp0_regnum
+ greg
+ 1,
209 else if (len
== 16 && TYPE_CODE (type
) == TYPE_CODE_FLT
210 && (gdbarch_long_double_format (gdbarch
)
211 == floatformats_ibm_long_double
))
213 /* Soft-float IBM long double passed in four consecutive
214 registers, or on the stack. The registers are not
215 necessarily odd/even pairs. */
219 argoffset
= align_up (argoffset
, 8);
221 write_memory (sp
+ argoffset
, val
, len
);
228 regcache_cooked_write (regcache
,
229 tdep
->ppc_gp0_regnum
+ greg
+ 0,
231 regcache_cooked_write (regcache
,
232 tdep
->ppc_gp0_regnum
+ greg
+ 1,
234 regcache_cooked_write (regcache
,
235 tdep
->ppc_gp0_regnum
+ greg
+ 2,
237 regcache_cooked_write (regcache
,
238 tdep
->ppc_gp0_regnum
+ greg
+ 3,
244 else if (TYPE_CODE (type
) == TYPE_CODE_DECFLOAT
&& len
<= 8
245 && !tdep
->soft_float
)
247 /* 32-bit and 64-bit decimal floats go in f1 .. f8. They can
254 gdb_byte regval
[MAX_REGISTER_SIZE
];
257 /* 32-bit decimal floats are right aligned in the
259 if (TYPE_LENGTH (type
) == 4)
261 memcpy (regval
+ 4, val
, 4);
267 regcache_cooked_write (regcache
,
268 tdep
->ppc_fp0_regnum
+ freg
, p
);
275 argoffset
= align_up (argoffset
, len
);
278 /* Write value in the stack's parameter save area. */
279 write_memory (sp
+ argoffset
, val
, len
);
284 else if (TYPE_CODE (type
) == TYPE_CODE_DECFLOAT
&& len
== 16
285 && !tdep
->soft_float
)
287 /* 128-bit decimal floats go in f2 .. f7, always in even/odd
288 pairs. They can end up in memory, using two doublewords. */
292 /* Make sure freg is even. */
297 regcache_cooked_write (regcache
,
298 tdep
->ppc_fp0_regnum
+ freg
, val
);
299 regcache_cooked_write (regcache
,
300 tdep
->ppc_fp0_regnum
+ freg
+ 1, val
+ 8);
305 argoffset
= align_up (argoffset
, 8);
308 write_memory (sp
+ argoffset
, val
, 16);
313 /* If a 128-bit decimal float goes to the stack because only f7
314 and f8 are free (thus there's no even/odd register pair
315 available), these registers should be marked as occupied.
316 Hence we increase freg even when writing to memory. */
320 && TYPE_CODE (type
) == TYPE_CODE_ARRAY
321 && TYPE_VECTOR (type
)
322 && tdep
->vector_abi
== POWERPC_VEC_ALTIVEC
)
324 /* Vector parameter passed in an Altivec register, or
325 when that runs out, 16 byte aligned stack location. */
329 regcache_cooked_write (regcache
,
330 tdep
->ppc_vr0_regnum
+ vreg
, val
);
335 argoffset
= align_up (argoffset
, 16);
337 write_memory (sp
+ argoffset
, val
, 16);
342 && TYPE_CODE (type
) == TYPE_CODE_ARRAY
343 && TYPE_VECTOR (type
)
344 && tdep
->vector_abi
== POWERPC_VEC_SPE
)
346 /* Vector parameter passed in an e500 register, or when
347 that runs out, 8 byte aligned stack location. Note
348 that since e500 vector and general purpose registers
349 both map onto the same underlying register set, a
350 "greg" and not a "vreg" is consumed here. A cooked
351 write stores the value in the correct locations
352 within the raw register cache. */
356 regcache_cooked_write (regcache
,
357 tdep
->ppc_ev0_regnum
+ greg
, val
);
362 argoffset
= align_up (argoffset
, 8);
364 write_memory (sp
+ argoffset
, val
, 8);
370 /* Reduce the parameter down to something that fits in a
372 gdb_byte word
[MAX_REGISTER_SIZE
];
373 memset (word
, 0, MAX_REGISTER_SIZE
);
374 if (len
> tdep
->wordsize
375 || TYPE_CODE (type
) == TYPE_CODE_STRUCT
376 || TYPE_CODE (type
) == TYPE_CODE_UNION
)
378 /* Structs and large values are put in an
379 aligned stack slot ... */
380 if (TYPE_CODE (type
) == TYPE_CODE_ARRAY
381 && TYPE_VECTOR (type
)
383 structoffset
= align_up (structoffset
, 16);
385 structoffset
= align_up (structoffset
, 8);
388 write_memory (sp
+ structoffset
, val
, len
);
389 /* ... and then a "word" pointing to that address is
390 passed as the parameter. */
391 store_unsigned_integer (word
, tdep
->wordsize
,
395 else if (TYPE_CODE (type
) == TYPE_CODE_INT
)
396 /* Sign or zero extend the "int" into a "word". */
397 store_unsigned_integer (word
, tdep
->wordsize
,
398 unpack_long (type
, val
));
400 /* Always goes in the low address. */
401 memcpy (word
, val
, len
);
402 /* Store that "word" in a register, or on the stack.
403 The words have "4" byte alignment. */
407 regcache_cooked_write (regcache
,
408 tdep
->ppc_gp0_regnum
+ greg
, word
);
413 argoffset
= align_up (argoffset
, tdep
->wordsize
);
415 write_memory (sp
+ argoffset
, word
, tdep
->wordsize
);
416 argoffset
+= tdep
->wordsize
;
421 /* Compute the actual stack space requirements. */
424 /* Remember the amount of space needed by the arguments. */
425 argspace
= argoffset
;
426 /* Allocate space for both the arguments and the structures. */
427 sp
-= (argoffset
+ structoffset
);
428 /* Ensure that the stack is still 16 byte aligned. */
429 sp
= align_down (sp
, 16);
432 /* The psABI says that "A caller of a function that takes a
433 variable argument list shall set condition register bit 6 to
434 1 if it passes one or more arguments in the floating-point
435 registers. It is strongly recommended that the caller set the
436 bit to 0 otherwise..." Doing this for normal functions too
442 regcache_cooked_read_unsigned (regcache
, tdep
->ppc_cr_regnum
, &cr
);
447 regcache_cooked_write_unsigned (regcache
, tdep
->ppc_cr_regnum
, cr
);
452 regcache_cooked_write_signed (regcache
, gdbarch_sp_regnum (gdbarch
), sp
);
454 /* Write the backchain (it occupies WORDSIZED bytes). */
455 write_memory_signed_integer (sp
, tdep
->wordsize
, saved_sp
);
457 /* Point the inferior function call's return address at the dummy's
459 regcache_cooked_write_signed (regcache
, tdep
->ppc_lr_regnum
, bp_addr
);
464 /* Handle the return-value conventions for Decimal Floating Point values
465 in both ppc32 and ppc64, which are the same. */
467 get_decimal_float_return_value (struct gdbarch
*gdbarch
, struct type
*valtype
,
468 struct regcache
*regcache
, gdb_byte
*readbuf
,
469 const gdb_byte
*writebuf
)
471 struct gdbarch_tdep
*tdep
= gdbarch_tdep (gdbarch
);
473 gdb_assert (TYPE_CODE (valtype
) == TYPE_CODE_DECFLOAT
);
475 /* 32-bit and 64-bit decimal floats in f1. */
476 if (TYPE_LENGTH (valtype
) <= 8)
478 if (writebuf
!= NULL
)
480 gdb_byte regval
[MAX_REGISTER_SIZE
];
483 /* 32-bit decimal float is right aligned in the doubleword. */
484 if (TYPE_LENGTH (valtype
) == 4)
486 memcpy (regval
+ 4, writebuf
, 4);
492 regcache_cooked_write (regcache
, tdep
->ppc_fp0_regnum
+ 1, p
);
496 regcache_cooked_read (regcache
, tdep
->ppc_fp0_regnum
+ 1, readbuf
);
498 /* Left align 32-bit decimal float. */
499 if (TYPE_LENGTH (valtype
) == 4)
500 memcpy (readbuf
, readbuf
+ 4, 4);
503 /* 128-bit decimal floats in f2,f3. */
504 else if (TYPE_LENGTH (valtype
) == 16)
506 if (writebuf
!= NULL
|| readbuf
!= NULL
)
510 for (i
= 0; i
< 2; i
++)
512 if (writebuf
!= NULL
)
513 regcache_cooked_write (regcache
, tdep
->ppc_fp0_regnum
+ 2 + i
,
516 regcache_cooked_read (regcache
, tdep
->ppc_fp0_regnum
+ 2 + i
,
523 internal_error (__FILE__
, __LINE__
, "Unknown decimal float size.");
525 return RETURN_VALUE_REGISTER_CONVENTION
;
528 /* Handle the return-value conventions specified by the SysV 32-bit
529 PowerPC ABI (including all the supplements):
531 no floating-point: floating-point values returned using 32-bit
532 general-purpose registers.
534 Altivec: 128-bit vectors returned using vector registers.
536 e500: 64-bit vectors returned using the full full 64 bit EV
537 register, floating-point values returned using 32-bit
538 general-purpose registers.
540 GCC (broken): Small struct values right (instead of left) aligned
541 when returned in general-purpose registers. */
543 static enum return_value_convention
544 do_ppc_sysv_return_value (struct gdbarch
*gdbarch
, struct type
*type
,
545 struct regcache
*regcache
, gdb_byte
*readbuf
,
546 const gdb_byte
*writebuf
, int broken_gcc
)
548 struct gdbarch_tdep
*tdep
= gdbarch_tdep (gdbarch
);
549 gdb_assert (tdep
->wordsize
== 4);
550 if (TYPE_CODE (type
) == TYPE_CODE_FLT
551 && TYPE_LENGTH (type
) <= 8
552 && !tdep
->soft_float
)
556 /* Floats and doubles stored in "f1". Convert the value to
557 the required type. */
558 gdb_byte regval
[MAX_REGISTER_SIZE
];
559 struct type
*regtype
= register_type (gdbarch
,
560 tdep
->ppc_fp0_regnum
+ 1);
561 regcache_cooked_read (regcache
, tdep
->ppc_fp0_regnum
+ 1, regval
);
562 convert_typed_floating (regval
, regtype
, readbuf
, type
);
566 /* Floats and doubles stored in "f1". Convert the value to
567 the register's "double" type. */
568 gdb_byte regval
[MAX_REGISTER_SIZE
];
569 struct type
*regtype
= register_type (gdbarch
, tdep
->ppc_fp0_regnum
);
570 convert_typed_floating (writebuf
, type
, regval
, regtype
);
571 regcache_cooked_write (regcache
, tdep
->ppc_fp0_regnum
+ 1, regval
);
573 return RETURN_VALUE_REGISTER_CONVENTION
;
575 if (TYPE_CODE (type
) == TYPE_CODE_FLT
576 && TYPE_LENGTH (type
) == 16
578 && (gdbarch_long_double_format (gdbarch
) == floatformats_ibm_long_double
))
580 /* IBM long double stored in f1 and f2. */
583 regcache_cooked_read (regcache
, tdep
->ppc_fp0_regnum
+ 1, readbuf
);
584 regcache_cooked_read (regcache
, tdep
->ppc_fp0_regnum
+ 2,
589 regcache_cooked_write (regcache
, tdep
->ppc_fp0_regnum
+ 1, writebuf
);
590 regcache_cooked_write (regcache
, tdep
->ppc_fp0_regnum
+ 2,
593 return RETURN_VALUE_REGISTER_CONVENTION
;
595 if (TYPE_CODE (type
) == TYPE_CODE_FLT
596 && TYPE_LENGTH (type
) == 16
597 && (gdbarch_long_double_format (gdbarch
) == floatformats_ibm_long_double
))
599 /* Soft-float IBM long double stored in r3, r4, r5, r6. */
602 regcache_cooked_read (regcache
, tdep
->ppc_gp0_regnum
+ 3, readbuf
);
603 regcache_cooked_read (regcache
, tdep
->ppc_gp0_regnum
+ 4,
605 regcache_cooked_read (regcache
, tdep
->ppc_gp0_regnum
+ 5,
607 regcache_cooked_read (regcache
, tdep
->ppc_gp0_regnum
+ 6,
612 regcache_cooked_write (regcache
, tdep
->ppc_gp0_regnum
+ 3, writebuf
);
613 regcache_cooked_write (regcache
, tdep
->ppc_gp0_regnum
+ 4,
615 regcache_cooked_write (regcache
, tdep
->ppc_gp0_regnum
+ 5,
617 regcache_cooked_write (regcache
, tdep
->ppc_gp0_regnum
+ 6,
620 return RETURN_VALUE_REGISTER_CONVENTION
;
622 if ((TYPE_CODE (type
) == TYPE_CODE_INT
&& TYPE_LENGTH (type
) == 8)
623 || (TYPE_CODE (type
) == TYPE_CODE_FLT
&& TYPE_LENGTH (type
) == 8))
627 /* A long long, or a double stored in the 32 bit r3/r4. */
628 regcache_cooked_read (regcache
, tdep
->ppc_gp0_regnum
+ 3,
630 regcache_cooked_read (regcache
, tdep
->ppc_gp0_regnum
+ 4,
635 /* A long long, or a double stored in the 32 bit r3/r4. */
636 regcache_cooked_write (regcache
, tdep
->ppc_gp0_regnum
+ 3,
638 regcache_cooked_write (regcache
, tdep
->ppc_gp0_regnum
+ 4,
641 return RETURN_VALUE_REGISTER_CONVENTION
;
643 if (TYPE_CODE (type
) == TYPE_CODE_DECFLOAT
&& !tdep
->soft_float
)
644 return get_decimal_float_return_value (gdbarch
, type
, regcache
, readbuf
,
646 else if ((TYPE_CODE (type
) == TYPE_CODE_INT
647 || TYPE_CODE (type
) == TYPE_CODE_CHAR
648 || TYPE_CODE (type
) == TYPE_CODE_BOOL
649 || TYPE_CODE (type
) == TYPE_CODE_PTR
650 || TYPE_CODE (type
) == TYPE_CODE_REF
651 || TYPE_CODE (type
) == TYPE_CODE_ENUM
)
652 && TYPE_LENGTH (type
) <= tdep
->wordsize
)
656 /* Some sort of integer stored in r3. Since TYPE isn't
657 bigger than the register, sign extension isn't a problem
658 - just do everything unsigned. */
660 regcache_cooked_read_unsigned (regcache
, tdep
->ppc_gp0_regnum
+ 3,
662 store_unsigned_integer (readbuf
, TYPE_LENGTH (type
), regval
);
666 /* Some sort of integer stored in r3. Use unpack_long since
667 that should handle any required sign extension. */
668 regcache_cooked_write_unsigned (regcache
, tdep
->ppc_gp0_regnum
+ 3,
669 unpack_long (type
, writebuf
));
671 return RETURN_VALUE_REGISTER_CONVENTION
;
673 if (TYPE_LENGTH (type
) == 16
674 && TYPE_CODE (type
) == TYPE_CODE_ARRAY
675 && TYPE_VECTOR (type
)
676 && tdep
->vector_abi
== POWERPC_VEC_ALTIVEC
)
680 /* Altivec places the return value in "v2". */
681 regcache_cooked_read (regcache
, tdep
->ppc_vr0_regnum
+ 2, readbuf
);
685 /* Altivec places the return value in "v2". */
686 regcache_cooked_write (regcache
, tdep
->ppc_vr0_regnum
+ 2, writebuf
);
688 return RETURN_VALUE_REGISTER_CONVENTION
;
690 if (TYPE_LENGTH (type
) == 16
691 && TYPE_CODE (type
) == TYPE_CODE_ARRAY
692 && TYPE_VECTOR (type
)
693 && tdep
->vector_abi
== POWERPC_VEC_GENERIC
)
695 /* GCC -maltivec -mabi=no-altivec returns vectors in r3/r4/r5/r6.
696 GCC without AltiVec returns them in memory, but it warns about
697 ABI risks in that case; we don't try to support it. */
700 regcache_cooked_read (regcache
, tdep
->ppc_gp0_regnum
+ 3,
702 regcache_cooked_read (regcache
, tdep
->ppc_gp0_regnum
+ 4,
704 regcache_cooked_read (regcache
, tdep
->ppc_gp0_regnum
+ 5,
706 regcache_cooked_read (regcache
, tdep
->ppc_gp0_regnum
+ 6,
711 regcache_cooked_write (regcache
, tdep
->ppc_gp0_regnum
+ 3,
713 regcache_cooked_write (regcache
, tdep
->ppc_gp0_regnum
+ 4,
715 regcache_cooked_write (regcache
, tdep
->ppc_gp0_regnum
+ 5,
717 regcache_cooked_write (regcache
, tdep
->ppc_gp0_regnum
+ 6,
720 return RETURN_VALUE_REGISTER_CONVENTION
;
722 if (TYPE_LENGTH (type
) == 8
723 && TYPE_CODE (type
) == TYPE_CODE_ARRAY
724 && TYPE_VECTOR (type
)
725 && tdep
->vector_abi
== POWERPC_VEC_SPE
)
727 /* The e500 ABI places return values for the 64-bit DSP types
728 (__ev64_opaque__) in r3. However, in GDB-speak, ev3
729 corresponds to the entire r3 value for e500, whereas GDB's r3
730 only corresponds to the least significant 32-bits. So place
731 the 64-bit DSP type's value in ev3. */
733 regcache_cooked_read (regcache
, tdep
->ppc_ev0_regnum
+ 3, readbuf
);
735 regcache_cooked_write (regcache
, tdep
->ppc_ev0_regnum
+ 3, writebuf
);
736 return RETURN_VALUE_REGISTER_CONVENTION
;
738 if (broken_gcc
&& TYPE_LENGTH (type
) <= 8)
740 /* GCC screwed up for structures or unions whose size is less
741 than or equal to 8 bytes.. Instead of left-aligning, it
742 right-aligns the data into the buffer formed by r3, r4. */
743 gdb_byte regvals
[MAX_REGISTER_SIZE
* 2];
744 int len
= TYPE_LENGTH (type
);
745 int offset
= (2 * tdep
->wordsize
- len
) % tdep
->wordsize
;
749 regcache_cooked_read (regcache
, tdep
->ppc_gp0_regnum
+ 3,
750 regvals
+ 0 * tdep
->wordsize
);
751 if (len
> tdep
->wordsize
)
752 regcache_cooked_read (regcache
, tdep
->ppc_gp0_regnum
+ 4,
753 regvals
+ 1 * tdep
->wordsize
);
754 memcpy (readbuf
, regvals
+ offset
, len
);
758 memset (regvals
, 0, sizeof regvals
);
759 memcpy (regvals
+ offset
, writebuf
, len
);
760 regcache_cooked_write (regcache
, tdep
->ppc_gp0_regnum
+ 3,
761 regvals
+ 0 * tdep
->wordsize
);
762 if (len
> tdep
->wordsize
)
763 regcache_cooked_write (regcache
, tdep
->ppc_gp0_regnum
+ 4,
764 regvals
+ 1 * tdep
->wordsize
);
767 return RETURN_VALUE_REGISTER_CONVENTION
;
769 if (TYPE_LENGTH (type
) <= 8)
773 /* This matches SVr4 PPC, it does not match GCC. */
774 /* The value is right-padded to 8 bytes and then loaded, as
775 two "words", into r3/r4. */
776 gdb_byte regvals
[MAX_REGISTER_SIZE
* 2];
777 regcache_cooked_read (regcache
, tdep
->ppc_gp0_regnum
+ 3,
778 regvals
+ 0 * tdep
->wordsize
);
779 if (TYPE_LENGTH (type
) > tdep
->wordsize
)
780 regcache_cooked_read (regcache
, tdep
->ppc_gp0_regnum
+ 4,
781 regvals
+ 1 * tdep
->wordsize
);
782 memcpy (readbuf
, regvals
, TYPE_LENGTH (type
));
786 /* This matches SVr4 PPC, it does not match GCC. */
787 /* The value is padded out to 8 bytes and then loaded, as
788 two "words" into r3/r4. */
789 gdb_byte regvals
[MAX_REGISTER_SIZE
* 2];
790 memset (regvals
, 0, sizeof regvals
);
791 memcpy (regvals
, writebuf
, TYPE_LENGTH (type
));
792 regcache_cooked_write (regcache
, tdep
->ppc_gp0_regnum
+ 3,
793 regvals
+ 0 * tdep
->wordsize
);
794 if (TYPE_LENGTH (type
) > tdep
->wordsize
)
795 regcache_cooked_write (regcache
, tdep
->ppc_gp0_regnum
+ 4,
796 regvals
+ 1 * tdep
->wordsize
);
798 return RETURN_VALUE_REGISTER_CONVENTION
;
800 return RETURN_VALUE_STRUCT_CONVENTION
;
803 enum return_value_convention
804 ppc_sysv_abi_return_value (struct gdbarch
*gdbarch
, struct type
*valtype
,
805 struct regcache
*regcache
, gdb_byte
*readbuf
,
806 const gdb_byte
*writebuf
)
808 return do_ppc_sysv_return_value (gdbarch
, valtype
, regcache
, readbuf
,
812 enum return_value_convention
813 ppc_sysv_abi_broken_return_value (struct gdbarch
*gdbarch
,
814 struct type
*valtype
,
815 struct regcache
*regcache
,
816 gdb_byte
*readbuf
, const gdb_byte
*writebuf
)
818 return do_ppc_sysv_return_value (gdbarch
, valtype
, regcache
, readbuf
,
822 /* The helper function for 64-bit SYSV push_dummy_call. Converts the
823 function's code address back into the function's descriptor
826 Find a value for the TOC register. Every symbol should have both
827 ".FN" and "FN" in the minimal symbol table. "FN" points at the
828 FN's descriptor, while ".FN" points at the entry point (which
829 matches FUNC_ADDR). Need to reverse from FUNC_ADDR back to the
830 FN's descriptor address (while at the same time being careful to
831 find "FN" in the same object file as ".FN"). */
834 convert_code_addr_to_desc_addr (CORE_ADDR code_addr
, CORE_ADDR
*desc_addr
)
836 struct obj_section
*dot_fn_section
;
837 struct minimal_symbol
*dot_fn
;
838 struct minimal_symbol
*fn
;
840 /* Find the minimal symbol that corresponds to CODE_ADDR (should
841 have a name of the form ".FN"). */
842 dot_fn
= lookup_minimal_symbol_by_pc (code_addr
);
843 if (dot_fn
== NULL
|| SYMBOL_LINKAGE_NAME (dot_fn
)[0] != '.')
845 /* Get the section that contains CODE_ADDR. Need this for the
846 "objfile" that it contains. */
847 dot_fn_section
= find_pc_section (code_addr
);
848 if (dot_fn_section
== NULL
|| dot_fn_section
->objfile
== NULL
)
850 /* Now find the corresponding "FN" (dropping ".") minimal symbol's
851 address. Only look for the minimal symbol in ".FN"'s object file
852 - avoids problems when two object files (i.e., shared libraries)
853 contain a minimal symbol with the same name. */
854 fn
= lookup_minimal_symbol (SYMBOL_LINKAGE_NAME (dot_fn
) + 1, NULL
,
855 dot_fn_section
->objfile
);
858 /* Found a descriptor. */
859 (*desc_addr
) = SYMBOL_VALUE_ADDRESS (fn
);
863 /* Pass the arguments in either registers, or in the stack. Using the
866 This implements a dumbed down version of the ABI. It always writes
867 values to memory, GPR and FPR, even when not necessary. Doing this
868 greatly simplifies the logic. */
871 ppc64_sysv_abi_push_dummy_call (struct gdbarch
*gdbarch
, struct value
*function
,
872 struct regcache
*regcache
, CORE_ADDR bp_addr
,
873 int nargs
, struct value
**args
, CORE_ADDR sp
,
874 int struct_return
, CORE_ADDR struct_addr
)
876 CORE_ADDR func_addr
= find_function_addr (function
, NULL
);
877 struct gdbarch_tdep
*tdep
= gdbarch_tdep (gdbarch
);
879 /* See for-loop comment below. */
881 /* Size of the Altivec's vector parameter region, the final value is
882 computed in the for-loop below. */
883 LONGEST vparam_size
= 0;
884 /* Size of the general parameter region, the final value is computed
885 in the for-loop below. */
886 LONGEST gparam_size
= 0;
887 /* Kevin writes ... I don't mind seeing tdep->wordsize used in the
888 calls to align_up(), align_down(), etc. because this makes it
889 easier to reuse this code (in a copy/paste sense) in the future,
890 but it is a 64-bit ABI and asserting that the wordsize is 8 bytes
891 at some point makes it easier to verify that this function is
892 correct without having to do a non-local analysis to figure out
893 the possible values of tdep->wordsize. */
894 gdb_assert (tdep
->wordsize
== 8);
896 /* This function exists to support a calling convention that
897 requires floating-point registers. It shouldn't be used on
898 processors that lack them. */
899 gdb_assert (ppc_floating_point_unit_p (gdbarch
));
901 /* By this stage in the proceedings, SP has been decremented by "red
902 zone size" + "struct return size". Fetch the stack-pointer from
903 before this and use that as the BACK_CHAIN. */
904 regcache_cooked_read_unsigned (regcache
, gdbarch_sp_regnum (gdbarch
),
907 /* Go through the argument list twice.
909 Pass 1: Compute the function call's stack space and register
912 Pass 2: Replay the same computation but this time also write the
913 values out to the target. */
915 for (write_pass
= 0; write_pass
< 2; write_pass
++)
918 /* Next available floating point register for float and double
921 /* Next available general register for non-vector (but possibly
924 /* Next available vector register for vector arguments. */
926 /* The address, at which the next general purpose parameter
927 (integer, struct, float, ...) should be saved. */
929 /* Address, at which the next Altivec vector parameter should be
935 /* During the first pass, GPARAM and VPARAM are more like
936 offsets (start address zero) than addresses. That way
937 the accumulate the total stack space each region
944 /* Decrement the stack pointer making space for the Altivec
945 and general on-stack parameters. Set vparam and gparam
946 to their corresponding regions. */
947 vparam
= align_down (sp
- vparam_size
, 16);
948 gparam
= align_down (vparam
- gparam_size
, 16);
949 /* Add in space for the TOC, link editor double word,
950 compiler double word, LR save area, CR save area. */
951 sp
= align_down (gparam
- 48, 16);
954 /* If the function is returning a `struct', then there is an
955 extra hidden parameter (which will be passed in r3)
956 containing the address of that struct.. In that case we
957 should advance one word and start from r4 register to copy
958 parameters. This also consumes one on-stack parameter slot. */
962 regcache_cooked_write_signed (regcache
,
963 tdep
->ppc_gp0_regnum
+ greg
,
966 gparam
= align_up (gparam
+ tdep
->wordsize
, tdep
->wordsize
);
969 for (argno
= 0; argno
< nargs
; argno
++)
971 struct value
*arg
= args
[argno
];
972 struct type
*type
= check_typedef (value_type (arg
));
973 const bfd_byte
*val
= value_contents (arg
);
974 if (TYPE_CODE (type
) == TYPE_CODE_FLT
&& TYPE_LENGTH (type
) <= 8)
976 /* Floats and Doubles go in f1 .. f13. They also
977 consume a left aligned GREG,, and can end up in
983 gdb_byte regval
[MAX_REGISTER_SIZE
];
985 = register_type (gdbarch
, tdep
->ppc_fp0_regnum
);
986 convert_typed_floating (val
, type
, regval
, regtype
);
987 regcache_cooked_write (regcache
,
988 tdep
->ppc_fp0_regnum
+ freg
,
993 /* The ABI states "Single precision floating
994 point values are mapped to the first word in
995 a single doubleword" and "... floating point
996 values mapped to the first eight doublewords
997 of the parameter save area are also passed in
1000 This code interprets that to mean: store it,
1001 left aligned, in the general register. */
1002 gdb_byte regval
[MAX_REGISTER_SIZE
];
1003 memset (regval
, 0, sizeof regval
);
1004 memcpy (regval
, val
, TYPE_LENGTH (type
));
1005 regcache_cooked_write (regcache
,
1006 tdep
->ppc_gp0_regnum
+ greg
,
1009 write_memory (gparam
, val
, TYPE_LENGTH (type
));
1011 /* Always consume parameter stack space. */
1014 gparam
= align_up (gparam
+ TYPE_LENGTH (type
), tdep
->wordsize
);
1016 else if (TYPE_CODE (type
) == TYPE_CODE_FLT
1017 && TYPE_LENGTH (type
) == 16
1018 && (gdbarch_long_double_format (gdbarch
)
1019 == floatformats_ibm_long_double
))
1021 /* IBM long double stored in two doublewords of the
1022 parameter save area and corresponding registers. */
1025 if (!tdep
->soft_float
&& freg
<= 13)
1027 regcache_cooked_write (regcache
,
1028 tdep
->ppc_fp0_regnum
+ freg
,
1031 regcache_cooked_write (regcache
,
1032 tdep
->ppc_fp0_regnum
+ freg
+ 1,
1037 regcache_cooked_write (regcache
,
1038 tdep
->ppc_gp0_regnum
+ greg
,
1041 regcache_cooked_write (regcache
,
1042 tdep
->ppc_gp0_regnum
+ greg
+ 1,
1045 write_memory (gparam
, val
, TYPE_LENGTH (type
));
1049 gparam
= align_up (gparam
+ TYPE_LENGTH (type
), tdep
->wordsize
);
1051 else if (TYPE_CODE (type
) == TYPE_CODE_DECFLOAT
1052 && TYPE_LENGTH (type
) <= 8)
1054 /* 32-bit and 64-bit decimal floats go in f1 .. f13. They can
1055 end up in memory. */
1058 gdb_byte regval
[MAX_REGISTER_SIZE
];
1061 /* 32-bit decimal floats are right aligned in the
1063 if (TYPE_LENGTH (type
) == 4)
1065 memcpy (regval
+ 4, val
, 4);
1071 /* Write value in the stack's parameter save area. */
1072 write_memory (gparam
, p
, 8);
1075 regcache_cooked_write (regcache
,
1076 tdep
->ppc_fp0_regnum
+ freg
, p
);
1081 /* Always consume parameter stack space. */
1082 gparam
= align_up (gparam
+ 8, tdep
->wordsize
);
1084 else if (TYPE_CODE (type
) == TYPE_CODE_DECFLOAT
&&
1085 TYPE_LENGTH (type
) == 16)
1087 /* 128-bit decimal floats go in f2 .. f12, always in even/odd
1088 pairs. They can end up in memory, using two doublewords. */
1093 /* Make sure freg is even. */
1095 regcache_cooked_write (regcache
,
1096 tdep
->ppc_fp0_regnum
+ freg
, val
);
1097 regcache_cooked_write (regcache
,
1098 tdep
->ppc_fp0_regnum
+ freg
+ 1, val
+ 8);
1101 write_memory (gparam
, val
, TYPE_LENGTH (type
));
1106 gparam
= align_up (gparam
+ TYPE_LENGTH (type
), tdep
->wordsize
);
1108 else if (TYPE_LENGTH (type
) == 16 && TYPE_VECTOR (type
)
1109 && TYPE_CODE (type
) == TYPE_CODE_ARRAY
1110 && tdep
->ppc_vr0_regnum
>= 0)
1112 /* In the Altivec ABI, vectors go in the vector
1113 registers v2 .. v13, or when that runs out, a vector
1114 annex which goes above all the normal parameters.
1115 NOTE: cagney/2003-09-21: This is a guess based on the
1116 PowerOpen Altivec ABI. */
1120 regcache_cooked_write (regcache
,
1121 tdep
->ppc_vr0_regnum
+ vreg
, val
);
1127 write_memory (vparam
, val
, TYPE_LENGTH (type
));
1128 vparam
= align_up (vparam
+ TYPE_LENGTH (type
), 16);
1131 else if ((TYPE_CODE (type
) == TYPE_CODE_INT
1132 || TYPE_CODE (type
) == TYPE_CODE_ENUM
1133 || TYPE_CODE (type
) == TYPE_CODE_PTR
)
1134 && TYPE_LENGTH (type
) <= 8)
1136 /* Scalars and Pointers get sign[un]extended and go in
1137 gpr3 .. gpr10. They can also end up in memory. */
1140 /* Sign extend the value, then store it unsigned. */
1141 ULONGEST word
= unpack_long (type
, val
);
1142 /* Convert any function code addresses into
1144 if (TYPE_CODE (type
) == TYPE_CODE_PTR
1145 && TYPE_CODE (TYPE_TARGET_TYPE (type
)) == TYPE_CODE_FUNC
)
1147 CORE_ADDR desc
= word
;
1148 convert_code_addr_to_desc_addr (word
, &desc
);
1152 regcache_cooked_write_unsigned (regcache
,
1153 tdep
->ppc_gp0_regnum
+
1155 write_memory_unsigned_integer (gparam
, tdep
->wordsize
,
1159 gparam
= align_up (gparam
+ TYPE_LENGTH (type
), tdep
->wordsize
);
1164 for (byte
= 0; byte
< TYPE_LENGTH (type
);
1165 byte
+= tdep
->wordsize
)
1167 if (write_pass
&& greg
<= 10)
1169 gdb_byte regval
[MAX_REGISTER_SIZE
];
1170 int len
= TYPE_LENGTH (type
) - byte
;
1171 if (len
> tdep
->wordsize
)
1172 len
= tdep
->wordsize
;
1173 memset (regval
, 0, sizeof regval
);
1174 /* The ABI (version 1.9) specifies that values
1175 smaller than one doubleword are right-aligned
1176 and those larger are left-aligned. GCC
1177 versions before 3.4 implemented this
1179 <http://gcc.gnu.org/gcc-3.4/powerpc-abi.html>. */
1181 memcpy (regval
+ tdep
->wordsize
- len
,
1184 memcpy (regval
, val
+ byte
, len
);
1185 regcache_cooked_write (regcache
, greg
, regval
);
1190 /* WARNING: cagney/2003-09-21: Strictly speaking, this
1191 isn't necessary, unfortunately, GCC appears to get
1192 "struct convention" parameter passing wrong putting
1193 odd sized structures in memory instead of in a
1194 register. Work around this by always writing the
1195 value to memory. Fortunately, doing this
1196 simplifies the code. */
1197 write_memory (gparam
, val
, TYPE_LENGTH (type
));
1199 && TYPE_CODE (type
) == TYPE_CODE_STRUCT
1200 && TYPE_NFIELDS (type
) == 1
1201 && TYPE_LENGTH (type
) <= 16)
1203 /* The ABI (version 1.9) specifies that structs
1204 containing a single floating-point value, at any
1205 level of nesting of single-member structs, are
1206 passed in floating-point registers. */
1207 while (TYPE_CODE (type
) == TYPE_CODE_STRUCT
1208 && TYPE_NFIELDS (type
) == 1)
1209 type
= check_typedef (TYPE_FIELD_TYPE (type
, 0));
1210 if (TYPE_CODE (type
) == TYPE_CODE_FLT
)
1212 if (TYPE_LENGTH (type
) <= 8)
1216 gdb_byte regval
[MAX_REGISTER_SIZE
];
1217 struct type
*regtype
1218 = register_type (gdbarch
,
1219 tdep
->ppc_fp0_regnum
);
1220 convert_typed_floating (val
, type
, regval
,
1222 regcache_cooked_write (regcache
,
1223 (tdep
->ppc_fp0_regnum
1229 else if (TYPE_LENGTH (type
) == 16
1230 && (gdbarch_long_double_format (gdbarch
)
1231 == floatformats_ibm_long_double
))
1235 regcache_cooked_write (regcache
,
1236 (tdep
->ppc_fp0_regnum
1240 regcache_cooked_write (regcache
,
1241 (tdep
->ppc_fp0_regnum
1249 /* Always consume parameter stack space. */
1250 gparam
= align_up (gparam
+ TYPE_LENGTH (type
), tdep
->wordsize
);
1256 /* Save the true region sizes ready for the second pass. */
1257 vparam_size
= vparam
;
1258 /* Make certain that the general parameter save area is at
1259 least the minimum 8 registers (or doublewords) in size. */
1261 gparam_size
= 8 * tdep
->wordsize
;
1263 gparam_size
= gparam
;
1268 regcache_cooked_write_signed (regcache
, gdbarch_sp_regnum (gdbarch
), sp
);
1270 /* Write the backchain (it occupies WORDSIZED bytes). */
1271 write_memory_signed_integer (sp
, tdep
->wordsize
, back_chain
);
1273 /* Point the inferior function call's return address at the dummy's
1275 regcache_cooked_write_signed (regcache
, tdep
->ppc_lr_regnum
, bp_addr
);
1277 /* Use the func_addr to find the descriptor, and use that to find
1280 CORE_ADDR desc_addr
;
1281 if (convert_code_addr_to_desc_addr (func_addr
, &desc_addr
))
1283 /* The TOC is the second double word in the descriptor. */
1285 read_memory_unsigned_integer (desc_addr
+ tdep
->wordsize
,
1287 regcache_cooked_write_unsigned (regcache
,
1288 tdep
->ppc_gp0_regnum
+ 2, toc
);
1296 /* The 64 bit ABI return value convention.
1298 Return non-zero if the return-value is stored in a register, return
1299 0 if the return-value is instead stored on the stack (a.k.a.,
1300 struct return convention).
1302 For a return-value stored in a register: when WRITEBUF is non-NULL,
1303 copy the buffer to the corresponding register return-value location
1304 location; when READBUF is non-NULL, fill the buffer from the
1305 corresponding register return-value location. */
1306 enum return_value_convention
1307 ppc64_sysv_abi_return_value (struct gdbarch
*gdbarch
, struct type
*valtype
,
1308 struct regcache
*regcache
, gdb_byte
*readbuf
,
1309 const gdb_byte
*writebuf
)
1311 struct gdbarch_tdep
*tdep
= gdbarch_tdep (gdbarch
);
1313 /* This function exists to support a calling convention that
1314 requires floating-point registers. It shouldn't be used on
1315 processors that lack them. */
1316 gdb_assert (ppc_floating_point_unit_p (gdbarch
));
1318 /* Floats and doubles in F1. */
1319 if (TYPE_CODE (valtype
) == TYPE_CODE_FLT
&& TYPE_LENGTH (valtype
) <= 8)
1321 gdb_byte regval
[MAX_REGISTER_SIZE
];
1322 struct type
*regtype
= register_type (gdbarch
, tdep
->ppc_fp0_regnum
);
1323 if (writebuf
!= NULL
)
1325 convert_typed_floating (writebuf
, valtype
, regval
, regtype
);
1326 regcache_cooked_write (regcache
, tdep
->ppc_fp0_regnum
+ 1, regval
);
1328 if (readbuf
!= NULL
)
1330 regcache_cooked_read (regcache
, tdep
->ppc_fp0_regnum
+ 1, regval
);
1331 convert_typed_floating (regval
, regtype
, readbuf
, valtype
);
1333 return RETURN_VALUE_REGISTER_CONVENTION
;
1335 if (TYPE_CODE (valtype
) == TYPE_CODE_DECFLOAT
)
1336 return get_decimal_float_return_value (gdbarch
, valtype
, regcache
, readbuf
,
1338 /* Integers in r3. */
1339 if ((TYPE_CODE (valtype
) == TYPE_CODE_INT
1340 || TYPE_CODE (valtype
) == TYPE_CODE_ENUM
)
1341 && TYPE_LENGTH (valtype
) <= 8)
1343 if (writebuf
!= NULL
)
1345 /* Be careful to sign extend the value. */
1346 regcache_cooked_write_unsigned (regcache
, tdep
->ppc_gp0_regnum
+ 3,
1347 unpack_long (valtype
, writebuf
));
1349 if (readbuf
!= NULL
)
1351 /* Extract the integer from r3. Since this is truncating the
1352 value, there isn't a sign extension problem. */
1354 regcache_cooked_read_unsigned (regcache
, tdep
->ppc_gp0_regnum
+ 3,
1356 store_unsigned_integer (readbuf
, TYPE_LENGTH (valtype
), regval
);
1358 return RETURN_VALUE_REGISTER_CONVENTION
;
1360 /* All pointers live in r3. */
1361 if (TYPE_CODE (valtype
) == TYPE_CODE_PTR
)
1363 /* All pointers live in r3. */
1364 if (writebuf
!= NULL
)
1365 regcache_cooked_write (regcache
, tdep
->ppc_gp0_regnum
+ 3, writebuf
);
1366 if (readbuf
!= NULL
)
1367 regcache_cooked_read (regcache
, tdep
->ppc_gp0_regnum
+ 3, readbuf
);
1368 return RETURN_VALUE_REGISTER_CONVENTION
;
1370 /* Array type has more than one use. */
1371 if (TYPE_CODE (valtype
) == TYPE_CODE_ARRAY
)
1373 /* Small character arrays are returned, right justified, in r3. */
1374 if (TYPE_LENGTH (valtype
) <= 8
1375 && TYPE_CODE (TYPE_TARGET_TYPE (valtype
)) == TYPE_CODE_INT
1376 && TYPE_LENGTH (TYPE_TARGET_TYPE (valtype
)) == 1)
1378 int offset
= (register_size (gdbarch
, tdep
->ppc_gp0_regnum
+ 3)
1379 - TYPE_LENGTH (valtype
));
1380 if (writebuf
!= NULL
)
1381 regcache_cooked_write_part (regcache
, tdep
->ppc_gp0_regnum
+ 3,
1382 offset
, TYPE_LENGTH (valtype
), writebuf
);
1383 if (readbuf
!= NULL
)
1384 regcache_cooked_read_part (regcache
, tdep
->ppc_gp0_regnum
+ 3,
1385 offset
, TYPE_LENGTH (valtype
), readbuf
);
1386 return RETURN_VALUE_REGISTER_CONVENTION
;
1388 /* A VMX vector is returned in v2. */
1389 if (TYPE_CODE (valtype
) == TYPE_CODE_ARRAY
1390 && TYPE_VECTOR (valtype
) && tdep
->ppc_vr0_regnum
>= 0)
1393 regcache_cooked_read (regcache
, tdep
->ppc_vr0_regnum
+ 2, readbuf
);
1395 regcache_cooked_write (regcache
, tdep
->ppc_vr0_regnum
+ 2, writebuf
);
1396 return RETURN_VALUE_REGISTER_CONVENTION
;
1399 /* Big floating point values get stored in adjacent floating
1400 point registers, starting with F1. */
1401 if (TYPE_CODE (valtype
) == TYPE_CODE_FLT
1402 && (TYPE_LENGTH (valtype
) == 16 || TYPE_LENGTH (valtype
) == 32))
1404 if (writebuf
|| readbuf
!= NULL
)
1407 for (i
= 0; i
< TYPE_LENGTH (valtype
) / 8; i
++)
1409 if (writebuf
!= NULL
)
1410 regcache_cooked_write (regcache
, tdep
->ppc_fp0_regnum
+ 1 + i
,
1411 (const bfd_byte
*) writebuf
+ i
* 8);
1412 if (readbuf
!= NULL
)
1413 regcache_cooked_read (regcache
, tdep
->ppc_fp0_regnum
+ 1 + i
,
1414 (bfd_byte
*) readbuf
+ i
* 8);
1417 return RETURN_VALUE_REGISTER_CONVENTION
;
1419 /* Complex values get returned in f1:f2, need to convert. */
1420 if (TYPE_CODE (valtype
) == TYPE_CODE_COMPLEX
1421 && (TYPE_LENGTH (valtype
) == 8 || TYPE_LENGTH (valtype
) == 16))
1423 if (regcache
!= NULL
)
1426 for (i
= 0; i
< 2; i
++)
1428 gdb_byte regval
[MAX_REGISTER_SIZE
];
1429 struct type
*regtype
=
1430 register_type (gdbarch
, tdep
->ppc_fp0_regnum
);
1431 if (writebuf
!= NULL
)
1433 convert_typed_floating ((const bfd_byte
*) writebuf
+
1434 i
* (TYPE_LENGTH (valtype
) / 2),
1435 valtype
, regval
, regtype
);
1436 regcache_cooked_write (regcache
,
1437 tdep
->ppc_fp0_regnum
+ 1 + i
,
1440 if (readbuf
!= NULL
)
1442 regcache_cooked_read (regcache
,
1443 tdep
->ppc_fp0_regnum
+ 1 + i
,
1445 convert_typed_floating (regval
, regtype
,
1446 (bfd_byte
*) readbuf
+
1447 i
* (TYPE_LENGTH (valtype
) / 2),
1452 return RETURN_VALUE_REGISTER_CONVENTION
;
1454 /* Big complex values get stored in f1:f4. */
1455 if (TYPE_CODE (valtype
) == TYPE_CODE_COMPLEX
&& TYPE_LENGTH (valtype
) == 32)
1457 if (regcache
!= NULL
)
1460 for (i
= 0; i
< 4; i
++)
1462 if (writebuf
!= NULL
)
1463 regcache_cooked_write (regcache
, tdep
->ppc_fp0_regnum
+ 1 + i
,
1464 (const bfd_byte
*) writebuf
+ i
* 8);
1465 if (readbuf
!= NULL
)
1466 regcache_cooked_read (regcache
, tdep
->ppc_fp0_regnum
+ 1 + i
,
1467 (bfd_byte
*) readbuf
+ i
* 8);
1470 return RETURN_VALUE_REGISTER_CONVENTION
;
1472 return RETURN_VALUE_STRUCT_CONVENTION
;
1476 ppc64_sysv_abi_adjust_breakpoint_address (struct gdbarch
*gdbarch
,
1479 /* PPC64 SYSV specifies that the minimal-symbol "FN" should point at
1480 a function-descriptor while the corresponding minimal-symbol
1481 ".FN" should point at the entry point. Consequently, a command
1482 like "break FN" applied to an object file with only minimal
1483 symbols, will insert the breakpoint into the descriptor at "FN"
1484 and not the function at ".FN". Avoid this confusion by adjusting
1485 any attempt to set a descriptor breakpoint into a corresponding
1486 function breakpoint. Note that GDB warns the user when this
1487 adjustment is applied - that's ok as otherwise the user will have
1488 no way of knowing why their breakpoint at "FN" resulted in the
1489 program stopping at ".FN". */
1490 return gdbarch_convert_from_func_ptr_addr (gdbarch
, bpaddr
, ¤t_target
);