From patchwork Wed Jun 3 12:50:31 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alan Modra X-Patchwork-Id: 136382 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 796304BA2E33 for ; Wed, 3 Jun 2026 12:51:13 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 796304BA2E33 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=XOXD315g X-Original-To: binutils@sourceware.org Delivered-To: binutils@sourceware.org Received: from mail-pl1-x633.google.com (mail-pl1-x633.google.com [IPv6:2607:f8b0:4864:20::633]) by sourceware.org (Postfix) with ESMTPS id 5E4E54BA2E15 for ; Wed, 3 Jun 2026 12:50:36 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 5E4E54BA2E15 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 5E4E54BA2E15 Authentication-Results: sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::633 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1780491036; cv=none; b=sbNSL3ldPpQT1wsEfKIcFhZAaoy8LQtnpvaoeVmwrgxebgPK0iVzYPA+u3ew0Zl4qAiV03CmVNrkWQzE6+26eAWmHLjzXSlneKNq5K2TEk8t3SnOv9kWjGbr0mTGoxzYDMGZ8ejOwY4Sm7RhPAvA5m617oWbMiUWOY2KzfHSp2s= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1780491036; c=relaxed/simple; bh=1AK7vwYEv7dAvGXA/bjtBL7pxLBGLQuqTKask6nBUPM=; h=DKIM-Signature:Date:From:To:Subject:Message-ID:MIME-Version; b=tA1HdjoR7JkwVkO1r0Ol/wwxFo1QjaSJIHKlnm2Bs+FeenuAeQ9PQtPPyoQTlWEAUKQffdf1Y22K7zCpSG3yb+D4T/wIz3mm2ukqpRADuG9N2qCa818P9JhdVSAXichWSwvtj4a/80zq6zSZ8hCzDElFj1Qz0vBn2Px3Pcp3ri8= 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=XOXD315g DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 5E4E54BA2E15 Received: by mail-pl1-x633.google.com with SMTP id d9443c01a7336-2c0c2d8b95bso24971155ad.1 for ; Wed, 03 Jun 2026 05:50:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1780491035; x=1781095835; darn=sourceware.org; h=content-disposition:mime-version:message-id:subject:to:from:date :from:to:cc:subject:date:message-id:reply-to; bh=C6TwtIlLTyJM0Mcu23eXLG0LxxmNg43lWhsj8ffWaco=; b=XOXD315g7CG7DhWX2wwejRS42lh48AdpPdiQ+ERzlpyEaixmH+udjMmMfMbuT1XZIp AkuEuwpjB+kKQao0DdDBlqKdev8uGFBehY04G130BbccHM1QeMZAnh3FuQ/qorkojbEW taJ7XPFJPjMD09hre+mM7E9/ePtaX5h5tBmXLuoMS06R7QJ12T2bxDL2rejTsKtnpl8e ZRte5xi7ZYvqFDJgbWC/JljWIbIEmjUp7qLw+vUqiTRknFkCZeq9viu2pK9qrOEBSxkt aaWWXcP9swZ212T9p+Hh2FJAkZii36icJsWRLB9/DIHxq9LFN6EdPVCThRh/llVMYE3X xJjg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1780491035; x=1781095835; h=content-disposition:mime-version:message-id:subject:to:from:date :x-gm-gg:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=C6TwtIlLTyJM0Mcu23eXLG0LxxmNg43lWhsj8ffWaco=; b=K/fGw23HINIYDNY1E2owCJu7MFHqp99F2JSaaS40Vi4PHRy79j58CLjYsDl+7HjFyD +FNtGrVpDqAMj9n1kYu1ES4Tqd2fWsjr376mZwMRMFiRnMN4n6xsDLinzqZAsJ0HuHRW AdLWtftivlXcv9nsNE1q/d7cDBEYOG/Bjh8oBamog6ykf8LJ5cC00ACBYThv/hs8f+sP Uh2Zux7Vu3gH69wrDkVeK1owP7UbifL3yR0RfBbyia4JK5+M7tOuIwUliKGhBF3366OA f/pd2yrt08EarJdE8emBmKBUTdBwroWQWO+l3nO2EgVeZBETNGuHG4N8nU5lGPj1MKfI J2Tg== X-Gm-Message-State: AOJu0YzJhWD0jPu51EXfIu5rKJoCZQwmtLZM3GeJnd1ll4L3kKPXL1M0 7HoRBV3DMqVYFVqkR2yQcokzDa+Dn3tiFT8johTUWGyyWjh3GyNO0edb9KPEWQ== X-Gm-Gg: Acq92OEXsLEhWG6pJyJRkUsuyvwkZyBFpeQpCjvOmrITAywKWJRm3hvVtM75WhdYZyq 1Bod+Vg+4VqKPpRrA4yhpzluFBKgSgAazuzEN8c6y5Cgnj3bOt3yeO8N1IEUzWq+bp4j1oHX8cb Br/b2IeTeI9AMD52ySXKtcVy3LKDQf4K8eScCV/1gfMcaO/5pC+gPZs3SLA2D136+owqI/vJ+Fo CsRidgmdP2LnFIXRplKKnYmb1RHTPbgf7b7eCjvL2JasA89AAI5+9N0mvVHH8MhotLW2rvoDA2n 66GdyJdYPvRIJOkKcrc0WYM7jYaxmVcli31Bi5i9dNP6kdiwbcgLaEWFTKLybzBBM0Yiy4av/au rHgLdxRUf1biv4oDM/tAV9fTz4j5++EZ012s2riSFBgbG/waRZS7X5I/HTqvt62gle/GiFea5wv qH094PUxBsXkrFlp1HITU8oIiDLzlY1aByTo4r5Y5gJoyi93vUajoM4YXcNFpXmuWdFp2/PRDM2 mo= X-Received: by 2002:a17:903:3bcf:b0:2c0:c625:400d with SMTP id d9443c01a7336-2c1644e4d16mr35952345ad.37.1780491035000; Wed, 03 Jun 2026 05:50:35 -0700 (PDT) Received: from squeak.grove.modra.org (58-96-106-158.ip4.superloop.au. [58.96.106.158]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-2c164f6d395sm35646365ad.17.2026.06.03.05.50.34 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Jun 2026 05:50:34 -0700 (PDT) Received: by squeak.grove.modra.org (Postfix, from userid 1000) id A12D91141907; Wed, 03 Jun 2026 22:20:31 +0930 (ACST) Date: Wed, 3 Jun 2026 22:20:31 +0930 From: Alan Modra To: binutils@sourceware.org Subject: spu: .note.spu_name Message-ID: MIME-Version: 1.0 Content-Disposition: inline X-Spam-Status: No, score=-3029.0 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, GIT_PATCH_0, LOTS_OF_MONEY, MONEY_NOHTML, RCVD_IN_DNSWL_BLOCKED, 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 This fixes a bug with the .note.spu_name section flags, which were made SEC_LOAD without SEC_ALLOC. That combination doesn't really make sense and led to odd layout behaviour. In addition .note.spu_name now uses the normal note alignment, with some tweaks to keep its file offset 16 byte aligned. This tends to work better in the testsuite when the standard scripts are not used and the note is merged with other notes. bfd/ * elf32-spu.c (spu_elf_create_sections): Remove SEC_LOAD from .note.spu_name, and align to 4 bytes. (spu_elf_fake_sections): Tweak .note.spu_name output section alignment for layout. (spu_elf_final_write_processing): New function. (elf_backend_final_write_processing): Define. binutils/ * testsuite/binutils-all/objcopy.exp (pr25662): Don't xfail spu. ld/ * testsuite/ld-elf/orphan-region.d: Don't xfail spu. * testsuite/ld-elf/pr23658-1e.d: Likewise. * testsuite/ld-scripts/provide-8.d: Likewise. * testsuite/ld-spu/ovl.d: Remove commented out old matches. Adjust expected overlay file offset. * testsuite/ld-spu/ovl2.d: Likewise. diff --git a/bfd/elf32-spu.c b/bfd/elf32-spu.c index 5f547b65443..9a9d3a0401c 100644 --- a/bfd/elf32-spu.c +++ b/bfd/elf32-spu.c @@ -583,10 +583,10 @@ spu_elf_create_sections (struct bfd_link_info *info) ibfd = info->input_bfds; /* This should really be SEC_LINKER_CREATED, but then we'd need to write out the section ourselves. */ - flags = SEC_LOAD | SEC_READONLY | SEC_HAS_CONTENTS | SEC_IN_MEMORY; + flags = SEC_READONLY | SEC_HAS_CONTENTS | SEC_IN_MEMORY; s = bfd_make_section_anyway_with_flags (ibfd, SPU_PTNOTE_SPUNAME, flags); if (s == NULL - || !bfd_set_section_alignment (s, 4)) + || !bfd_set_section_alignment (s, 2)) return false; /* Because we didn't set SEC_LINKER_CREATED we need to set the proper section type. */ @@ -5342,10 +5342,32 @@ spu_elf_fake_sections (bfd *obfd ATTRIBUTE_UNUSED, asection *sec) { if (strcmp (sec->name, SPU_PTNOTE_SPUNAME) == 0) - hdr->sh_type = SHT_NOTE; + { + hdr->sh_type = SHT_NOTE; + hdr->sh_addralign = 16; + } return true; } +/* .note.spu_name is read by the PPU from the object, and possibly + needs the file offset to be aligned to 16 bytes. We used to simply + call bfd_set_section_alignment to set the alignment to 16, but if + left like that it triggers a readelf warning. Now for layout we + tweak the alignment to 16 in spu_elf_fake_sections, and restore it + to 4 here. */ + +static bool +spu_elf_final_write_processing (bfd *abfd) +{ + asection *sec = bfd_get_section_by_name (abfd, SPU_PTNOTE_SPUNAME); + if (sec != NULL) + { + struct bfd_elf_section_data *esd = elf_section_data (sec); + esd->this_hdr.sh_addralign = 4; + } + return _bfd_elf_final_write_processing (abfd); +} + /* Tweak phdrs before writing them out. */ static bool @@ -5539,6 +5561,7 @@ spu_elf_size_sections (bfd *obfd ATTRIBUTE_UNUSED, struct bfd_link_info *info) #define elf_backend_modify_headers spu_elf_modify_headers #define elf_backend_init_file_header spu_elf_init_file_header #define elf_backend_fake_sections spu_elf_fake_sections +#define elf_backend_final_write_processing spu_elf_final_write_processing #define elf_backend_special_sections spu_elf_special_sections #define bfd_elf32_bfd_final_link spu_elf_final_link diff --git a/binutils/testsuite/binutils-all/objcopy.exp b/binutils/testsuite/binutils-all/objcopy.exp index c11b911df67..25e2a440967 100644 --- a/binutils/testsuite/binutils-all/objcopy.exp +++ b/binutils/testsuite/binutils-all/objcopy.exp @@ -1556,7 +1556,6 @@ run_dump_test "pr23633" run_dump_test "set-section-alignment" setup_xfail "hppa*-*-*" -setup_xfail "spu-*-*" clear_xfail "hppa*64*-*-hpux*" "hppa*-*-linux*" "hppa*-*-lites*" clear_xfail "hppa*-*-*n*bsd*" "hppa*-*-*elf*" if { [istarget pdp11-*-*] } { diff --git a/ld/testsuite/ld-elf/orphan-region.d b/ld/testsuite/ld-elf/orphan-region.d index 13fb31fff9f..7be708ddcf6 100644 --- a/ld/testsuite/ld-elf/orphan-region.d +++ b/ld/testsuite/ld-elf/orphan-region.d @@ -1,9 +1,9 @@ #source: orphan-region.s #ld: -T orphan-region.ld -N -z stack-size=0 --no-warn-rwx-segments #readelf: -S -l --wide -#xfail: [uses_genelf] hppa*64*-*-hpux* spu-*-* +#xfail: [uses_genelf] hppa*64*-*-hpux* # if not using elf.em, you don't get fancy orphan handling -# spu twiddles LOAD range, hppa64 adds PHDR +# hppa64 adds PHDR #... \[[ 0-9]+\] \.text[ \t]+PROGBITS[ \t]+0*40000000[ \t]+.* diff --git a/ld/testsuite/ld-elf/pr23658-1e.d b/ld/testsuite/ld-elf/pr23658-1e.d index dbb05e6293e..c331aa7c902 100644 --- a/ld/testsuite/ld-elf/pr23658-1e.d +++ b/ld/testsuite/ld-elf/pr23658-1e.d @@ -14,7 +14,7 @@ #xfail: cr16-* crx-* visium-* # The following targets place .note.gnu.build-id in unusual places. #xfail: *-*-hpux* -#xfail: arc*-* avr-* m68hc1*-* microblaze*-* nds32*-* spu-*-* xstormy16-*-* +#xfail: arc*-* avr-* m68hc1*-* microblaze*-* nds32*-* xstormy16-*-* #noxfail: microblaze*-linux* #... diff --git a/ld/testsuite/ld-scripts/provide-8.d b/ld/testsuite/ld-scripts/provide-8.d index 250b0441479..a6136ad52d7 100644 --- a/ld/testsuite/ld-scripts/provide-8.d +++ b/ld/testsuite/ld-scripts/provide-8.d @@ -1,7 +1,7 @@ #source: provide-5.s #ld: -T provide-8.t #nm: -B -#xfail: mmix-*-* spu-*-* +#xfail: mmix-*-* # Placing a symbol outside of the image isn't well-defined in PE. #notarget: *-*-pe *-*-mingw* *-*-cygwin diff --git a/ld/testsuite/ld-spu/ovl.d b/ld/testsuite/ld-spu/ovl.d index a0372a0e2fd..052a45fb074 100644 --- a/ld/testsuite/ld-spu/ovl.d +++ b/ld/testsuite/ld-spu/ovl.d @@ -70,30 +70,6 @@ Disassembly of section \.text: .* ila \$79,1076 # 434 .* bra? .* <__ovly_load>.* -#00000330 <00000000\.ovl_call\.f1_a1>: -#.* bra?sl \$75,.* <__ovly_load>.* -#.*00 04 04 00.* -# -#00000338 <00000000\.ovl_call\.f2_a1>: -#.* bra?sl \$75,.* <__ovly_load>.* -#.*00 04 04 04.* -# -#00000340 <00000000\.ovl_call\.f1_a2>: -#.* bra?sl \$75,.* <__ovly_load>.* -#.*00 08 04 00.* -# -#00000348 <00000000\.ovl_call\.f2_a2>: -#.* bra?sl \$75,.* <__ovly_load>.* -#.*00 08 04 24.* -# -#00000350 <00000000\.ovl_call\.f4_a1>: -#.* bra?sl \$75,.* <__ovly_load>.* -#.*00 04 04 10.* -# -#00000358 <00000000.ovl_call.14:8>: -#.* bra?sl \$75,.* <__ovly_load>.* -#.*00 08 04 34.* - Disassembly of section \.ov_a1: 00000400 : @@ -150,13 +126,11 @@ Disassembly of section .data: 00000450 <_ovly_table>: 450: 00 00 04 00 .* 454: 00 00 00 20 .* -# 458: 00 00 03 40 .* - 458: 00 00 01 00 .* + 458: 00 00 00 e0 .* 45c: 00 00 00 01 .* 460: 00 00 04 00 .* 464: 00 00 00 40 .* -# 468: 00 00 03 60 .* - 468: 00 00 01 20 .* + 468: 00 00 01 00 .* 46c: 00 00 00 01 .* 00000470 <_ovly_buf_table>: diff --git a/ld/testsuite/ld-spu/ovl2.d b/ld/testsuite/ld-spu/ovl2.d index b8570c069d1..a0921828907 100644 --- a/ld/testsuite/ld-spu/ovl2.d +++ b/ld/testsuite/ld-spu/ovl2.d @@ -103,13 +103,11 @@ Disassembly of section \.data: 00000430 <_ovly_table>: .*00 00 04 00 .* .*00 00 00 20 .* -#.*00 00 03 10 .* -.*00 00 01 00 .* +.*00 00 00 e0 .* .*00 00 00 01 .* .*00 00 04 00 .* .*00 00 00 20 .* -#.*00 00 03 20 .* -.*00 00 01 20 .* +.*00 00 01 00 .* .*00 00 00 01 .* 00000450 <_ovly_buf_table>: