This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] Fix ppc64 unwinding problem


On Fri, Jul 11, 2003 at 11:54:25PM -0700, Richard Henderson wrote:
> > ... at the end of CIE cfa program might do the job.
> 
> Actually, it won't.  DW_CFA_expression is defined to yield an address
> (not a value), and thus DW_OP_reg2 doesn't give us what we want.

Isn't it something that should be fixed in the standard?
Whether by adding DW_CFA_expression variant which would push
initially both CFA and the previous address of the register,
or adding some DW_OP_regaddr which would return address of given register
instead of its value.

> We could possibly solve this via magic code in uw_update_context.
> 
> /* If the current unwind info (FS) does not contain explicit info
>    saving R2, then we have to do a minor amount of code reading to
>    figure out if it was saved.  The big problem here is that the 
>    code that does the save/restore is generated by the linker, so
>    we have no good way to determine at compile time what to do.  */
> #define MD_FROB_UPDATE_CONTEXT(CTX, FS)				\
>   do {								\
>     if (FS->regs.reg[2].how == REG_UNSAVED)			\
>       {								\
> 	if (*(unsigned int *)context->ra == 0xE8410028)		\
> 	  _Unwind_SetGRPtr (CTX, 2, CTX->cfa + 16);		\
>       }								\
>   } while (0)
> 
> Which I guess may solve the binary compatibility problem.

The following patch (ATM against gcc-3_2-rhl8-branch, will port it
to trunk and gcc-3_3-branch if you agree with it) seems to work for me,
both on the included cleanup-8.c testcase and separately attached
test (basically the same, but split into a bunch of shared libraries,
so that $r2 restoring is better tested) and also on NPTL make check.
It also fixes accessing below ABI allowed red zone below the stack
(e.g. ppc64 allows 288 bytes below stack, but current unwind-dw2.o
contains:
    242c:       f8 c1 fe d8     std     r6,-296(r1)
    2430:       f8 01 00 10     std     r0,16(r1)
    2434:       91 81 00 08     stw     r12,8(r1)
    2438:       f8 61 fe c0     std     r3,-320(r1)
    243c:       f8 81 fe c8     std     r4,-312(r1)
    2440:       f8 a1 fe d0     std     r5,-304(r1)
).

	Jakub

Attachment: P3
Description: Text document

Attachment: cleanup-test.sh
Description: Bourne shell script


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]