No PT_INTERP when .interp is zero size

Michael Eager eager@eagerm.com
Mon Oct 8 15:49:00 GMT 2018


On 10/08/2018 03:00 AM, Alan Modra wrote:
> 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.
> 
> diff --git a/bfd/elf.c b/bfd/elf.c
> index b3ce110893..fe43c9ffe7 100644
> --- 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);
> diff --git a/ld/testsuite/ld-elf/pr22423.d b/ld/testsuite/ld-elf/pr22423.d
> index 70bd59e399..9255c7e77b 100644
> --- a/ld/testsuite/ld-elf/pr22423.d
> +++ b/ld/testsuite/ld-elf/pr22423.d
> @@ -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
>   
>   #...


OK.

-- 
Michael Eager    eager@eagerm.com
1960 Park Blvd., Palo Alto, CA 94306



More information about the Binutils mailing list