bug-binutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Bug binutils/23595] "simple objcopy of executable" failure for msp430-e


From: jozef.l at mittosystems dot com
Subject: [Bug binutils/23595] "simple objcopy of executable" failure for msp430-elf with -mlarge
Date: Thu, 30 Aug 2018 13:23:52 +0000

https://sourceware.org/bugzilla/show_bug.cgi?id=23595

--- Comment #1 from Jozef Lawrynowicz <jozef.l at mittosystems dot com> ---
Proposed patch, lightly tested without regressions in the binutils, gas, ld
testsuites for msp430-elf/-mlarge and x86_64-pc-linux-gnu.

diff --git a/bfd/elf.c b/bfd/elf.c
index b8860c4..14612bd 100644
--- a/bfd/elf.c
+++ b/bfd/elf.c
@@ -7235,6 +7235,7 @@ copy_elf_program_header (bfd *ibfd, bfd *obfd)
       Elf_Internal_Shdr *this_hdr;
       asection *first_section = NULL;
       asection *lowest_section;
+      bfd_boolean no_contents = TRUE;

       /* Compute how many sections are in this segment.  */
       for (section = ibfd->sections, section_count = 0;
@@ -7246,6 +7247,8 @@ copy_elf_program_header (bfd *ibfd, bfd *obfd)
            {
              if (first_section == NULL)
                first_section = section;
+             if (elf_section_type (section) != SHT_NOBITS)
+               no_contents = FALSE;
              section_count++;
            }
        }
@@ -7342,8 +7345,15 @@ copy_elf_program_header (bfd *ibfd, bfd *obfd)
        }

       if (map->includes_filehdr && lowest_section != NULL)
-       /* We need to keep the space used by the headers fixed.  */
-       map->header_size = lowest_section->vma - segment->p_vaddr;
+       {
+         /* We need to keep the space used by the headers fixed.
+            If no_contents is true, get a more accurate value for header_size
+            by checking the p_filesz of the segment.  */
+         if (no_contents)
+           map->header_size = segment->p_filesz;
+         else
+           map->header_size = lowest_section->vma - segment->p_vaddr;
+       }

       if (!map->includes_phdrs
          && !map->includes_filehdr

-- 
You are receiving this mail because:
You are on the CC list for the bug.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]