From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2124) id 67A6B3858C98; Mon, 15 Apr 2024 15:28:43 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 67A6B3858C98 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1713194923; bh=uZ723U/MbHSaP4T3AqC607c5KggDly4wpJjCNLxzNbc=; h=From:To:Subject:Date:From; b=pDvFpC+XqPpBqemIGIdjiL1I2trw6+R9y242Ejh7e/jXubMDiHZEbcpFfyFStoZC+ PtL8MkR5J5OdKppf7TLLxOiPmoLOzUczqE+PGdrDcxmhyC87b8De6PBOATPKubpJQm eCx8jd0Lu9N89hPMOjqZZlKJcbc4qPhfZw2SigZM= 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] When mapping sections to segments ensure that we do not add sections whose VMA->LMA relationship doe X-Act-Checkin: binutils-gdb X-Git-Author: Vijay Shankar X-Git-Refname: refs/heads/master X-Git-Oldrev: 75670e0075df0f6fc8c324ea11de193a038274d6 X-Git-Newrev: ccbf42ec88f3e8bbb74dbdc1d6c9da3a9d805cff Message-Id: <20240415152843.67A6B3858C98@sourceware.org> Date: Mon, 15 Apr 2024 15:28:43 +0000 (GMT) List-Id: https://sourceware.org/git/gitweb.cgi?p=3Dbinutils-gdb.git;h=3Dccbf42ec88f3= e8bbb74dbdc1d6c9da3a9d805cff commit ccbf42ec88f3e8bbb74dbdc1d6c9da3a9d805cff Author: Vijay Shankar Date: Mon Apr 15 16:27:21 2024 +0100 When mapping sections to segments ensure that we do not add sections wh= ose VMA->LMA relationship does not match the relationship of earlier sectio= ns in the segment. =20 PR 31540 Diff: --- bfd/elf.c | 12 +++++++++--- binutils/testsuite/binutils-all/pr25662.ld | 2 ++ 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/bfd/elf.c b/bfd/elf.c index c305b40eca3..889078db097 100644 --- a/bfd/elf.c +++ b/bfd/elf.c @@ -8394,7 +8394,9 @@ copy_private_bfd_data (bfd *ibfd, bfd *obfd) /* Check to see if any sections in the input BFD covered by ELF program header have changed. */ Elf_Internal_Phdr *segment; - asection *section, *osec; + asection * section; + asection * osec; + asection * prev; unsigned int i, num_segments; Elf_Internal_Shdr *this_hdr; const struct elf_backend_data *bed; @@ -8425,7 +8427,7 @@ copy_private_bfd_data (bfd *ibfd, bfd *obfd) || segment->p_type =3D=3D PT_DYNAMIC)) goto rewrite; =20 - for (section =3D ibfd->sections; + for (section =3D prev =3D ibfd->sections; section !=3D NULL; section =3D section->next) { /* We mark the output section so that we know it comes @@ -8446,9 +8448,13 @@ 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) + || 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) goto rewrite; } + prev =3D section; } } =20 diff --git a/binutils/testsuite/binutils-all/pr25662.ld b/binutils/testsuit= e/binutils-all/pr25662.ld index 19ef1391f8d..4951184f88e 100644 --- a/binutils/testsuite/binutils-all/pr25662.ld +++ b/binutils/testsuite/binutils-all/pr25662.ld @@ -12,4 +12,6 @@ SECTIONS .text : { *(.text) } > ROM =20 .bss : { *(.bss) } > RAM + + /DISCARD/ : { *(.*) } }