summaryrefslogtreecommitdiffstats
path: root/src/elfcompress.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/elfcompress.c')
-rw-r--r--src/elfcompress.c15
1 files changed, 11 insertions, 4 deletions
diff --git a/src/elfcompress.c b/src/elfcompress.c
index 8e0d5c55..d1cef85b 100644
--- a/src/elfcompress.c
+++ b/src/elfcompress.c
@@ -135,7 +135,10 @@ parse_opt (int key, char *arg __attribute__ ((unused)),
if (type == T_UNSET)
type = T_COMPRESS_ZLIB;
if (patterns == NULL)
- add_pattern (".?(z)debug*");
+ {
+ add_pattern (".debug*");
+ add_pattern (".zdebug*");
+ }
break;
case ARGP_KEY_NO_ARGS:
@@ -321,7 +324,7 @@ process_file (const char *fname)
return res;
}
- fd = open (fname, O_RDONLY);
+ fd = open (fname, O_RDONLY | O_BINARY);
if (fd < 0)
{
error (0, errno, "Couldn't open %s\n", fname);
@@ -542,7 +545,7 @@ process_file (const char *fname)
else
{
fnew = xstrdup (foutput);
- fdnew = open (fnew, O_WRONLY | O_CREAT, st.st_mode & ALLPERMS);
+ fdnew = open (fnew, O_WRONLY | O_BINARY | O_CREAT, st.st_mode & 07777);
}
if (fdnew < 0)
@@ -1235,13 +1238,17 @@ process_file (const char *fname)
elf_end (elfnew);
elfnew = NULL;
+#if HAVE_DECL_FCHMOD
/* Try to match mode and owner.group of the original file. */
- if (fchmod (fdnew, st.st_mode & ALLPERMS) != 0)
+ if (fchmod (fdnew, st.st_mode & 07777) != 0)
if (verbose >= 0)
error (0, errno, "Couldn't fchmod %s", fnew);
+#endif
+#if HAVE_DECL_FCHOWN
if (fchown (fdnew, st.st_uid, st.st_gid) != 0)
if (verbose >= 0)
error (0, errno, "Couldn't fchown %s", fnew);
+#endif
/* Finally replace the old file with the new file. */
if (foutput == NULL)