This is the mail archive of the binutils@sourceware.org mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

PT_PHDR stripping issue


Hi,

A while ago we had a problem with the strip utility generating invalid
executables. 

We define the program headers in our linker script, including a PT_PHDR
program header containing FILEHDR and PHDRS.

We also specify another program header which ends up having a virtual
address of 0.

If I remember correctly, strip was trying to work out which program
headers our sections belonged to and incorrectly attributed one of them
to the PT_PHDR program header. This was causing it to generate an
invalid ELF.

The following patch fixes this. I've tested it on i686-pc-linux-gnu. Is
this the correct thing to do?

Thanks,
Dave

include/elf/ChangeLog

2010-04-07  David Stubbs  <stubbs@icerasemi.com>

	* internal.h (ELF_IS_SECTION_IN_SEGMENT): PT_PHDR program
headers cannot contain
	any sections.


Index: include/elf/internal.h
===================================================================
RCS file: /cvs/src/src/include/elf/internal.h,v
retrieving revision 1.22
diff -u -p -r1.22 internal.h
--- include/elf/internal.h	14 Nov 2008 14:44:09 -0000	1.22
+++ include/elf/internal.h	7 Apr 2010 14:55:48 -0000
@@ -307,6 +307,8 @@ struct elf_segment_map
 	 || segment->p_type == PT_LOAD))
\
     || ((sec_hdr->sh_flags & SHF_TLS) == 0
\
 	&& segment->p_type != PT_TLS))
\
+  /* PT_PHDR segments cannot contain any sections. */
\
+  && (segment->p_type != PT_PHDR)
\
    /* Any section besides one of type SHT_NOBITS must have a file
\
       offset within the segment.  */
\
    && (sec_hdr->sh_type == SHT_NOBITS
\


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]