Nick Clifton 1a9ccd70f9 Fix the linker so that it will not silently generate ELF binaries with invalid program headers. Fix readelf to report such invalid binaries.
PR ld/20815
bfd	* elf.c (elf_modify_segment_map): Allow empty LOAD segments if
	they contain the program headers.
	(_bfd_elf_map_sections_to_segments): If the linker created the
	PHDR segment then always attempt to include it in a LOAD segment.
	(assign_file_positions_for_non_load_sections): Allow LOAD segments
	to overlap PHDR segments.
	(phdr_sorter): New function.  Sorts program headers.
	(assign_file_positions_except_relocs): Sort the program headers
	before writing them out.  Issue an error if the PHDR segment is
	not covered by a LOAD segment, unless the backend allows it.
	* elf-bfd.h (struct elf_backend_data): Add
	elf_backend_allow_non_load_phdr.
	* elfxx-target.h (elf_backend_allow_non_load_phdr): Provide
	default definition that returns FALSE.
	(elfNN_bed): Initialise the elf_backend_allow_non_load_phdr
	field.
	* elf64-hppa.c (elf64_hppa_allow_non_load_phdr): New function.
	Returns TRUE.
	(elf_backend_allow_non_load_phdr): Define.
	* elf-m10300.c (_bfd_mn10300_elf_size_dynamic_sections): Do not
	place the interpreter string into the .interp section if the
	nointerp flag is set in the link info structure.
	* elf32-arc.c (elf_arc_size_dynamic_sections): Likewise.
	* elf32-score7.c (score_elf_final_link_relocate): Allow for the
	_gp symbol not being part of the output.

binutils* readelf.c (process_program_headers): Check PT_LOAD and PT_PHDR
	segments for validity.

ld	* ld.texinfo: Note that PT_TLS can be used as a segment type.
	* testsuite/ld-discard/discard.ld: Add space for program headers.
	* testsuite/ld-elf/flags1.ld: Likewise.
	* testsuite/ld-elf/maxpage3.t: Likewise.
	* testsuite/ld-elf/noload-1.t: Likewise.
	* testsuite/ld-elf/orphan.ld: Likewise.
	* testsuite/ld-elf/overlay.t: Likewise.
	* testsuite/ld-elf/pr14052.t: Likewise.
	* testsuite/ld-elf/pr19539.t: Likewise.
	* testsuite/ld-elf/provide-hidden-1.ld: Likewise.
	* testsuite/ld-elf/provide-hidden-s.ld: Likewise.
	* testsuite/ld-elf/weak-dyn-1.ld: Likewise.
	* testsuite/ld-i386/pr19539.t: Likewise.
	* testsuite/ld-scripts/defined.t: Likewise.
	* testsuite/ld-scripts/defined6.t: Likewise.
	* testsuite/ld-scripts/dynamic-sections.t: Likewise.
	* testsuite/ld-scripts/empty-aligned.t: Likewise.
	* testsuite/ld-scripts/provide-2.t: Likewise.
	* testsuite/ld-scripts/provide-4.t: Likewise.
	* testsuite/ld-vax-elf/plt-local.ld: Likewise.
	* testsuite/ld-x86-64/pr19539.t: Likewise.
	* testsuite/ld-elf/ehdr_start-missing.d: Do not initialise the
	dynamic linker.
	* testsuite/ld-elf/ehdr_start-weak.d: Likewise.
	* testsuite/ld-elf/elf.exp (pr14170, pr17068): Likewise.
	* testsuite/ld-elf/loadaddr1.d: Update expected readelf output.
	* testsuite/ld-elf/noload-2.d: Likewise.
	* testsuite/ld-powerpc/vxworks2.sd: Likewise.
	* testsuite/ld-scripts/phdrs3a.d: Likewise.
	* testsuite/ld-scripts/size-2.d: Likewise.
	* testsuite/ld-elf/group.ld: Add program headers.
	* testsuite/ld-elf/overlay.d: Skip for SPU.
	* testsuite/ld-elf/flags1.d: Skip for RX.
	* testsuite/ld-elf/pr19162.d: Skip for HPPA64.
	* testsuite/ld-elf/pr19539.d: Skip for ALPHA.
	* testsuite/ld-scripts/empty-orphan.t: Update program headers.
	* testsuite/ld-scripts/size-2.t: Likewise.
2016-11-23 11:10:39 +00:00
..
2011-07-22 20:22:38 +00:00
2012-04-03 16:01:38 +00:00
2013-11-21 04:53:05 -08:00
2013-11-21 04:53:05 -08:00
2015-10-22 04:56:39 -07:00
2015-02-19 04:45:27 -08:00
2010-07-15 00:42:23 +00:00
2011-01-03 18:16:46 +00:00
2016-02-26 05:01:34 -08:00
2016-01-01 23:00:01 +10:30
2011-01-03 18:16:46 +00:00
2014-11-13 11:09:40 -08:00
2014-11-13 11:09:40 -08:00
2012-04-03 16:01:38 +00:00
2013-08-26 22:18:07 +00:00
2013-08-26 22:18:07 +00:00
2011-01-14 23:07:11 +00:00
2012-04-03 16:01:38 +00:00
2012-04-03 16:01:38 +00:00
2016-02-26 05:01:34 -08:00
2016-02-26 05:01:34 -08:00
2016-02-26 05:01:34 -08:00
2016-02-26 05:01:34 -08:00
2016-02-26 05:01:34 -08:00
2016-02-26 05:01:34 -08:00
2016-02-26 05:01:34 -08:00
2016-01-01 23:00:01 +10:30
2010-10-01 04:47:02 +00:00
2010-10-01 04:47:02 +00:00
2012-04-03 16:01:38 +00:00
2016-04-20 11:13:56 -07:00
2016-04-20 11:13:56 -07:00
2015-02-19 04:45:27 -08:00
2016-04-20 11:12:22 -07:00
2016-04-20 11:12:22 -07:00
2014-11-20 13:29:41 -08:00
2015-10-29 09:18:57 -07:00
2012-04-03 16:01:38 +00:00
2012-04-03 16:01:38 +00:00
2012-04-03 16:01:38 +00:00
2012-05-22 18:22:03 +00:00
2012-05-22 18:22:03 +00:00
2011-05-01 13:38:22 +00:00
2011-06-24 14:03:15 +00:00
2014-11-20 13:38:31 -08:00
2015-04-22 23:19:59 +09:30
2015-04-01 04:24:24 -07:00
2015-04-01 04:24:24 -07:00
2016-02-02 06:36:52 -08:00
2015-10-01 09:31:16 +09:30
2015-10-28 03:20:55 -07:00
2015-10-28 03:20:55 -07:00
2016-03-13 08:57:10 -07:00
2016-03-13 08:57:10 -07:00
2016-03-13 08:57:10 -07:00
2016-02-26 05:01:34 -08:00
2016-02-26 05:01:34 -08:00
2016-04-19 20:11:55 -07:00
2016-04-19 20:11:55 -07:00
2016-03-15 11:47:06 -07:00
2016-03-15 11:47:06 -07:00
2016-03-15 11:47:06 -07:00
2012-04-03 16:01:38 +00:00
2012-04-03 16:01:38 +00:00
2010-09-07 17:52:32 +00:00
2010-09-07 17:52:32 +00:00
2011-01-03 18:16:46 +00:00
2012-04-03 16:01:38 +00:00
2012-04-03 16:01:38 +00:00
2012-04-03 16:01:38 +00:00
2012-04-03 16:01:38 +00:00
2012-04-03 16:01:38 +00:00
2012-04-03 16:01:38 +00:00
2013-06-28 15:07:55 +00:00
2013-07-01 16:17:11 +00:00
2011-03-03 22:11:33 +00:00
2012-04-03 16:01:38 +00:00
2012-04-03 16:01:38 +00:00