public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
From: Alan Modra <amodra@gmail.com>
To: binutils@sourceware.org
Subject: PR25585, PHDR segment not covered by LOAD segment
Date: Sat, 22 Feb 2020 02:37:00 -0000	[thread overview]
Message-ID: <20200222023739.GB5570@bubble.grove.modra.org> (raw)

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.

diff --git a/bfd/elf.c b/bfd/elf.c
index 4342e84752..4a6d31a75e 100644
--- 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.
diff --git a/ld/NEWS b/ld/NEWS
index f659ccfc06..7734d23d5b 100644
--- 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.

-- 
Alan Modra
Australia Development Lab, IBM

                 reply	other threads:[~2020-02-22  2:37 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200222023739.GB5570@bubble.grove.modra.org \
    --to=amodra@gmail.com \
    --cc=binutils@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).