From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 28090 invoked by alias); 22 Mar 2016 09:19:39 -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 28051 invoked by uid 89); 22 Mar 2016 09:19:37 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.0 required=5.0 tests=AWL,BAYES_00,SPF_PASS autolearn=ham version=3.3.2 spammy=respective, 19987, ffff, retval 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; Tue, 22 Mar 2016 09:19:35 +0000 Received: from INET-PRV-MTA by prv-mh.provo.novell.com with Novell_GroupWise; Tue, 22 Mar 2016 03:19:34 -0600 Message-Id: <56F11C3402000078000DF167@prv-mh.provo.novell.com> Date: Tue, 22 Mar 2016 09:19:00 -0000 From: "Jan Beulich" To: "Alan Modra" Cc: "Hans-Peter Nilsson" , , Subject: Re: Ping: [PATCH] gas: fix bogus error on .org involving expression References: <56D6DCAB02000078000D845A@prv-mh.provo.novell.com> <56E99A7F02000078000DD4E5@prv-mh.provo.novell.com> <20160316234647.GA22605@bubble.grove.modra.org> In-Reply-To: <20160316234647.GA22605@bubble.grove.modra.org> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=__PartF5C25F34.2__=" X-SW-Source: 2016-03/txt/msg00285.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. --=__PartF5C25F34.2__= Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: quoted-printable Content-Disposition: inline Content-length: 2692 >>> On 17.03.16 at 00:46, wrote: > On Wed, Mar 16, 2016 at 10:40:15AM -0600, Jan Beulich wrote: >> Ping??? >> >>> On 02.03.16 at 12:29, wrote: >> > gas/ >> > 2016-03-02 Jan Beulich >> >=20 >> > * expr.c (expr): Set retval to expr_section for expressions >> > involving symbols, which cannot be resolved right away. >=20 > OK. >=20 >> > gas/testsuite/ >> > 2016-03-02 Jan Beulich >> >=20 >> > * expr-org.s, expr.org.d: New. >> > * gas.exp: Run new test. >=20 > Have you run the new test over a good sample of binutils targets? > I suspect that the new test won't work on some, tic4x and tic54x, for > example. OK with changes to exclude such targets. Indeed there were quite a few. Namely, due to the use of .pushsection and .popsection all non-ELF targets need to be excluded. mep-*-elf was the only other one needing exclusion, since the complex relocation support it enables appears to result in expressions not getting evaluated in time for .org to get its operand fully resolved. To be honest, I'm not really bothered enough to dig into finding (and fixing) the exact reason for this. Beyond those, however, this also revealed a few other failures: 1) i586-aout had several regressions due to the unimplemented segment checks in i386_finalize_immediate() and i386_finalize_displacement() not accounting for expr_section. This will therefore require an update to the patch itself, not just the testsuite (which I think is warranted even if the test now is being limited to ELF targets). 2) Along the same lines HPPA's "Bad segment in expression." warning generation logic didn't account for expr_section. 3) xtensa-elf setting TC_FINALIZE_SYMS_BEFORE_SIZE_SEG to 0 causes the "invalid operands (.text.unlikely and .text.startup sections) for `-'" to not appear for elf/bad-group.s. Prior to the change this was detected as "operation combines symbols in different segments" from expr(), but the code change results in this error getting eliminated. It's not clear to me how to make sure the "finalize_syms" dependent "invalid operands" error from resolve_symbol_value() gets properly raised for such targets (nds32 appears to be the only other one, which my set of tested targets didn't include). 4) MMIX'es pr12815-* tests both fail (they no longer produce the expected or any other error). Since I have no idea what exactly those tests test, I also have no idea how to deal with this. I'm attaching the patch taking care of everything except 3) and 4); please advise what to do about those two remaining issues (I'm also Cc-ing the respective target code maintainers for that purpose). Jan --=__PartF5C25F34.2__= 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: 4162 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-22 Jan Beulich * config/tc-hppa.c (get_expression): Also allow expr_section. * config/tc-i386.c (i386_finalize_immediate): Likewise. (i386_finalize_displacement): Likewise. * expr.c (expr): Set retval to expr_section for expressions involving symbols, which cannot be resolved right away. gas/testsuite/ 2016-03-22 Jan Beulich * expr-org.s, expr.org.d: New. * gas.exp: Run new test. --- 2016-03-22/gas/config/tc-hppa.c +++ 2016-03-22/gas/config/tc-hppa.c @@ -1282,6 +1282,7 @@ get_expression (char *str) input_line_pointer =3D str; seg =3D expression (&the_insn.exp); if (!(seg =3D=3D absolute_section + || seg =3D=3D expr_section || seg =3D=3D undefined_section || SEG_NORMAL (seg))) { --- 2016-03-22/gas/config/tc-i386.c +++ 2016-03-22/gas/config/tc-i386.c @@ -8043,6 +8043,7 @@ i386_finalize_immediate (segT exp_seg AT && exp_seg !=3D text_section && exp_seg !=3D data_section && exp_seg !=3D bss_section + && exp_seg !=3D expr_section && exp_seg !=3D undefined_section && !bfd_is_com_section (exp_seg)) { @@ -8336,6 +8337,7 @@ i386_finalize_displacement (segT exp_seg && exp_seg !=3D text_section && exp_seg !=3D data_section && exp_seg !=3D bss_section + && exp_seg !=3D expr_section && exp_seg !=3D undefined_section && !bfd_is_com_section (exp_seg)) { --- 2016-03-22/gas/expr.c +++ 2016-03-22/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-22/gas/testsuite/gas/all/expr-org.d +++ 2016-03-22/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[0 .]* + +Contents of section \.alt: + 0000 00000000 [ .]* +#pass --- 2016-03-22/gas/testsuite/gas/all/expr-org.s +++ 2016-03-22/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-22/gas/testsuite/gas/all/gas.exp +++ 2016-03-22/gas/testsuite/gas/all/gas.exp @@ -432,6 +432,11 @@ gas_test_error "weakref4.s" "" "is alrea run_dump_test string if [is_elf_format] { run_dump_test none + +# Targets enabling OBJ_COMPLEX_RELC don't seem to be compatible with this. + if { ![istarget "mep-*-*"] } { + run_dump_test expr-org + } } =20 run_dump_test quoted-sym-names --=__PartF5C25F34.2__=--