strip looses original file ownership and file permissions

Ian Lance Taylor ian@zembu.com
Thu May 6 13:57:00 GMT 1999


   Date: Thu, 06 May 1999 20:42:53 +0200
   From: Franz Sirl <Franz.Sirl-kernel@lauterbach.com>

   Btw, have you ever looked at the patch in 
   http://sourceware.cygnus.com/ml/gas2/1999/msg00041.html ? Is it the correct 
   fix for the make check FAIL on powerpc-linux-gnu?

No, I don't think it is.  I think this is a problem in the glibc
dynamic linker.  (I looked at glibc 2.0.7; I don't know about other
versions.)

The GNU linker does not ordinarily create a PT_PHDR program segment
for a shared library.  This follows the lead of the Solaris linker.

When the glibc 2.0.7 dynamic linker does not find a PT_PHDR program
segment, it assumes that the program headers may be found at the start
of the first PT_LOAD segment.  However, ELF does not require this.
The comment in the glibc sources (in dl-load.c) says this:

	/* There was no PT_PHDR specified.  We need to find the phdr in the
           load image ourselves.  We assume it is in fact in the load image
           somewhere, and that the first load command starts at the
           beginning of the file and thus contains the ELF file header.  */

However, I believe the dynamic linker should be able to operate
without having the program headers in the load segment at all.

What your patch changes is whether the linker puts the program headers
at the start of the first PT_LOAD segment.  Without your patch, the
linker does not put the program headers in loadable memory.  With your
patch, it does.

Since with the current script the program headers are not loaded, the
dynamic linker will wind up looking at nonsensical memory for the
program headers, and it will fail.  However, the dynamic linker does
know how to find the correct program headers by reading the file.
However, after reading the program headers, it throws them away, and
uses the copy which it expects to find in the file.  If there is no
PT_PHDR segment, it should instead keep and use its own copy.

Ian


More information about the Gas2 mailing list