No PT_INTERP when .interp is zero size
authorAlan Modra <amodra@gmail.com>
Fri, 5 Oct 2018 14:35:51 +0000 (00:05 +0930)
committerAlan Modra <amodra@gmail.com>
Mon, 8 Oct 2018 09:56:08 +0000 (20:26 +1030)
Some targets don't set a default interpreter, resulting in an empty
.interp section unless --dynamic-linker is passed to ld.  A PT_INTERP
without a path is rather useless.

The testsuite change fixes a failure on microblaze-linux.

bfd/
* elf.c (get_program_header_size): Don't count PT_INTERP if
.interp is empty.
(_bfd_elf_map_sections_to_segments): Don't create PT_INTERP if
.interp is empty.
ld/
* testsuite/ld-elf/pr22423.d: Pass --dynamic-linker to ld.

bfd/ChangeLog
bfd/elf.c
ld/ChangeLog
ld/testsuite/ld-elf/pr22423.d

index 1b51db7e7eb4e4a8329a9c786cb9f25babc40f8a..3d6796b09497578010af1aaf7d650197a7944b55 100644 (file)
@@ -1,3 +1,10 @@
+2018-10-08  Alan Modra  <amodra@gmail.com>
+
+       * elf.c (get_program_header_size): Don't count PT_INTERP if
+       .interp is empty.
+       (_bfd_elf_map_sections_to_segments): Don't create PT_INTERP if
+       .interp is empty.
+
 2018-10-08  Alan Modra  <amodra@gmail.com>
 
        * elf32-spu.c (spu_elf_modify_segment_map): Don't insert
index b3ce110893b351c8b4daabaf84dbac1780569bf8..fe43c9ffe726328b85ab9e87434260b8ecf2127d 100644 (file)
--- a/bfd/elf.c
+++ b/bfd/elf.c
@@ -4335,7 +4335,7 @@ get_program_header_size (bfd *abfd, struct bfd_link_info *info)
   segs = 2;
 
   s = bfd_get_section_by_name (abfd, ".interp");
-  if (s != NULL && (s->flags & SEC_LOAD) != 0)
+  if (s != NULL && (s->flags & SEC_LOAD) != 0 && s->size != 0)
     {
       /* If we have a loadable interpreter section, we need a
         PT_INTERP segment.  In this case, assume we also need a
@@ -4647,7 +4647,7 @@ _bfd_elf_map_sections_to_segments (bfd *abfd, struct bfd_link_info *info)
         the program headers and a PT_INTERP segment for the .interp
         section.  */
       s = bfd_get_section_by_name (abfd, ".interp");
-      if (s != NULL && (s->flags & SEC_LOAD) != 0)
+      if (s != NULL && (s->flags & SEC_LOAD) != 0 && s->size != 0)
        {
          amt = sizeof (struct elf_segment_map);
          m = (struct elf_segment_map *) bfd_zalloc (abfd, amt);
index b0c9eaa3c5526c544e622bb8f157bf16b8134b5f..7356c2b81062c9b0b5fe5e9d01a5d850344b9061 100644 (file)
@@ -1,3 +1,7 @@
+2018-10-08  Alan Modra  <amodra@gmail.com>
+
+       * testsuite/ld-elf/pr22423.d: Pass --dynamic-linker to ld.
+
 2018-10-05  Richard Henderson  <rth@twiddle.net>
 
        * testsuite/ld-or1k/or1k.exp: Add test cases for plt generation.
index 70bd59e399dc806b5b8a6e0f5f102ddfc64e5bc0..9255c7e77bc77577f17bc9f64172dd083a2473a0 100644 (file)
@@ -1,6 +1,6 @@
 #source: start.s
 #readelf: -l -W
-#ld: -pie
+#ld: -pie --dynamic-linker=/usr/lib/ld.so.1
 #target: *-*-linux* *-*-gnu* arm*-*-uclinuxfdpiceabi
 
 #...
This page took 0.034842 seconds and 4 git commands to generate.