From patchwork Fri Mar 27 14:12:29 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Beulich X-Patchwork-Id: 132377 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from vm01.sourceware.org (localhost [127.0.0.1]) by sourceware.org (Postfix) with ESMTP id ADEDC4BA23F4 for ; Fri, 27 Mar 2026 14:18:05 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org ADEDC4BA23F4 Authentication-Results: sourceware.org; dkim=pass (2048-bit key, unprotected) header.d=suse.com header.i=@suse.com header.a=rsa-sha256 header.s=google header.b=YJNDsiNx X-Original-To: binutils@sourceware.org Delivered-To: binutils@sourceware.org Received: from mail-wr1-x42a.google.com (mail-wr1-x42a.google.com [IPv6:2a00:1450:4864:20::42a]) by sourceware.org (Postfix) with ESMTPS id D24134BA2E1A for ; Fri, 27 Mar 2026 14:12:31 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org D24134BA2E1A Authentication-Results: sourceware.org; dmarc=pass (p=quarantine dis=none) header.from=suse.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=suse.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org D24134BA2E1A Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a00:1450:4864:20::42a ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1774620752; cv=none; b=oKw/kPOuoqigF/ZQ/LfHG370earYr5CEqZSWtkzdwvMUnD0ykDhtMarTqVsi3GFUDUCzVWL/XXXrEj69bBrOq18h/XjL1vdPlQ9W4c+M9zlX7fAH4NwcqZp5IWsGSi7iEqYhIFRvTJpJBHKkvccgfxwavFAjS0ExGUevralc6bM= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1774620752; c=relaxed/simple; bh=7Y1qi7SWgrtJEjL3AspOKk7ND03JIlHAjDpAXgXRYeA=; h=DKIM-Signature:Message-ID:Date:MIME-Version:Subject:From:To; b=Y4Slf6B+fFIQDdzwoxFzKgKFuSvG8D+3kFck7lGZuSiPJcV4TEId7BxOV0q3CterXmZz72VxO91/CUzXXzAFbT750UNZxiEM2hel7pX9mJ6gyYUPxFDJ4k/N7C2Nozzj0d9kH6JlETIHEVXaUoMcLpLQFL3Ami06jjITOLtTVc8= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org D24134BA2E1A Received: by mail-wr1-x42a.google.com with SMTP id ffacd0b85a97d-43b41b545d9so2235098f8f.2 for ; Fri, 27 Mar 2026 07:12:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=google; t=1774620751; x=1775225551; darn=sourceware.org; h=content-transfer-encoding:in-reply-to:autocrypt:cc:content-language :references:to:from:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=/w5ro2mkBYT8/suCErt1KFmb1y/JHT1fh3a2MXRe39A=; b=YJNDsiNxj06wiX28F4L4FH9ZR5K3xLIsvDY63PwwDUNoQ51eytJrkR/a1gQcU+e48V sy3T8mnWLXWkF3vk/XmWJVbU0Q5aZHnDBwlniD9Ji1YkamEBB9edTZG2gNc2ew2t6kxc lHfuki/s78DFrzgvSx0p534N4UfW7b/AvTFVDCswkU4z1lcvFfvhcnnHXIuFloaLjm21 HE85TfOzs0SilQ+wQWK9pHRe1rihtlUNdrc2f+u4CBnV0++8ncuKMzTxDcut9GX6WSTb CDqc9GMjwC2GnhYBJCvFRxM87RiVu/3ZuaOO/wbVacBClGpEkCj6ey2YjWBUWeLSeS6S sLQA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1774620751; x=1775225551; h=content-transfer-encoding:in-reply-to:autocrypt:cc:content-language :references:to:from:subject:user-agent:mime-version:date:message-id :x-gm-gg:x-gm-message-state:from:to:cc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05AhWGGCXR65xlR C7iygx4WwMmkGI= X-Received: by 2002:a05:6000:4212:b0:439:b6ae:5d5f with SMTP id ffacd0b85a97d-43b9ea6267cmr4114164f8f.36.1774620750544; Fri, 27 Mar 2026 07:12:30 -0700 (PDT) Received: from [10.156.60.236] (ip-037-024-206-209.um08.pools.vodafone-ip.de. [37.24.206.209]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-43b919cf2bdsm16166385f8f.21.2026.03.27.07.12.30 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 27 Mar 2026 07:12:30 -0700 (PDT) Message-ID: <617d6e4b-4055-4dec-aa23-2a7681d659ba@suse.com> Date: Fri, 27 Mar 2026 15:12:29 +0100 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: [PATCH 4/8] gas: don't fail due to local register symbols From: Jan Beulich To: Binutils References: <04ccd34e-7b05-412b-a0fe-2039e323f7d1@suse.com> Content-Language: en-US Cc: "H.J. Lu" Autocrypt: addr=jbeulich@suse.com; keydata= xsDiBFk3nEQRBADAEaSw6zC/EJkiwGPXbWtPxl2xCdSoeepS07jW8UgcHNurfHvUzogEq5xk hu507c3BarVjyWCJOylMNR98Yd8VqD9UfmX0Hb8/BrA+Hl6/DB/eqGptrf4BSRwcZQM32aZK 7Pj2XbGWIUrZrd70x1eAP9QE3P79Y2oLrsCgbZJfEwCgvz9JjGmQqQkRiTVzlZVCJYcyGGsD /0tbFCzD2h20ahe8rC1gbb3K3qk+LpBtvjBu1RY9drYk0NymiGbJWZgab6t1jM7sk2vuf0Py O9Hf9XBmK0uE9IgMaiCpc32XV9oASz6UJebwkX+zF2jG5I1BfnO9g7KlotcA/v5ClMjgo6Gl MDY4HxoSRu3i1cqqSDtVlt+AOVBJBACrZcnHAUSuCXBPy0jOlBhxPqRWv6ND4c9PH1xjQ3NP nxJuMBS8rnNg22uyfAgmBKNLpLgAGVRMZGaGoJObGf72s6TeIqKJo/LtggAS9qAUiuKVnygo 3wjfk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com> X-Spam-Status: No, score=-3016.8 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, RCVD_IN_DNSWL_BLOCKED, SPF_HELO_NONE, SPF_NONE, TXREP, URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on sourceware.org X-BeenThere: binutils@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Binutils mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: binutils-bounces~patchwork=sourceware.org@sourceware.org The diagnostic text as well as its origin are pretty clear: This is about global symbols. This is further supported by S_IS_LOCAL() returning true for symbols in reg_section. Add the missing check, adjusting the testcase that was introduced back at the time (where the sole diagnostic originally issued was therefore wrong, while other diagnostics were missing, but got added thanks to work done elsewhere). Further drop the bogus trailing .equ in another testcase, which were apparently put there to avoid tripping this or some other undue check (albeit no error surfaced there already before the change here). While there also fully eliminate the redundant "sname": There's "name" already, getting set up a little earlier. --- For context: There's a pretty deep reaching issue in x86'es Intel syntax parsing, fixing of which would expose the issue addressed here by breaking (at least) the i386/equ.s testcase. If it was the "global" in the diagnostic that was wrong, i.e. if we'd want to error also on local register symbols, this check would need moving past the subsequent check for symbols wanting removing: If in particular S_IS_LOCAL() would cause the symbol to be dropped anyway, emitting the diagnostic would be wrong (making it entirely impossible to use register equates). Really this is also the connection to the Intel syntax issue mentioned above: The parser bogusly fiddles with equates when they're used, and once that's corrected the check here would trigger for any such equate (as it did already when an equate isn't used anywhere). This may actually be only a special case of a wider problem. Equates can be about any expression. If registers are involved (no matter whether the recorded section is reg_section or expr_section), surely such symbols should not only not appear in the symbol table, but also not cause errors out of resolve_symbol_value() (unless appearing in a relocation or being global)? There's also a listing issue lurking: Without the "nop", the diagnostics aren't (re-)emitted as part of the listing. Plus of course the first three shouldn't really be at the end in the first place. --- a/gas/testsuite/gas/i386/equ.s +++ b/gas/testsuite/gas/i386/equ.s @@ -59,6 +59,3 @@ _start: .if s == x .err .endif - - .equ r, -3 - .equ s, -3 --- a/gas/testsuite/gas/i386/inval-equ-2.l +++ b/gas/testsuite/gas/i386/inval-equ-2.l @@ -18,10 +18,13 @@ GAS LISTING .* [ ]*6[ ]+\.globl bar2 [ ]*7[ ]+\.set bar3,\(%eax\+1\) [ ]*8[ ]+\?\?\?\? A1...... mov bar3,%eax +[ ]*8[ ]+.. +[ ]*9[ ]+\.globl bar4 +[ ]*10[ ]+\.set bar4,\(%eax\+1\) +[ ]*11[ ]+\?\?\?\? 90 nop .* Error: invalid .* relocation against register .* Error: invalid .* relocation against register .* Error: invalid .* relocation against register .* Error: can't make global register symbol `bar1' .* Error: can't make global register symbol `bar2' -.* Error: can't make global register symbol `bar3' -[ ]*8[ ]+.. +.* Error: can't make global register symbol `bar4' --- a/gas/testsuite/gas/i386/inval-equ-2.s +++ b/gas/testsuite/gas/i386/inval-equ-2.s @@ -6,3 +6,6 @@ .globl bar2 .set bar3,(%eax+1) mov bar3,%eax + .globl bar4 + .set bar4,(%eax+1) + nop --- a/gas/write.c +++ b/gas/write.c @@ -2396,24 +2396,22 @@ write_object_file (void) if (symbol_equated_reloc_p (symp) || S_IS_WEAKREFR (symp)) { - const char *sname = S_GET_NAME (symp); - if (S_IS_COMMON (symp) - && !TC_FAKE_LABEL (sname) + && !TC_FAKE_LABEL (name) && !S_IS_WEAKREFR (symp)) { expressionS *e = symbol_get_value_expression (symp); as_bad (_("`%s' can't be equated to common symbol `%s'"), - sname, S_GET_NAME (e->X_add_symbol)); + name, S_GET_NAME (e->X_add_symbol)); } - if (S_GET_SEGMENT (symp) == reg_section) - { + + if (S_GET_SEGMENT (symp) == reg_section + && S_IS_EXTERNAL (symp) /* Report error only if we know the symbol name. */ - if (S_GET_NAME (symp) != reg_section->name) - as_bad (_("can't make global register symbol `%s'"), - sname); - } + && name != reg_section->name) + as_bad (_("can't make global register symbol `%s'"), name); + symbol_remove (symp, &symbol_rootP, &symbol_lastP); continue; }