This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Re: PATCH: PR binutils/10802: objcopy an executable file compiled with PIE failed
On Mon, Oct 19, 2009 at 04:56:02PM -0700, H.J. Lu wrote:
> The question is if objcopy should preserve the permission bits.
Current behaviour is to not preserve them.
$ gcc -o hello /src/tmp/hello.c
$ chmod a-x hello
$ objcopy hello hello2
$ ls -l hello*
-rw-r--r-- 1 alan alan 6830 2009-10-20 11:12 hello
-rwxr-xr-x 1 alan alan 6830 2009-10-20 11:12 hello2
> Do we really mark all DSOs with the X bit?
Yes. ldmain.c:
if (link_info.relocatable)
link_info.output_bfd->flags &= ~EXEC_P;
else
link_info.output_bfd->flags |= EXEC_P;
Committed.
PR binutils/10802
* opncls.c (_maybe_make_executable): Make DYNAMIC files executable.
Index: bfd/opncls.c
===================================================================
RCS file: /cvs/src/src/bfd/opncls.c,v
retrieving revision 1.59
diff -u -p -r1.59 opncls.c
--- bfd/opncls.c 16 Oct 2009 07:14:43 -0000 1.59
+++ bfd/opncls.c 20 Oct 2009 00:46:38 -0000
@@ -635,7 +635,7 @@ _maybe_make_executable (bfd * abfd)
/* If the file was open for writing and is now executable,
make it so. */
if (abfd->direction == write_direction
- && abfd->flags & EXEC_P)
+ && (abfd->flags & (EXEC_P | DYNAMIC)) != 0)
{
struct stat buf;
--
Alan Modra
Australia Development Lab, IBM