From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 20602 invoked by alias); 18 Aug 2008 13:57:46 -0000 Received: (qmail 20558 invoked by uid 22791); 18 Aug 2008 13:57:43 -0000 X-Spam-Check-By: sourceware.org Received: from hiauly1.hia.nrc.ca (HELO hiauly1.hia.nrc.ca) (132.246.100.193) by sourceware.org (qpsmtpd/0.31) with ESMTP; Mon, 18 Aug 2008 13:57:09 +0000 Received: by hiauly1.hia.nrc.ca (Postfix, from userid 1000) id 073814DE6; Mon, 18 Aug 2008 09:57:05 -0400 (EDT) Subject: Re: update dwarf2 asm unwind info [hppa64-*-* failures] To: dave@hiauly1.hia.nrc.ca (John David Anglin) Date: Mon, 18 Aug 2008 14:23:00 -0000 From: "John David Anglin" Cc: rth@twiddle.net, sje@cup.hp.com, gcc-patches@gcc.gnu.org, dave.anglin@nrc-cnrc.gc.ca, binutils-patches@gcc.gnu.org In-Reply-To: from "John David Anglin" at Aug 17, 2008 11:37:45 am X-Mailer: ELM [version 2.4 PL25] MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Message-Id: <20080818135706.073814DE6@hiauly1.hia.nrc.ca> Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org X-SW-Source: 2008-08/txt/msg01175.txt.bz2 > The first form works. I'll see if the addend can be adjusted. I've appended an updated binutils change. This adjusts the addend in tc-hppa.c and readelf.c to account for the fact that PA-RISC PCREL relocations are for symbol - PC - 8 + addend. GAS now appears to generate correct locations for symbol differences, and the cfi tests are now successful on both hppa-unknown-linux-gnu and hppa64-hp-hpux11.11. However, we still have some EH failures on linux. On hppa64, we aren't failing the C cleanup tests but there are still a lot of g++ and libstdc++ EH failures. Dave -- J. David Anglin dave.anglin@nrc-cnrc.gc.ca National Research Council of Canada (613) 990-0752 (FAX: 952-6602) Index: binutils/readelf.c =================================================================== RCS file: /cvs/src/src/binutils/readelf.c,v retrieving revision 1.423 diff -u -3 -p -r1.423 readelf.c --- binutils/readelf.c 8 Aug 2008 19:24:48 -0000 1.423 +++ binutils/readelf.c 17 Aug 2008 19:23:05 -0000 @@ -8156,7 +8156,7 @@ is_32bit_pcrel_reloc (unsigned int reloc case EM_ARM: return reloc_type == 3; /* R_ARM_REL32 */ case EM_PARISC: - return reloc_type == 0; /* R_PARISC_NONE. *//* FIXME: This reloc is generated, but it may be a bug. */ + return reloc_type == 9; /* R_PARISC_PCREL32. */ case EM_PPC: return reloc_type == 26; /* R_PPC_REL32. */ case EM_PPC64: @@ -8219,6 +8219,36 @@ is_64bit_abs_reloc (unsigned int reloc_t } } +/* Like is_32bit_pcrel_reloc except that it returns TRUE iff RELOC_TYPE is + a 64-bit pc-relative RELA relocation used in DWARF debug sections. */ + +static bfd_boolean +is_64bit_pcrel_reloc (unsigned int reloc_type) +{ + switch (elf_header.e_machine) + { + case EM_ALPHA: + return reloc_type == 11; /* R_ALPHA_SREL64 */ + case EM_IA_64: + return reloc_type == 0x4f; /* R_IA64_PCREL64LSB */ + case EM_PARISC: + return reloc_type == 72; /* R_PARISC_PCREL64 */ + case EM_PPC64: + return reloc_type == 44; /* R_PPC64_REL64 */ + case EM_SPARC32PLUS: + case EM_SPARCV9: + case EM_SPARC: + return reloc_type == 46; /* R_SPARC_DISP64 */ + case EM_X86_64: + return reloc_type == 24; /* R_X86_64_PC64 */ + case EM_S390_OLD: + case EM_S390: + return reloc_type == 23; /* R_S390_PC64 */ + default: + return FALSE; + } +} + /* Like is_32bit_abs_reloc except that it returns TRUE iff RELOC_TYPE is a 16-bit absolute RELA relocation used in DWARF debug sections. */ @@ -8392,7 +8422,8 @@ debug_apply_relocations (void *file, if (is_32bit_abs_reloc (reloc_type) || is_32bit_pcrel_reloc (reloc_type)) reloc_size = 4; - else if (is_64bit_abs_reloc (reloc_type)) + else if (is_64bit_abs_reloc (reloc_type) + || is_64bit_pcrel_reloc (reloc_type)) reloc_size = 8; else if (is_16bit_abs_reloc (reloc_type)) reloc_size = 2; @@ -8435,10 +8466,16 @@ debug_apply_relocations (void *file, } addend = is_rela ? rp->r_addend : byte_get (loc, reloc_size); - - if (is_32bit_pcrel_reloc (reloc_type)) - byte_put (loc, (addend + sym->st_value) - rp->r_offset, - reloc_size); + + if (is_32bit_pcrel_reloc (reloc_type) + || is_64bit_pcrel_reloc (reloc_type)) + { + /* Adjust addend on PA-RISC. */ + if (elf_header.e_machine == EM_PARISC) + addend -= 8; + byte_put (loc, (addend + sym->st_value) - rp->r_offset, + reloc_size); + } else byte_put (loc, addend + sym->st_value, reloc_size); } Index: gas/dw2gencfi.c =================================================================== RCS file: /cvs/src/src/gas/dw2gencfi.c,v retrieving revision 1.34 diff -u -3 -p -r1.34 dw2gencfi.c --- gas/dw2gencfi.c 13 Feb 2008 10:14:37 -0000 1.34 +++ gas/dw2gencfi.c 17 Aug 2008 19:23:05 -0000 @@ -31,6 +31,16 @@ # define DWARF2_LINE_MIN_INSN_LENGTH 1 #endif +/* By default, use 32-bit relocations from .eh_frame into .text. */ +#ifndef DWARF2_FDE_RELOC_SIZE +# define DWARF2_FDE_RELOC_SIZE 4 +#endif + +/* By default, use a read-only .eh_frame section. */ +#ifndef DWARF2_EH_FRAME_READ_ONLY +# define DWARF2_EH_FRAME_READ_ONLY SEC_READONLY +#endif + #ifndef EH_FRAME_ALIGNMENT # define EH_FRAME_ALIGNMENT (bfd_get_arch_size (stdoutput) == 64 ? 3 : 2) #endif @@ -1041,6 +1051,7 @@ output_cie (struct cie_entry *cie) expressionS exp; struct cfi_insn_data *i; offsetT augmentation_size; + int enc; cie->start_address = symbol_temp_new_now (); after_size_address = symbol_temp_make (); @@ -1096,11 +1107,22 @@ output_cie (struct cie_entry *cie) } if (cie->lsda_encoding != DW_EH_PE_omit) out_one (cie->lsda_encoding); + + switch (DWARF2_FDE_RELOC_SIZE) + { + case 4: + enc = DW_EH_PE_sdata4; + break; + case 8: + enc = DW_EH_PE_sdata8; + break; + default: + abort (); + } #if defined DIFF_EXPR_OK || defined tc_cfi_emit_pcrel_expr - out_one (DW_EH_PE_pcrel | DW_EH_PE_sdata4); -#else - out_one (DW_EH_PE_sdata4); + enc |= DW_EH_PE_pcrel; #endif + out_one (enc); if (cie->first) for (i = cie->first; i != cie->last; i = i->next) @@ -1135,22 +1157,22 @@ output_fde (struct fde_entry *fde, struc #ifdef DIFF_EXPR_OK exp.X_add_symbol = fde->start_address; exp.X_op_symbol = symbol_temp_new_now (); - emit_expr (&exp, 4); /* Code offset. */ + emit_expr (&exp, DWARF2_FDE_RELOC_SIZE); /* Code offset. */ #else exp.X_op = O_symbol; exp.X_add_symbol = fde->start_address; exp.X_op_symbol = NULL; #ifdef tc_cfi_emit_pcrel_expr - tc_cfi_emit_pcrel_expr (&exp, 4); /* Code offset. */ + tc_cfi_emit_pcrel_expr (&exp, DWARF2_FDE_RELOC_SIZE); /* Code offset. */ #else - emit_expr (&exp, 4); /* Code offset. */ + emit_expr (&exp, DWARF2_FDE_RELOC_SIZE); /* Code offset. */ #endif exp.X_op = O_subtract; #endif exp.X_add_symbol = fde->end_address; exp.X_op_symbol = fde->start_address; /* Code length. */ - emit_expr (&exp, 4); + emit_expr (&exp, DWARF2_FDE_RELOC_SIZE); augmentation_size = encoding_size (fde->lsda_encoding); out_uleb128 (augmentation_size); /* Augmentation size. */ @@ -1319,7 +1341,8 @@ cfi_finish (void) /* Open .eh_frame section. */ cfi_seg = subseg_new (".eh_frame", 0); bfd_set_section_flags (stdoutput, cfi_seg, - SEC_ALLOC | SEC_LOAD | SEC_DATA | SEC_READONLY); + SEC_ALLOC | SEC_LOAD | SEC_DATA + | DWARF2_EH_FRAME_READ_ONLY); subseg_set (cfi_seg, 0); record_alignment (cfi_seg, EH_FRAME_ALIGNMENT); Index: gas/config/tc-hppa.c =================================================================== RCS file: /cvs/src/src/gas/config/tc-hppa.c,v retrieving revision 1.138 diff -u -3 -p -r1.138 tc-hppa.c --- gas/config/tc-hppa.c 16 Mar 2008 23:16:03 -0000 1.138 +++ gas/config/tc-hppa.c 17 Aug 2008 19:23:05 -0000 @@ -1375,6 +1375,16 @@ tc_gen_reloc (asection *section, fixS *f reloc->sym_ptr_ptr = xmalloc (sizeof (asymbol *)); *reloc->sym_ptr_ptr = symbol_get_bfdsym (fixp->fx_addsy); + + /* Allow fixup_segment to recognize hand-written pc-relative + relocations. When we went through cons_fix_new_hppa, we + classified them as complex. Simplify that now. */ + if (fixp->fx_r_type == R_HPPA_COMPLEX && fixp->fx_pcrel) + { + fixp->fx_r_type = R_HPPA_PCREL_CALL; + fixp->fx_offset += 8; + } + codes = hppa_gen_reloc_type (stdoutput, fixp->fx_r_type, hppa_fixp->fx_r_format, Index: gas/config/tc-hppa.h =================================================================== RCS file: /cvs/src/src/gas/config/tc-hppa.h,v retrieving revision 1.35 diff -u -3 -p -r1.35 tc-hppa.h --- gas/config/tc-hppa.h 12 Aug 2008 23:39:30 -0000 1.35 +++ gas/config/tc-hppa.h 17 Aug 2008 19:23:05 -0000 @@ -186,8 +186,6 @@ int hppa_fix_adjustable (struct fix *); #define elf_tc_final_processing elf_hppa_final_processing void elf_hppa_final_processing (void); - -#define DWARF2_LINE_MIN_INSN_LENGTH 4 #endif /* OBJ_ELF */ #define md_operand(x) @@ -213,10 +211,18 @@ extern int hppa_regname_to_dw2regnum (ch #define DWARF2_LINE_MIN_INSN_LENGTH 4 #define DWARF2_DEFAULT_RETURN_COLUMN 2 #if TARGET_ARCH_SIZE == 64 -#define DWARF2_CIE_DATA_ALIGNMENT (-8) +#define DWARF2_CIE_DATA_ALIGNMENT 8 +#define DWARF2_FDE_RELOC_SIZE 8 #else -#define DWARF2_CIE_DATA_ALIGNMENT (-4) +#define DWARF2_CIE_DATA_ALIGNMENT 4 #endif + +#if !(defined (OBJ_ELF) && (defined (TE_LINUX) || defined (TE_NetBSD))) +/* Due to the way dynamic linking to personality functions is handled + on HP-UX, we need to have a read-write .eh_frame section. */ +#define DWARF2_EH_FRAME_READ_ONLY 0 +#endif + #endif #endif /* _TC_HPPA_H */ Index: gas/testsuite/gas/cfi/cfi-common-1.d =================================================================== RCS file: /cvs/src/src/gas/testsuite/gas/cfi/cfi-common-1.d,v retrieving revision 1.5 diff -u -3 -p -r1.5 cfi-common-1.d --- gas/testsuite/gas/cfi/cfi-common-1.d 28 Jan 2008 15:15:31 -0000 1.5 +++ gas/testsuite/gas/cfi/cfi-common-1.d 17 Aug 2008 19:23:05 -0000 @@ -14,10 +14,11 @@ The section .eh_frame contains: DW_CFA_nop DW_CFA_nop -00000014 00000018 00000018 FDE cie=00000000 pc=.* +00000014 000000(18|1c|20) 00000018 FDE cie=00000000 pc=.* DW_CFA_advance_loc: 4 to .* DW_CFA_def_cfa: r0( \([er]ax\)|) ofs 16 - DW_CFA_offset: r1( \((rdx|ecx)\)|) at cfa-8 + DW_CFA_offset(_extended_sf|): r1( \((rdx|ecx)\)|) at cfa-8 DW_CFA_advance_loc: 4 to .* DW_CFA_def_cfa_offset: 32 - DW_CFA_offset: r2( \((rcx|edx)\)|) at cfa-24 + DW_CFA_offset(_extended_sf|): r2( \((rcx|edx)\)|) at cfa-24 +#... Index: gas/testsuite/gas/cfi/cfi-hppa-1.d =================================================================== RCS file: /cvs/src/src/gas/testsuite/gas/cfi/cfi-hppa-1.d,v retrieving revision 1.2 diff -u -3 -p -r1.2 cfi-hppa-1.d --- gas/testsuite/gas/cfi/cfi-hppa-1.d 28 Jan 2008 15:15:31 -0000 1.2 +++ gas/testsuite/gas/cfi/cfi-hppa-1.d 17 Aug 2008 19:23:05 -0000 @@ -6,13 +6,13 @@ The section .eh_frame contains: Version: 1 Augmentation: "zR" Code alignment factor: 4 - Data alignment factor: -[48] + Data alignment factor: [48] Return address column: 2 - Augmentation data: 1b + Augmentation data: 1[bc] DW_CFA_def_cfa: r30 ofs 0 -00000014 00000018 00000018 FDE cie=00000000 pc=00000000..00000018 +00000014 000000(18|20) 00000018 FDE cie=00000000 pc=00000000..00000018 DW_CFA_advance_loc: 8 to 00000008 DW_CFA_def_cfa_register: r3 DW_CFA_advance_loc: 4 to 0000000c @@ -21,17 +21,16 @@ The section .eh_frame contains: DW_CFA_def_cfa_register: r30 DW_CFA_nop -00000030 00000018 00000034 FDE cie=00000000 pc=00000018..00000040 +0000003[08] 000000(18|20) 0000003[4c] FDE cie=00000000 pc=00000018..00000040 DW_CFA_advance_loc: 12 to 00000024 DW_CFA_def_cfa_register: r3 - DW_CFA_offset: r2 at cfa-24 + DW_CFA_offset_extended_sf: r2 at cfa-24 DW_CFA_advance_loc: 24 to 0000003c DW_CFA_def_cfa_register: r30 DW_CFA_nop DW_CFA_nop - DW_CFA_nop -0000004c 00000010 00000050 FDE cie=00000000 pc=00000040..00000048 +000000[45]c 0000001[08] 000000[56]0 FDE cie=00000000 pc=00000040..00000048 DW_CFA_nop DW_CFA_nop DW_CFA_nop Index: gas/testsuite/gas/cfi/cfi.exp =================================================================== RCS file: /cvs/src/src/gas/testsuite/gas/cfi/cfi.exp,v retrieving revision 1.21 diff -u -3 -p -r1.21 cfi.exp --- gas/testsuite/gas/cfi/cfi.exp 18 Feb 2008 21:05:07 -0000 1.21 +++ gas/testsuite/gas/cfi/cfi.exp 17 Aug 2008 19:23:05 -0000 @@ -80,13 +80,18 @@ if { [istarget "i*86-*-*"] || [istarget } run_list_test "cfi-diag-1" "" -run_dump_test "cfi-common-1" -run_dump_test "cfi-common-2" -run_dump_test "cfi-common-3" -run_dump_test "cfi-common-4" -run_dump_test "cfi-common-5" -# MIPS doesn't support PC relative cfi directives +# HPPA64 uses 64-bit relocations, which results in all of the dump +# offset numbers not matching up. +if { ![istarget "hppa64*-*"] } then { + run_dump_test "cfi-common-1" + run_dump_test "cfi-common-2" + run_dump_test "cfi-common-3" + run_dump_test "cfi-common-4" + run_dump_test "cfi-common-5" +} + +# MIPS doesn't support PC relative cfi directives. if { ![istarget "mips*-*"] } then { run_dump_test "cfi-common-6" }