Message ID | yddoc9brkjo.fsf@manam.CeBiTec.Uni-Bielefeld.DE |
---|---|
State | New |
Headers | show |
On 11/26/2010 10:45 AM, Rainer Orth wrote: > * src/x86/sysv.S (.eh_frame) [__PIC__ && __sun__ && __svr4__]: Use > datarel encoding. > (.LASFDE1) [__PIC__ && __sun__ && __svr4__]: Use @GOTOFF for FDE > initial location. > (.LASFDE2, LASFDE3): Likewise. This is getting complex enough that I think we should not replicate this logic 4 times. Would you please pull this out into a set of macros near the top of the file? E.g. #if defined __PIC__ # if defined __sun__ && defined __svr4__ # define FDE_ENCODING 0x30 /* datarel */ # define FDE_ENCODE(X) X@GOTOFF # else # define FDE_ENCODING 0x1b /* pcrel sdata4 */ # if defined HAVE_AS_X86_PCREL # define FDE_ENCODE(X) X-. # else # define FDE_ENCODE(X) X@rel # endif # endif #else # define FDE_ENCODING 0 /* absolute */ # define FDE_ENCODE(X) X #endif And, frankly, for gcc 4.7 we ought to consider requiring a recent version of binutils and scrap all of this explicit unwind info in favor of CFI directives. r~
Richard Henderson <rth@redhat.com> writes: > On 11/26/2010 10:45 AM, Rainer Orth wrote: >> * src/x86/sysv.S (.eh_frame) [__PIC__ && __sun__ && __svr4__]: Use >> datarel encoding. >> (.LASFDE1) [__PIC__ && __sun__ && __svr4__]: Use @GOTOFF for FDE >> initial location. >> (.LASFDE2, LASFDE3): Likewise. > > This is getting complex enough that I think we should not > replicate this logic 4 times. Would you please pull this > out into a set of macros near the top of the file? E.g. > > #if defined __PIC__ > # if defined __sun__ && defined __svr4__ > # define FDE_ENCODING 0x30 /* datarel */ > # define FDE_ENCODE(X) X@GOTOFF > # else > # define FDE_ENCODING 0x1b /* pcrel sdata4 */ > # if defined HAVE_AS_X86_PCREL > # define FDE_ENCODE(X) X-. > # else > # define FDE_ENCODE(X) X@rel > # endif > # endif > #else > # define FDE_ENCODING 0 /* absolute */ > # define FDE_ENCODE(X) X > #endif Sure, I'll give this a try. > And, frankly, for gcc 4.7 we ought to consider requiring a > recent version of binutils and scrap all of this explicit > unwind info in favor of CFI directives. We have to be very careful here: libffi is used by several other projects and is supposed to be buildable with vendor compilers and assemblers also. Rainer
diff -r 36d43c8e1be5 libffi/src/x86/sysv.S --- a/libffi/src/x86/sysv.S Sat Nov 20 22:10:07 2010 +0100 +++ b/libffi/src/x86/sysv.S Sat Nov 20 22:10:57 2010 +0100 @@ -354,8 +354,15 @@ .byte 0x8 /* CIE RA Column */ #ifdef __PIC__ .byte 0x1 /* .uleb128 0x1; Augmentation size */ +#ifdef __sun__ && __svr4__ + /* 32-bit Solaris 2/x86 uses datarel encoding for PIC. GNU ld + doesn't correctly sort .eh_frame_hdr with mixed encodings, so + match this. */ + .byte 0x30 /* FDE Encoding (datarel) */ +#else .byte 0x1b /* FDE Encoding (pcrel sdata4) */ #endif +#endif .byte 0xc /* DW_CFA_def_cfa */ .byte 0x4 /* .uleb128 0x4 */ .byte 0x4 /* .uleb128 0x4 */ @@ -367,10 +374,14 @@ .long .LEFDE1-.LASFDE1 /* FDE Length */ .LASFDE1: .long .LASFDE1-.Lframe1 /* FDE CIE offset */ -#if defined __PIC__ && defined HAVE_AS_X86_PCREL - .long .LFB1-. /* FDE initial location */ -#elif defined __PIC__ - .long .LFB1@rel +#ifdef __PIC__ +#if defined __sun__ && defined __svr4__ + .long .LFB1@GOTOFF /* FDE initial location */ +#elif defined HAVE_AS_X86_PCREL + .long .LFB1-. /* FDE initial location */ +#else + .long .LFB1@rel /* FDE initial location */ +#endif #else .long .LFB1 #endif @@ -394,10 +405,14 @@ .long .LEFDE2-.LASFDE2 /* FDE Length */ .LASFDE2: .long .LASFDE2-.Lframe1 /* FDE CIE offset */ -#if defined __PIC__ && defined HAVE_AS_X86_PCREL - .long .LFB2-. /* FDE initial location */ -#elif defined __PIC__ - .long .LFB2@rel +#ifdef __PIC__ +#if defined __sun__ && defined __svr4__ + .long .LFB2@GOTOFF /* FDE initial location */ +#elif defined HAVE_AS_X86_PCREL + .long .LFB2-. /* FDE initial location */ +#else + .long .LFB2@rel /* FDE initial location */ +#endif #else .long .LFB2 #endif @@ -430,10 +445,14 @@ .long .LEFDE3-.LASFDE3 /* FDE Length */ .LASFDE3: .long .LASFDE3-.Lframe1 /* FDE CIE offset */ -#if defined __PIC__ && defined HAVE_AS_X86_PCREL - .long .LFB3-. /* FDE initial location */ -#elif defined __PIC__ - .long .LFB3@rel +#ifdef __PIC__ +#if defined __sun__ && defined __svr4__ + .long .LFB3@GOTOFF /* FDE initial location */ +#elif defined HAVE_AS_X86_PCREL + .long .LFB3-. /* FDE initial location */ +#else + .long .LFB3@rel /* FDE initial location */ +#endif #else .long .LFB3 #endif