From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 47865 invoked by alias); 22 Mar 2017 23:04:36 -0000 Mailing-List: contact binutils-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: binutils-owner@sourceware.org Received: (qmail 47417 invoked by uid 89); 22 Mar 2017 23:04:32 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-25.4 required=5.0 tests=AWL,BAYES_00,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,RCVD_IN_DNSWL_NONE,RCVD_IN_SORBS_SPAM,SPF_PASS autolearn=ham version=3.3.2 spammy=Hx-languages-length:2855 X-HELO: mail-pf0-f194.google.com Received: from mail-pf0-f194.google.com (HELO mail-pf0-f194.google.com) (209.85.192.194) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 22 Mar 2017 23:04:31 +0000 Received: by mail-pf0-f194.google.com with SMTP id n11so17548888pfg.2 for ; Wed, 22 Mar 2017 16:04:31 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:to:cc:subject:date:message-id :in-reply-to:references; bh=Y0VEbEjkpYRmoNL98vtIJom24v+AzNo38p7phkVEmts=; b=SWwYstLIWTo/tColALg8U8yLnPNlz2ar2bzHHsGTEVcgq3NT0aXFKAPhnPq4KWBn7y kKNpDloEQmYlgOPmGIqFFCYaleipiGhu3onTnacM9cGmJ0+2/bGHsNC1z3QX7QH6sR6C tsVOyh6xxRFYmsW+nMBwspG5tAqG4V4RTx461E5DCbBQZvir4iJp1P2HYbt0HRhVZ1hB zDfM0+6iRzXZ0pIuQGZWw88rX4bSV/s9iq0TZGTeUFAOsM7sLo0hwjSiHMCXj+ptQkuf gFUbUaOqkKBpOrmdj88Ot3Moj1ljnbsERwEg/MOKjXThOzJiC0L7DxZr9zJBsUSDcwgG wJ3w== X-Gm-Message-State: AFeK/H0rR6JUrW1HXlhIZhUI3PQS57onDyyJVrzEZiLjSxqN7uCJSoxWIgyXJTjsPSuMuw== X-Received: by 10.98.62.82 with SMTP id l79mr50168221pfa.164.1490223870495; Wed, 22 Mar 2017 16:04:30 -0700 (PDT) Received: from localhost ([216.38.154.21]) by smtp.gmail.com with ESMTPSA id 23sm5891160pfw.94.2017.03.22.16.04.29 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 22 Mar 2017 16:04:29 -0700 (PDT) From: Palmer Dabbelt To: binutils@sourceware.org To: Tristan Gingold Cc: Kuan-Lin Chen Subject: [PATCH 2/7] RISC-V: Fix the offset of CFA relocation. Date: Wed, 22 Mar 2017 23:04:00 -0000 Message-Id: <20170322230408.8885-3-palmer@dabbelt.com> In-Reply-To: <20170322230408.8885-1-palmer@dabbelt.com> References: <20170322230408.8885-1-palmer@dabbelt.com> X-IsSubscribed: yes X-SW-Source: 2017-03/txt/msg00311.txt.bz2 From: Kuan-Lin Chen gas/ChangeLog: 2017-03-02 Kuan-Lin Chen * config/tc-riscv.c (md_apply_fix): Compute the correct offsets for CFA relocations. --- gas/ChangeLog | 5 +++++ gas/config/tc-riscv.c | 20 ++++++++++---------- 2 files changed, 15 insertions(+), 10 deletions(-) diff --git a/gas/ChangeLog b/gas/ChangeLog index d59472a..7639ec7 100644 --- a/gas/ChangeLog +++ b/gas/ChangeLog @@ -1,3 +1,8 @@ +2017-03-02 Kuan-Lin Chen + + * config/tc-riscv.c (md_apply_fix): Compute the correct offsets + for CFA relocations. + 2017-03-21 Andreas Krebbel Backport from mainline diff --git a/gas/config/tc-riscv.c b/gas/config/tc-riscv.c index ec5b0bb..c79f313 100644 --- a/gas/config/tc-riscv.c +++ b/gas/config/tc-riscv.c @@ -1837,6 +1837,7 @@ md_apply_fix (fixS *fixP, valueT *valP, segT seg ATTRIBUTE_UNUSED) unsigned int subtype; bfd_byte *buf = (bfd_byte *) (fixP->fx_frag->fr_literal + fixP->fx_where); bfd_boolean relaxable = FALSE; + offsetT loc; /* Remember value for tc_gen_reloc. */ fixP->fx_addnumber = *valP; @@ -1922,30 +1923,31 @@ md_apply_fix (fixS *fixP, valueT *valP, segT seg ATTRIBUTE_UNUSED) case BFD_RELOC_RISCV_CFA: /* Load the byte to get the subtype. */ - subtype = bfd_get_8 (NULL, &fixP->fx_frag->fr_literal[fixP->fx_where]); + subtype = bfd_get_8 (NULL, &((fragS *) (fixP->fx_frag->fr_opcode))->fr_literal[fixP->fx_where]); + loc = fixP->fx_frag->fr_fix - (subtype & 7); switch (subtype) { case DW_CFA_advance_loc1: - fixP->fx_where++; - fixP->fx_next->fx_where++; + fixP->fx_where = loc + 1; + fixP->fx_next->fx_where = loc + 1; fixP->fx_r_type = BFD_RELOC_RISCV_SET8; fixP->fx_next->fx_r_type = BFD_RELOC_RISCV_SUB8; break; case DW_CFA_advance_loc2: fixP->fx_size = 2; - fixP->fx_where++; fixP->fx_next->fx_size = 2; - fixP->fx_next->fx_where++; + fixP->fx_where = loc + 1; + fixP->fx_next->fx_where = loc + 1; fixP->fx_r_type = BFD_RELOC_RISCV_SET16; fixP->fx_next->fx_r_type = BFD_RELOC_RISCV_SUB16; break; case DW_CFA_advance_loc4: fixP->fx_size = 4; - fixP->fx_where++; fixP->fx_next->fx_size = 4; - fixP->fx_next->fx_where++; + fixP->fx_where = loc; + fixP->fx_next->fx_where = loc; fixP->fx_r_type = BFD_RELOC_RISCV_SET32; fixP->fx_next->fx_r_type = BFD_RELOC_RISCV_SUB32; break; @@ -2069,7 +2071,6 @@ riscv_pre_output_hook (void) { if (frag->fr_type == rs_cfa) { - fragS *loc4_frag; expressionS exp; symbolS *add_symbol = frag->fr_symbol->sy_value.X_add_symbol; @@ -2080,8 +2081,7 @@ riscv_pre_output_hook (void) exp.X_add_number = 0; exp.X_op_symbol = op_symbol; - loc4_frag = (fragS *) frag->fr_opcode; - fix_new_exp (loc4_frag, (int) frag->fr_offset, 1, &exp, 0, + fix_new_exp (frag, (int) frag->fr_offset, 1, &exp, 0, BFD_RELOC_RISCV_CFA); } } -- 2.10.2