[Bug binutils/31540] objcopy, ELF_SECTION_IN_SEGMENT_1 section to segment mapping seems wrong
https://sourceware.org/bugzilla/show_bug.cgi?id=31540 --- Comment #9 from Nick Clifton --- Hi Alan, > https://sourceware.org/bugzilla/show_bug.cgi?id=31540 > > --- Comment #8 from Alan Modra --- > Nick, your change to binutils/testsuite/binutils-all/pr25662.ld results in > arc-elf +FAIL: objcopy executable (pr25662) > arc-linux-uclibc +FAIL: objcopy executable (pr25662) > bfin-linux-uclibc +FAIL: objcopy executable (pr25662) > frv-linux-gnu +FAIL: objcopy executable (pr25662) > spu-elf +XPASS: objcopy executable (pr25662) Doh! That change was not even meant to go in. It was a potential patch for a completely different issue. I will revert my commit. Sorry about the mis-commmit! Cheers Nick -- You are receiving this mail because: You are on the CC list for the bug.
[Bug binutils/31540] objcopy, ELF_SECTION_IN_SEGMENT_1 section to segment mapping seems wrong
https://sourceware.org/bugzilla/show_bug.cgi?id=31540 --- Comment #8 from Alan Modra --- Nick, your change to binutils/testsuite/binutils-all/pr25662.ld results in arc-elf +FAIL: objcopy executable (pr25662) arc-linux-uclibc +FAIL: objcopy executable (pr25662) bfin-linux-uclibc +FAIL: objcopy executable (pr25662) frv-linux-gnu +FAIL: objcopy executable (pr25662) spu-elf +XPASS: objcopy executable (pr25662) -- You are receiving this mail because: You are on the CC list for the bug.
[Bug binutils/31540] objcopy, ELF_SECTION_IN_SEGMENT_1 section to segment mapping seems wrong
https://sourceware.org/bugzilla/show_bug.cgi?id=31540 --- Comment #7 from vijay Shankar --- (In reply to Nick Clifton from comment #6) > Right - well the patch looks good to me, and did not trigger any problems, > so I have gone ahead and checked it in. Thanks Nick. -- You are receiving this mail because: You are on the CC list for the bug.
[Bug binutils/31540] objcopy, ELF_SECTION_IN_SEGMENT_1 section to segment mapping seems wrong
https://sourceware.org/bugzilla/show_bug.cgi?id=31540 --- Comment #5 from Sourceware Commits --- The master branch has been updated by Nick Clifton : https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=ccbf42ec88f3e8bbb74dbdc1d6c9da3a9d805cff 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 whose VMA->LMA relationship does not match the relationship of earlier sections in the segment. PR 31540 -- You are receiving this mail because: You are on the CC list for the bug.
[Bug binutils/31540] objcopy, ELF_SECTION_IN_SEGMENT_1 section to segment mapping seems wrong
https://sourceware.org/bugzilla/show_bug.cgi?id=31540 Nick Clifton changed: What|Removed |Added Resolution|--- |FIXED Status|ASSIGNED|RESOLVED --- Comment #6 from Nick Clifton --- Right - well the patch looks good to me, and did not trigger any problems, so I have gone ahead and checked it in. -- You are receiving this mail because: You are on the CC list for the bug.
[Bug binutils/31540] objcopy, ELF_SECTION_IN_SEGMENT_1 section to segment mapping seems wrong
https://sourceware.org/bugzilla/show_bug.cgi?id=31540 --- Comment #4 from vijay Shankar --- > Can you confirm that the patch fixes the problem you initially reported ? Yes, can confirm that the patch does fix the issue Here's section to segment mapping with and without patch without change --SEGMAP-- LOAD: .eh_frame --SEGMAP-- LOAD: .text --SEGMAP-- LOAD: .data .bss .tbss .sdata --SEGMAP-- TLS: .tbss --SEGMAP-- STACK: ./objcopy: stVzY0CU: section `.data' can't be allocated in segment 0 LOAD: .tbss .data .bss .sdata ./objcopy: stVzY0CU: section `.bss' can't be allocated in segment 0 LOAD: .tbss .data .bss .sdata with change --SEGMAP-- LOAD: .eh_frame --SEGMAP-- LOAD: .text --SEGMAP-- LOAD: .data .bss .sdata --SEGMAP-- TLS: .tbss --SEGMAP-- STACK: -- You are receiving this mail because: You are on the CC list for the bug.
[Bug binutils/31540] objcopy, ELF_SECTION_IN_SEGMENT_1 section to segment mapping seems wrong
https://sourceware.org/bugzilla/show_bug.cgi?id=31540 Nick Clifton changed: What|Removed |Added Status|UNCONFIRMED |ASSIGNED CC||nickc at redhat dot com Ever confirmed|0 |1 Last reconfirmed||2024-04-15 Assignee|unassigned at sourceware dot org |nickc at redhat dot com --- Comment #3 from Nick Clifton --- (In reply to vijay Shankar from comment #2) > I have a patch suggestion for this issue I am running the patch through my test farm and so far it is looking good. Can you confirm that the patch fixes the problem you initially reported ? Cheers Nick -- You are receiving this mail because: You are on the CC list for the bug.
[Bug binutils/31540] objcopy, ELF_SECTION_IN_SEGMENT_1 section to segment mapping seems wrong
https://sourceware.org/bugzilla/show_bug.cgi?id=31540 --- Comment #2 from vijay Shankar --- I have a patch suggestion for this issue added check to copy_private_bfd_data so that sections with inconsistent relation between vma and lma go to re-write im not sure how this will affect other cases maybe linker scripts? waiting on experts opinion on this change. alternative way would be to exclude tbss from PT_LOAD by adding checks in releavent places ( ELF_SECTION_IN_SEGMENT_1, make_mapping ). diff --git a/bfd/elf.c b/bfd/elf.c index c305b40e..b45e1eee 100644 --- a/bfd/elf.c +++ b/bfd/elf.c @@ -8394,7 +8394,7 @@ 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, *osec, *prev; unsigned int i, num_segments; Elf_Internal_Shdr *this_hdr; const struct elf_backend_data *bed; @@ -8425,7 +8425,7 @@ copy_private_bfd_data (bfd *ibfd, bfd *obfd) || segment->p_type == PT_DYNAMIC)) goto rewrite; - for (section = ibfd->sections; + for (section = ibfd->sections,prev=section; section != NULL; section = section->next) { /* We mark the output section so that we know it comes @@ -8440,16 +8440,21 @@ copy_private_bfd_data (bfd *ibfd, bfd *obfd) { /* FIXME: Check if its output section is changed or removed. What else do we need to check? */ + /* make sure this sections vma and lma relation is +same as previous section otherwise it needs a +rewrite */ if (osec == NULL || section->flags != osec->flags || section->lma != osec->lma || section->vma != osec->vma || section->size != osec->size || section->rawsize != osec->rawsize - || section->alignment_power != osec->alignment_power) + || section->alignment_power != osec->alignment_power + || section->lma - section->vma != prev->lma - prev->vma) goto rewrite; } } + prev = section; } /* Check to see if any output section do not come from the -- You are receiving this mail because: You are on the CC list for the bug.
[Bug binutils/31540] objcopy, ELF_SECTION_IN_SEGMENT_1 section to segment mapping seems wrong
https://sourceware.org/bugzilla/show_bug.cgi?id=31540 --- Comment #1 from vijay Shankar --- I have a patch suggestion for this issue added check to copy_private_bfd_data so that sections with inconsistent relation between vma and lma go to re-write im not sure how this will affect other cases maybe linker scripts? waiting on experts opinion on this change. alternative way would be to exclude tbss from PT_LOAD by adding checks in releavent places ( ELF_SECTION_IN_SEGMENT_1, make_mapping ). diff --git a/bfd/elf.c b/bfd/elf.c index c305b40e..b45e1eee 100644 --- a/bfd/elf.c +++ b/bfd/elf.c @@ -8394,7 +8394,7 @@ 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, *osec, *prev; unsigned int i, num_segments; Elf_Internal_Shdr *this_hdr; const struct elf_backend_data *bed; @@ -8425,7 +8425,7 @@ copy_private_bfd_data (bfd *ibfd, bfd *obfd) || segment->p_type == PT_DYNAMIC)) goto rewrite; - for (section = ibfd->sections; + for (section = ibfd->sections,prev=section; section != NULL; section = section->next) { /* We mark the output section so that we know it comes @@ -8440,16 +8440,21 @@ copy_private_bfd_data (bfd *ibfd, bfd *obfd) { /* FIXME: Check if its output section is changed or removed. What else do we need to check? */ + /* make sure this sections vma and lma relation is +same as previous section otherwise it needs a +rewrite */ if (osec == NULL || section->flags != osec->flags || section->lma != osec->lma || section->vma != osec->vma || section->size != osec->size || section->rawsize != osec->rawsize - || section->alignment_power != osec->alignment_power) + || section->alignment_power != osec->alignment_power + || section->lma - section->vma != prev->lma - prev->vma) goto rewrite; } } + prev = section; } /* Check to see if any output section do not come from the -- You are receiving this mail because: You are on the CC list for the bug.
[Bug binutils/31540] objcopy, ELF_SECTION_IN_SEGMENT_1 section to segment mapping seems wrong
https://sourceware.org/bugzilla/show_bug.cgi?id=31540 vijay Shankar changed: What|Removed |Added CC||nickc at sourceware dot org -- You are receiving this mail because: You are on the CC list for the bug.
[Bug binutils/31540] objcopy, ELF_SECTION_IN_SEGMENT_1 section to segment mapping seems wrong
https://sourceware.org/bugzilla/show_bug.cgi?id=31540 vijay Shankar changed: What|Removed |Added Version|unspecified |2.40 -- You are receiving this mail because: You are on the CC list for the bug.
[Bug binutils/31540] objcopy, ELF_SECTION_IN_SEGMENT_1 section to segment mapping seems wrong
https://sourceware.org/bugzilla/show_bug.cgi?id=31540 vijay Shankar changed: What|Removed |Added Priority|P2 |P3 CC||shank.vijay at yandex dot com -- You are receiving this mail because: You are on the CC list for the bug.