From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 21777 invoked by alias); 26 Sep 2006 14:49:05 -0000 Received: (qmail 21729 invoked by uid 22791); 26 Sep 2006 14:49:04 -0000 X-Spam-Check-By: sourceware.org Received: from sunsite.ms.mff.cuni.cz (HELO sunsite.mff.cuni.cz) (195.113.15.26) by sourceware.org (qpsmtpd/0.31) with ESMTP; Tue, 26 Sep 2006 14:48:57 +0000 Received: from sunsite.mff.cuni.cz (sunsite.mff.cuni.cz [127.0.0.1]) by sunsite.mff.cuni.cz (8.13.1/8.13.1) with ESMTP id k8QEmfAd009443; Tue, 26 Sep 2006 16:48:41 +0200 Received: (from jj@localhost) by sunsite.mff.cuni.cz (8.13.1/8.13.1/Submit) id k8QEmf57009442; Tue, 26 Sep 2006 16:48:41 +0200 Date: Tue, 26 Sep 2006 14:58:00 -0000 From: Jakub Jelinek To: "H. J. Lu" Cc: binutils@sources.redhat.com Subject: Re: [PATCH] Fix DW_CFA_set_loc handling Message-ID: <20060926144840.GD4556@sunsite.mff.cuni.cz> Reply-To: Jakub Jelinek References: <20060926123840.GA4556@sunsite.mff.cuni.cz> <20060926135742.GB32243@lucon.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20060926135742.GB32243@lucon.org> User-Agent: Mutt/1.4.1i X-IsSubscribed: yes Mailing-List: contact binutils-help@sourceware.org; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: binutils-owner@sourceware.org X-SW-Source: 2006-09/txt/msg00310.txt.bz2 On Tue, Sep 26, 2006 at 06:57:42AM -0700, H. J. Lu wrote: > On Tue, Sep 26, 2006 at 02:38:40PM +0200, Jakub Jelinek wrote: > > Hi! > > > > Recent http://gcc.gnu.org/PR22313 change (including gcc 4.1 branch) started > > (unnecessarily) using DW_CFA_set_loc at the start of all FDEs, but > > unfortunately linker .eh_frame optimizations didn't handle that well. > > If FDE encoding is pc relative or linker is changing it from absptr > > to pc relative, we need to adjust the DW_CFA_set_loc operand accordingly. > > > > Tested with make check on x86_64-linux, visual inspection of x86_64 > > readelf -wf libc.so.6 (this was seriously broken before) and visual > > inspection of a hacked up test for absptr -> pcrel conversion. > > > > Is that possible to include a testcase, even just for one arch/format? Sure: 2006-09-26 Jakub Jelinek * ld-elf/eh4.d: New test. * ld-elf/eh4.s: New file. * ld-elf/eh4a.s: New file. --- ld/testsuite/ld-elf/eh4.d.jj 2006-09-26 16:37:48.000000000 +0200 +++ ld/testsuite/ld-elf/eh4.d 2006-09-26 16:38:31.000000000 +0200 @@ -0,0 +1,32 @@ +#source: eh4.s +#source: eh4a.s +#ld: -shared +#readelf: -wf +#target: x86_64-*-* + +The section .eh_frame contains: + +00000000 00000014 00000000 CIE + Version: 1 + Augmentation: "zR" + Code alignment factor: 1 + Data alignment factor: -8 + Return address column: 16 + Augmentation data: 1b + + DW_CFA_def_cfa: r7 ofs 8 + DW_CFA_offset: r16 at cfa-8 + DW_CFA_nop + DW_CFA_nop + +00000018 00000014 0000001c FDE cie=00000000 pc=00000400..00000413 + DW_CFA_set_loc: 00000404 + DW_CFA_def_cfa_offset: 80 + +00000030 00000014 00000034 FDE cie=00000000 pc=00000413..00000426 + DW_CFA_set_loc: 00000417 + DW_CFA_def_cfa_offset: 80 + +00000048 ZERO terminator +#pass + --- ld/testsuite/ld-elf/eh4.s.jj 2006-09-26 16:12:13.000000000 +0200 +++ ld/testsuite/ld-elf/eh4.s 2006-09-26 16:30:39.000000000 +0200 @@ -0,0 +1,92 @@ + .text + .align 512 + .globl foo + .type foo, @function +foo: +.LFB1: + subq $72, %rsp +.LCFI1: + xorl %eax, %eax + movq %rsp, %rdi + call bar@PLT + addq $72, %rsp + ret +.LFE1: + .size foo, .-foo + .globl bar + .type bar, @function +bar: +.LFB2: + subq $72, %rsp +.LCFI2: + xorl %eax, %eax + movq %rsp, %rdi + call bar@PLT + addq $72, %rsp + ret +.LFE2: + .size bar, .-bar + .section .eh_frame,"a",@progbits +.Lframe1: + .long .LECIE1-.LSCIE1 # Length of Common Information Entry +.LSCIE1: + .long 0x0 # CIE Identifier Tag + .byte 0x1 # CIE Version + .ascii "zR\0" # CIE Augmentation + .uleb128 0x1 # CIE Code Alignment Factor + .sleb128 -8 # CIE Data Alignment Factor + .byte 0x10 # CIE RA Column + .uleb128 0x1 # Augmentation size + .byte 0x1b # FDE Encoding (pcrel sdata4) + .byte 0xc # DW_CFA_def_cfa + .uleb128 0x7 + .uleb128 0x8 + .byte 0x90 # DW_CFA_offset, column 0x10 + .uleb128 0x1 + .align 8 +.LECIE1: +.LSFDE1: + .long .LEFDE1-.LASFDE1 # FDE Length +.LASFDE1: + .long .LASFDE1-.Lframe1 # FDE CIE offset + .long .LFB1-. # FDE initial location + .long .LFE1-.LFB1 # FDE address range + .uleb128 0x0 # Augmentation size + .byte 0x1 # DW_CFA_set_loc + .long .LCFI1-. + .byte 0xe # DW_CFA_def_cfa_offset + .uleb128 0x50 + .align 8 +.LEFDE1: +.Lframe2: + .long .LECIE2-.LSCIE2 # Length of Common Information Entry +.LSCIE2: + .long 0x0 # CIE Identifier Tag + .byte 0x1 # CIE Version + .ascii "zR\0" # CIE Augmentation + .uleb128 0x1 # CIE Code Alignment Factor + .sleb128 -8 # CIE Data Alignment Factor + .byte 0x10 # CIE RA Column + .uleb128 0x1 # Augmentation size + .byte 0x1b # FDE Encoding (pcrel sdata4) + .byte 0xc # DW_CFA_def_cfa + .uleb128 0x7 + .uleb128 0x8 + .byte 0x90 # DW_CFA_offset, column 0x10 + .uleb128 0x1 + .align 8 +.LECIE2: +.LSFDE2: + .long .LEFDE2-.LASFDE2 # FDE Length +.LASFDE2: + .long .LASFDE2-.Lframe2 # FDE CIE offset + .long .LFB2-. # FDE initial location + .long .LFE2-.LFB2 # FDE address range + .uleb128 0x0 # Augmentation size + .byte 0x1 # DW_CFA_set_loc + .long .LCFI2-. + .byte 0xe # DW_CFA_def_cfa_offset + .uleb128 0x50 + .align 8 +.LEFDE2: + .section .note.GNU-stack,"",@progbits --- ld/testsuite/ld-elf/eh4a.s.jj 2006-09-26 16:39:07.000000000 +0200 +++ ld/testsuite/ld-elf/eh4a.s 2006-05-24 04:39:16.000000000 +0200 @@ -0,0 +1,3 @@ + .section .eh_frame,"a",%progbits + .align 8 + .zero 8 Jakub