From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2124) id A4C2E3858431; Tue, 16 Apr 2024 16:55:36 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org A4C2E3858431 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1713286536; bh=LLOvVGCvpMLzoSUguq71vjRTXUchECd/5klP5C8q3Y8=; h=From:To:Subject:Date:From; b=x/VyMpQ/sJQSgGdtkzyp1+ayoY2qIeVBljbnJQWgUPxHDx6FgCrfrndelyvXEbN/N GsZPwqcmi/8H6KgMQWYAhZBbwczJWvrPJE3IU+5pdAy27lNZZw3spKz83duVtwwFN/ EtmqWRFCeXEtpYxC0LDlTmaQ1PwJ5erGeQ68/hk0= Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: Nick Clifton To: binutils-cvs@sourceware.org Subject: [binutils-gdb] Fix test for sections with different VMA<->LMA relationships so that it only applies to allocated se X-Act-Checkin: binutils-gdb X-Git-Author: Nick Clifton X-Git-Refname: refs/heads/master X-Git-Oldrev: 12f5356130c2cda10e2589e74a8716563050dccb X-Git-Newrev: b6fc194038ce0744532d6471499326114c0f0d90 Message-Id: <20240416165536.A4C2E3858431@sourceware.org> Date: Tue, 16 Apr 2024 16:55:36 +0000 (GMT) List-Id: https://sourceware.org/git/gitweb.cgi?p=3Dbinutils-gdb.git;h=3Db6fc194038ce= 0744532d6471499326114c0f0d90 commit b6fc194038ce0744532d6471499326114c0f0d90 Author: Nick Clifton Date: Tue Apr 16 17:54:13 2024 +0100 Fix test for sections with different VMA<->LMA relationships so that it= only applies to allocated sections, and only sections in the same segment = are checked. =20 PR 31450 Diff: --- bfd/elf.c | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/bfd/elf.c b/bfd/elf.c index 889078db097..52a6a2f56c3 100644 --- a/bfd/elf.c +++ b/bfd/elf.c @@ -8427,7 +8427,7 @@ copy_private_bfd_data (bfd *ibfd, bfd *obfd) || segment->p_type =3D=3D PT_DYNAMIC)) goto rewrite; =20 - for (section =3D prev =3D ibfd->sections; + for (section =3D ibfd->sections, prev =3D NULL; section !=3D NULL; section =3D section->next) { /* We mark the output section so that we know it comes @@ -8448,13 +8448,20 @@ copy_private_bfd_data (bfd *ibfd, bfd *obfd) || section->vma !=3D osec->vma || section->size !=3D osec->size || section->rawsize !=3D osec->rawsize - || section->alignment_power !=3D osec->alignment_power - /* PR 31450: Make sure this section's vma to lma - relationship is the same as previous section's. */ - || section->lma - section->vma !=3D prev->lma - prev->vma) + || section->alignment_power !=3D osec->alignment_power) goto rewrite; + + /* PR 31450: If this is an allocated section then make sure + that this section's vma to lma relationship is the same + as previous (allocated) section's. */ + if (prev !=3D NULL + && section->flags & SEC_ALLOC + && section->lma - section->vma !=3D prev->lma - prev->vma) + goto rewrite; + + if (section->flags & SEC_ALLOC) + prev =3D section; } - prev =3D section; } }