Message ID | yddvd3gpgxi.fsf@manam.CeBiTec.Uni-Bielefeld.DE |
---|---|
State | New |
Headers | show |
Rainer Orth <ro@CeBiTec.Uni-Bielefeld.DE> writes: > Richard Henderson <rth@redhat.com> writes: > >> 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 > > Worked like a charm :-) Bootstrapped without regressions on > i386-pc-solaris2.11 with both as and gas. > > Ok for mainline? Thanks Rainer and Richard. Please go ahead and commit this to the GCC tree. AG > > Rainer > > > 2010-11-27 Richard Henderson <rth@redhat.com> > Rainer Orth <ro@CeBiTec.Uni-Bielefeld.DE> > > libffi: > * src/x86/sysv.S (FDE_ENCODING, FDE_ENCODE): Define. > (.eh_frame): Use FDE_ENCODING. > (.LASFDE1, .LASFDE2, LASFDE3): Simplify with FDE_ENCODE. > > diff -r 82d3ec096908 libffi/src/x86/sysv.S > --- a/libffi/src/x86/sysv.S Sat Nov 27 11:15:48 2010 +0100 > +++ b/libffi/src/x86/sysv.S Sat Nov 27 11:35:38 2010 +0100 > @@ -328,6 +328,25 @@ > .size ffi_closure_raw_SYSV, .-ffi_closure_raw_SYSV > #endif > > +#if defined __PIC__ > +# if defined __sun__ && defined __svr4__ > +/* 32-bit Solaris 2/x86 uses datarel encoding for PIC. GNU ld before 2.22 > + doesn't correctly sort .eh_frame_hdr with mixed encodings, so match this. */ > +# 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 > + > .section .eh_frame,EH_FRAME_FLAGS,@progbits > .Lframe1: > .long .LECIE1-.LSCIE1 /* Length of Common Information Entry */ > @@ -354,7 +373,7 @@ > .byte 0x8 /* CIE RA Column */ > #ifdef __PIC__ > .byte 0x1 /* .uleb128 0x1; Augmentation size */ > - .byte 0x1b /* FDE Encoding (pcrel sdata4) */ > + .byte FDE_ENCODING > #endif > .byte 0xc /* DW_CFA_def_cfa */ > .byte 0x4 /* .uleb128 0x4 */ > @@ -367,14 +386,8 @@ > .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 > -#else > - .long .LFB1 > -#endif > - .long .LFE1-.LFB1 /* FDE address range */ > + .long FDE_ENCODE(.LFB1) /* FDE initial location */ > + .long .LFE1-.LFB1 /* FDE address range */ > #ifdef __PIC__ > .byte 0x0 /* .uleb128 0x0; Augmentation size */ > #endif > @@ -394,14 +407,8 @@ > .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 > -#else > - .long .LFB2 > -#endif > - .long .LFE2-.LFB2 /* FDE address range */ > + .long FDE_ENCODE(.LFB2) /* FDE initial location */ > + .long .LFE2-.LFB2 /* FDE address range */ > #ifdef __PIC__ > .byte 0x0 /* .uleb128 0x0; Augmentation size */ > #endif > @@ -430,14 +437,8 @@ > .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 > -#else > - .long .LFB3 > -#endif > - .long .LFE3-.LFB3 /* FDE address range */ > + .long FDE_ENCODE(.LFB3) /* FDE initial location */ > + .long .LFE3-.LFB3 /* FDE address range */ > #ifdef __PIC__ > .byte 0x0 /* .uleb128 0x0; Augmentation size */ > #endif
diff -r 82d3ec096908 libffi/src/x86/sysv.S --- a/libffi/src/x86/sysv.S Sat Nov 27 11:15:48 2010 +0100 +++ b/libffi/src/x86/sysv.S Sat Nov 27 11:35:38 2010 +0100 @@ -328,6 +328,25 @@ .size ffi_closure_raw_SYSV, .-ffi_closure_raw_SYSV #endif +#if defined __PIC__ +# if defined __sun__ && defined __svr4__ +/* 32-bit Solaris 2/x86 uses datarel encoding for PIC. GNU ld before 2.22 + doesn't correctly sort .eh_frame_hdr with mixed encodings, so match this. */ +# 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 + .section .eh_frame,EH_FRAME_FLAGS,@progbits .Lframe1: .long .LECIE1-.LSCIE1 /* Length of Common Information Entry */ @@ -354,7 +373,7 @@ .byte 0x8 /* CIE RA Column */ #ifdef __PIC__ .byte 0x1 /* .uleb128 0x1; Augmentation size */ - .byte 0x1b /* FDE Encoding (pcrel sdata4) */ + .byte FDE_ENCODING #endif .byte 0xc /* DW_CFA_def_cfa */ .byte 0x4 /* .uleb128 0x4 */ @@ -367,14 +386,8 @@ .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 -#else - .long .LFB1 -#endif - .long .LFE1-.LFB1 /* FDE address range */ + .long FDE_ENCODE(.LFB1) /* FDE initial location */ + .long .LFE1-.LFB1 /* FDE address range */ #ifdef __PIC__ .byte 0x0 /* .uleb128 0x0; Augmentation size */ #endif @@ -394,14 +407,8 @@ .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 -#else - .long .LFB2 -#endif - .long .LFE2-.LFB2 /* FDE address range */ + .long FDE_ENCODE(.LFB2) /* FDE initial location */ + .long .LFE2-.LFB2 /* FDE address range */ #ifdef __PIC__ .byte 0x0 /* .uleb128 0x0; Augmentation size */ #endif @@ -430,14 +437,8 @@ .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 -#else - .long .LFB3 -#endif - .long .LFE3-.LFB3 /* FDE address range */ + .long FDE_ENCODE(.LFB3) /* FDE initial location */ + .long .LFE3-.LFB3 /* FDE address range */ #ifdef __PIC__ .byte 0x0 /* .uleb128 0x0; Augmentation size */ #endif