From patchwork Sun Sep 20 23:57:24 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Samuel Price X-Patchwork-Id: 144241 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from vm01.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 0DA5A4BA23E6 for ; Sun, 20 Sep 2026 23:58:06 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 0DA5A4BA23E6 Authentication-Results: sourceware.org; dkim=pass (2048-bit key, unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20251104 header.b=DH3jPsM3 X-Original-To: binutils@sourceware.org Delivered-To: binutils@sourceware.org Received: from mail-qv2-x10.google.com (mail-qv2-x10.google.com [IPv6:2607:f8b0:4864:33::10]) by sourceware.org (Postfix) with ESMTPS id 43CB44BA23C3 for ; Sun, 20 Sep 2026 23:57:32 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 43CB44BA23C3 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 43CB44BA23C3 Authentication-Results: sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:33::10 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1789948652; cv=none; b=Q8Wjhne5Hu70N3rF78ihpofcrLKI4b7TXKBMGfgrG1c05wyuOarLVv+isRa2CsIIP0rlUZbN6uWBjifzIa3cXuLDALflH/A+FIj5BLk6doXVuLL8AT/K3GGT+hSiyTHBrlBPUtAlCAKaT3vft257WexaJhCBIPu9zfYIA4Md3B0= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1789948652; c=relaxed/simple; bh=hpXHR1db+HUigP4147mwgKh1ePFL1TQ8kIjrLMYU0tc=; h=DKIM-Signature:From:To:Subject:Date:Message-Id:MIME-Version; b=nbW5QdR5e/qIUP3bb1+SvaBhb1l2rE8CP3TIQ5c4LO1g2w6tjTJKrd1oFz4YIydIE8AmGaLd47jMBHUPDvwtNiNpLQ0fFTgx/As9FapN71caiSuEvB7OoOLIV7SVOsJ4JUgCEjQBQ6CBUvg4y2W8qAESbYdB4d0g8WR6tDcEQO0= ARC-Authentication-Results: i=1; sourceware.org; dkim=pass (2048-bit key, unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20251104 header.b=DH3jPsM3 DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 43CB44BA23C3 Received: by mail-qv2-x10.google.com with SMTP id 6a1803df08f44-910537b51a0so22027916d6.3 for ; Sun, 20 Sep 2026 16:57:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1789948652; x=1790553452; darn=sourceware.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to:content-type; bh=i3qDezu80pLEA1/pvtR1et2waN179EmkRtgNJOLybys=; b=DH3jPsM3S0hySyZZHMy/AydLVPw617fPQxQN/7yHJ9JNMPqY73Qq5yceJi95ij0L10 dGVEbEPHfbyMihMPuBjRayfA8vYQo9Go40pcHZq8TkFxempCgJFUI7S/LQRX7BXNR/tt xyqgT040yNABtAe2rtzXZG6VrcGpKc88Dhoc7V8SkJp89nOw6zB+eQhv9cs8i+bj7o2H n/vqzXnXVQ1APg8gTOB39W7NCBsAOnSlPpzi/TUOYH2rGSvpTReDEHf2MzseIblIBLgt OgRkGs6yGXC0kLyYUOsHPIF1MFLbceKgeVKxIZrUy3jypQqt5hBGJyHJyxVb7ErvHZdh WP0w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1789948652; x=1790553452; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to:content-type; bh=i3qDezu80pLEA1/pvtR1et2waN179EmkRtgNJOLybys=; b=cGJoGoMWjVIKxb0kbFuhHgPKFCXG1lAdO4J878wxUzhrZysblMOPGSY86m/Bsq3/YL pLoKIllY20XhPa0Lm+7tdWaZt862dVSBXjtIbUAM7ZbfPvC+eAAsKj6aTXjsAO+zdqSU G9wg3BMkNS7ayi7wwCmvyIoQUcj+TJSwF83Iq2Tu6MxRauN7h/qzR0VL0mlMIGpmLSJW 5Y4F/xOxbGlLCMGxOx+b/SOvjyRTO3TIEZMU3Kd5nD+gJFS6oTuhvlYmYrnPtOOSYdM5 /h4Gm8qoqupFNfXtD4OQmWVHLGBVYludgv0ISjIPJyIIZgPSKN5WrnUcaAkw+qrCg5AA YzCQ== X-Gm-Message-State: AFuF++nuu9RG1KGcWli09XQLD54TwW77ng4odY9a++JaSd2JYb34fEvg vS0VwGFMu0IjWwaKctSp9YE+YEQuPW8Mb+mep6uRUiyOF2UXKJTic/g1cUuYIA== X-Gm-Gg: AYBFou0KTT/iKpBdxY9//MkEZVQ4gDZgq0zIcMCpPMfbI2B2d06O+SGx5O4WtWhwekL M2peEjfFFIFTSwR2kCbIL0lAuLqPVlm15G4LSKr9MyUziEZMl9WTokBkg3eHju+eSHvSJNsiaW2 856EbzmNc1jlbkYyyDttOlowpyBE3IccL3Nh7vy8CxfMlYdyhXyKhj8SwVz+nSKZLcy9/vvx9wN p2Zm6z7wlM1OxgqNUXLxgjmkrVjYImtBTJjgR0WteH+aQG9NISjcteYX60vnpfjPBl5zd/SdNaF 90dZ15USgNtFe2mRPYjP/URAaPYH+wmxZs9TlNzfMc3ggyYKUKGJv8Qy34IebXCJ3r69flBDFOy mQ1P8avIMNdZrYsil+tc7eAuJKQ7lJQ2ABff8EIF9GuqhCw3AxIkrNgB01VV6mTnig79SFThrMF 7Mg80bJ5Fgw78Y+pFU0teLhsSPNWpjWP/9Fc6xVMZToFy4zt6GNv47G99e8Aw2e7vquKL9hCGUb Y3BH6XD9bl/W5Bu0cJZKzej1s9vLgEZojq0ieQlphXcJYxnBBTTUgbRbM5tD3btoCLJse2L3wKw YpZ3K5PqTVfJFQ== X-Received: by 2002:a05:6214:2b97:b0:912:517b:9758 with SMTP id 6a1803df08f44-912a804ddf3mr89239436d6.50.1789948651636; Sun, 20 Sep 2026 16:57:31 -0700 (PDT) Received: from localhost (pool-96-241-179-174.washdc.fios.verizon.net. [96.241.179.174]) by smtp.gmail.com with ESMTPSA id 6a1803df08f44-91260a878absm53700926d6.31.2026.09.20.16.57.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 20 Sep 2026 16:57:30 -0700 (PDT) From: Sam Price To: binutils@sourceware.org, eager@eagercon.com Cc: neal.frager@amd.com, Samuel Price Subject: [PATCH] microblaze: add BFD_RELOC_8 and BFD_RELOC_16 cases Date: Sun, 20 Sep 2026 19:57:24 -0400 Message-Id: <20260920235724.37190-1-thesamprice@gmail.com> X-Mailer: git-send-email 2.39.5 (Apple Git-154) MIME-Version: 1.0 X-Spam-Status: No, score=-10.3 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, RCVD_IN_PBL, SPF_HELO_NONE, SPF_PASS, TXREP shortcircuit=no 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 From: Samuel Price md_apply_fix has cases for BFD_RELOC_32, BFD_RELOC_64 and for the MicroBlaze-specific relocations, but none for BFD_RELOC_8 or BFD_RELOC_16. Those fall through to the default and nothing is written, so a byte or halfword datum whose value is only known at fixup time assembles to zero. The fixup is then resolved and turned into BFD_RELOC_NONE, so no relocation survives for the linker to correct it either, and the zero is permanent. The two new cases replicate the BFD_RELOC_32 case immediately below them in the same switch -- the same S_IS_DEFINED guard and the same target_big_endian byte order -- narrowed to one and two bytes. Fixes gas/all/simple-forward. It also fixes gas/all/forward, which was xfailed for microblaze-*-*, so drop it from that xfail list. The gas testsuite on microblaze-elf goes from 327 passes and 1 unexpected failure to 329 passes and 0 failures. gas/ * config/tc-microblaze.c (md_apply_fix): Handle BFD_RELOC_8 and BFD_RELOC_16. * testsuite/gas/all/forward.d: Remove the microblaze-*-* xfail. Signed-off-by: Sam Price Assisted-by: Claude (Anthropic) Reviewed-by: Neal Frager --- I considered writing the two new cases the way aarch64 and mips do instead -- case BFD_RELOC_16: case BFD_RELOC_8: if (fixP->fx_done) md_number_to_chars (buf, *valP, fixP->fx_size); break; -- which is shorter, drops the endianness branch, and guards on fx_done rather than S_IS_DEFINED, which is arguably what is really meant here. The comment on that case in tc-mips.c describes this exact failure mode: "If we are deleting this reloc entry, we must fill in the value now." I kept the local form so the patch stays minimal and consistent with its neighbour, but I am happy to send the md_number_to_chars version instead if you would rather have it. Or if you want the neighbors converted to aarch64 / mips and tested I can do that also. gas/config/tc-microblaze.c | 23 +++++++++++++++++++++++ gas/testsuite/gas/all/forward.d | 2 +- 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/gas/config/tc-microblaze.c b/gas/config/tc-microblaze.c index 3e3dca81921..36b98bbd8fc 100644 --- a/gas/config/tc-microblaze.c +++ b/gas/config/tc-microblaze.c @@ -2145,6 +2145,29 @@ md_apply_fix (fixS * fixP, } } break; + case BFD_RELOC_8: + /* Don't do anything if the symbol is not defined. */ + if (fixP->fx_addsy == NULL || S_IS_DEFINED (fixP->fx_addsy)) + buf[0] |= (val & 0xff); + break; + + case BFD_RELOC_16: + /* Don't do anything if the symbol is not defined. */ + if (fixP->fx_addsy == NULL || S_IS_DEFINED (fixP->fx_addsy)) + { + if (target_big_endian) + { + buf[0] |= ((val >> 8) & 0xff); + buf[1] |= (val & 0xff); + } + else + { + buf[1] |= ((val >> 8) & 0xff); + buf[0] |= (val & 0xff); + } + } + break; + case BFD_RELOC_32: case BFD_RELOC_RVA: case BFD_RELOC_32_PCREL: diff --git a/gas/testsuite/gas/all/forward.d b/gas/testsuite/gas/all/forward.d index d921ec517be..360ab778ebb 100644 --- a/gas/testsuite/gas/all/forward.d +++ b/gas/testsuite/gas/all/forward.d @@ -11,7 +11,7 @@ # mep and microblaze use complex relocs and don't resolve the relocs. # one of the relocs references minus_one, which is a bug, but no one # seems bothered enough to fix this. -#xfail: mep-*-* microblaze-*-* +#xfail: mep-*-* .*: .*