PR25585, PHDR segment not covered by LOAD segment
authorAlan Modra <amodra@gmail.com>
Sat, 22 Feb 2020 02:16:33 +0000 (12:46 +1030)
committerAlan Modra <amodra@gmail.com>
Sat, 22 Feb 2020 02:23:52 +0000 (12:53 +1030)
I closed this bug as invalid, but I think it is worth mentioning in NEWS
that older linkers didn't check PT_PHDR very well.  The patch also allows
people to force an output file with --noinhibit-exec after the error.

bfd/
PR 25585
* elf.c (assign_file_positions_for_load_sections): Continue linking
on "PHDR segment not covered by LOAD segment" errors.
ld/
PR 25585
* NEWS: Mention better "PHDR segment not covered by LOAD segment"
checking.

bfd/ChangeLog
bfd/elf.c
ld/ChangeLog
ld/NEWS

index 4ee96e4abc3d4b6bfba9a566e9f5b4d96052b302..31e7c6986ccae3916516ea36b63ee9f6a7d5841e 100644 (file)
@@ -1,3 +1,9 @@
+2020-02-22  Alan Modra  <amodra@gmail.com>
+
+       PR 25585
+       * elf.c (assign_file_positions_for_load_sections): Continue linking
+       on "PHDR segment not covered by LOAD segment" errors.
+
 2020-02-21  Alan Modra  <amodra@gmail.com>
 
        * mach-o.c (bfd_mach_o_canonicalize_relocs): Fix ineffective
index 4342e847527e288791a13aaaf1d23a78166baea8..4a6d31a75e4e4ae7cff4acdae99803c759a064ff 100644 (file)
--- a/bfd/elf.c
+++ b/bfd/elf.c
@@ -5926,7 +5926,11 @@ assign_file_positions_for_load_sections (bfd *abfd,
          _bfd_error_handler (_("%pB: error: PHDR segment not covered"
                                " by LOAD segment"),
                              abfd);
-         return FALSE;
+         if (link_info == NULL)
+           return FALSE;
+         /* Arrange for the linker to exit with an error, deleting
+            the output file unless --noinhibit-exec is given.  */
+         link_info->callbacks->info ("%X");
        }
 
       /* Check that all sections are in a PT_LOAD segment.
index 29348f186b9d65f91179ff26608afa3549c51848..dab3590b2b6ff7d7fc6b288ec9e5beb472326cc9 100644 (file)
@@ -1,3 +1,9 @@
+2020-02-22  Alan Modra  <amodra@gmail.com>
+
+       PR 25585
+       * NEWS: Mention better "PHDR segment not covered by LOAD segment"
+       checking.
+
 2020-02-19  Sergey Belyashov  <sergey.belyashov@gmail.com>
 
        PR 25537
diff --git a/ld/NEWS b/ld/NEWS
index f659ccfc06b72420f7fbc15cad18c63ff54381a0..7734d23d5bb5034330de566c05e4059724540387 100644 (file)
--- a/ld/NEWS
+++ b/ld/NEWS
@@ -2,6 +2,12 @@
 
 Changes in 2.34:
 
+* The ld check for "PHDR segment not covered by LOAD segment" is more
+  effective, catching cases that were wrongly allowed by previous versions of
+  ld.  If you see this error it is likely you are linking with a bad linker
+  script or the binary you are building is not intended to be loaded by a
+  dynamic loader.  In the latter case --no-dynamic-linker is appropriate.
+
 * cr16c support removed.
 
 * Add support for z80-elf.
This page took 0.030919 seconds and 4 git commands to generate.