From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 50536 invoked by alias); 2 Mar 2016 11:29:37 -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 50514 invoked by uid 89); 2 Mar 2016 11:29:35 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=0.4 required=5.0 tests=AWL,BAYES_50,SPF_PASS autolearn=ham version=3.3.2 spammy=ffff, sk:undefin, 2.20, 0xff X-HELO: prv-mh.provo.novell.com Received: from prv-mh.provo.novell.com (HELO prv-mh.provo.novell.com) (137.65.248.74) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-GCM-SHA384 encrypted) ESMTPS; Wed, 02 Mar 2016 11:29:34 +0000 Received: from INET-PRV-MTA by prv-mh.provo.novell.com with Novell_GroupWise; Wed, 02 Mar 2016 04:29:32 -0700 Message-Id: <56D6DCAB02000078000D845A@prv-mh.provo.novell.com> Date: Wed, 02 Mar 2016 11:29:00 -0000 From: "Jan Beulich" To: Subject: [PATCH] gas: fix bogus error on .org involving expression Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=__PartAD9A208B.0__=" X-SW-Source: 2016-03/txt/msg00030.txt.bz2 This is a MIME message. If you are reading this text, you may want to consider changing to a mail reader or gateway that understands how to properly handle MIME multipart messages. --=__PartAD9A208B.0__= Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: quoted-printable Content-Disposition: inline Content-length: 2931 For years I have been carrying this change, and it was long forgotten what it was originally meant to deal with, hence I've never submitted it. Until I came across an issue with Linux kernel like alternative instruction patching, where the space needed to hold the replacement instruction was allocated using .org. Things built fine for me (since I had the patch in place), and things also built fine on 2.20. But assemblers from at least 2.22 onwards produce an undefined symbol warning for the "orig" label in the new test case, followed by an error complaining that .org would be moving backwards (which is a logical consequence of the undefined symbol getting replaced by plain zero). gas/ 2016-03-02 Jan Beulich * expr.c (expr): Set retval to expr_section for expressions involving symbols, which cannot be resolved right away. gas/testsuite/ 2016-03-02 Jan Beulich * expr-org.s, expr.org.d: New. * gas.exp: Run new test. --- 2016-03-02/gas/expr.c +++ 2016-03-02/gas/expr.c @@ -1998,7 +1998,11 @@ expr (int rankarg, /* Larger # is highe retval =3D absolute_section; rightseg =3D absolute_section; } + else + retval =3D expr_section; } + else + retval =3D expr_section; } else { @@ -2010,17 +2014,18 @@ expr (int rankarg, /* Larger # is highe resultP->X_add_number =3D 0; resultP->X_unsigned =3D 1; resultP->X_extrabit =3D 0; + retval =3D expr_section; } =20 if (retval !=3D rightseg) { - if (retval =3D=3D undefined_section) + if (retval =3D=3D expr_section) ; - else if (rightseg =3D=3D undefined_section) + else if (rightseg =3D=3D expr_section) retval =3D rightseg; - else if (retval =3D=3D expr_section) + else if (retval =3D=3D undefined_section) ; - else if (rightseg =3D=3D expr_section) + else if (rightseg =3D=3D undefined_section) retval =3D rightseg; else if (retval =3D=3D reg_section) ; --- 2016-03-02/gas/testsuite/gas/all/expr-org.d +++ 2016-03-02/gas/testsuite/gas/all/expr-org.d @@ -0,0 +1,11 @@ +#objdump: -s -j .data -j .alt +#name: .org with expression (with forward reference) + +.*: .* + +Contents of section \.data: + 0000 [0f][0f]ffff[0f][0f] 01 [ .]* + +Contents of section \.alt: + 0000 00000000 [ .]* +#pass --- 2016-03-02/gas/testsuite/gas/all/expr-org.s +++ 2016-03-02/gas/testsuite/gas/all/expr-org.s @@ -0,0 +1,10 @@ + .data +orig: + .byte 0 + .org orig + (alt_end - alt_begin), 0xff + .pushsection .alt, "a", @progbits +alt_begin: + .long 0 +alt_end: + .popsection + .byte 1 --- 2016-03-02/gas/testsuite/gas/all/gas.exp +++ 2016-03-02/gas/testsuite/gas/all/gas.exp @@ -371,6 +371,7 @@ if { ([istarget "i*86-*-*pe*"] && ![ist if { ![istarget "bfin-*-*"] && ![istarget "nds32*-*-*"] } then { run_dump_test assign } +run_dump_test expr-org run_dump_test sleb128 run_dump_test sleb128-2 run_dump_test sleb128-3 --=__PartAD9A208B.0__= Content-Type: text/plain; name="binutils-master-master-org-expression.patch" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="binutils-master-master-org-expression.patch" Content-length: 2979 gas: fix bogus error on .org involving expression For years I have been carrying this change, and it was long forgotten what it was originally meant to deal with, hence I've never submitted it. Until I came across an issue with Linux kernel like alternative instruction patching, where the space needed to hold the replacement instruction was allocated using .org. Things built fine for me (since I had the patch in place), and things also built fine on 2.20. But assemblers from at least 2.22 onwards produce an undefined symbol warning for the "orig" label in the new test case, followed by an error complaining that .org would be moving backwards (which is a logical consequence of the undefined symbol getting replaced by plain zero). gas/ 2016-03-02 Jan Beulich * expr.c (expr): Set retval to expr_section for expressions involving symbols, which cannot be resolved right away. gas/testsuite/ 2016-03-02 Jan Beulich * expr-org.s, expr.org.d: New. * gas.exp: Run new test. --- 2016-03-02/gas/expr.c +++ 2016-03-02/gas/expr.c @@ -1998,7 +1998,11 @@ expr (int rankarg, /* Larger # is highe retval =3D absolute_section; rightseg =3D absolute_section; } + else + retval =3D expr_section; } + else + retval =3D expr_section; } else { @@ -2010,17 +2014,18 @@ expr (int rankarg, /* Larger # is highe resultP->X_add_number =3D 0; resultP->X_unsigned =3D 1; resultP->X_extrabit =3D 0; + retval =3D expr_section; } =20 if (retval !=3D rightseg) { - if (retval =3D=3D undefined_section) + if (retval =3D=3D expr_section) ; - else if (rightseg =3D=3D undefined_section) + else if (rightseg =3D=3D expr_section) retval =3D rightseg; - else if (retval =3D=3D expr_section) + else if (retval =3D=3D undefined_section) ; - else if (rightseg =3D=3D expr_section) + else if (rightseg =3D=3D undefined_section) retval =3D rightseg; else if (retval =3D=3D reg_section) ; --- 2016-03-02/gas/testsuite/gas/all/expr-org.d +++ 2016-03-02/gas/testsuite/gas/all/expr-org.d @@ -0,0 +1,11 @@ +#objdump: -s -j .data -j .alt +#name: .org with expression (with forward reference) + +.*: .* + +Contents of section \.data: + 0000 [0f][0f]ffff[0f][0f] 01 [ .]* + +Contents of section \.alt: + 0000 00000000 [ .]* +#pass --- 2016-03-02/gas/testsuite/gas/all/expr-org.s +++ 2016-03-02/gas/testsuite/gas/all/expr-org.s @@ -0,0 +1,10 @@ + .data +orig: + .byte 0 + .org orig + (alt_end - alt_begin), 0xff + .pushsection .alt, "a", @progbits +alt_begin: + .long 0 +alt_end: + .popsection + .byte 1 --- 2016-03-02/gas/testsuite/gas/all/gas.exp +++ 2016-03-02/gas/testsuite/gas/all/gas.exp @@ -371,6 +371,7 @@ if { ([istarget "i*86-*-*pe*"] && ![ist if { ![istarget "bfin-*-*"] && ![istarget "nds32*-*-*"] } then { run_dump_test assign } +run_dump_test expr-org run_dump_test sleb128 run_dump_test sleb128-2 run_dump_test sleb128-3 --=__PartAD9A208B.0__=--