summaryrefslogtreecommitdiffstats
path: root/src/strip.c
diff options
context:
space:
mode:
authorRoland McGrath <[email protected]>2005-08-08 03:49:35 +0000
committerRoland McGrath <[email protected]>2005-08-08 03:49:35 +0000
commit095a01b14c2562a33615f079f300ac86da95bc56 (patch)
tree84933deb60852d24a4fa6a8308d26c402f36da1b /src/strip.c
parent5678f87b4ad2557c653e3780221b539379311308 (diff)
2005-08-07 Roland McGrath <[email protected]>
* strip.c (process_file): Open read-only when using a different output file.
Diffstat (limited to 'src/strip.c')
-rw-r--r--src/strip.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/src/strip.c b/src/strip.c
index 214513c4..2de5d6b8 100644
--- a/src/strip.c
+++ b/src/strip.c
@@ -274,7 +274,7 @@ process_file (const char *fname)
}
/* Open the file. */
- int fd = open (fname, O_RDWR);
+ int fd = open (fname, output_fname == NULL ? O_RDWR : O_RDONLY);
if (fd == -1)
{
error (0, errno, gettext ("while opening \"%s\""), fname);
@@ -300,7 +300,8 @@ process_file (const char *fname)
}
/* Now get the ELF descriptor. */
- Elf *elf = elf_begin (fd, ELF_C_RDWR, NULL);
+ Elf *elf = elf_begin (fd, output_fname == NULL ? ELF_C_RDWR : ELF_C_READ,
+ NULL);
int result;
switch (elf_kind (elf))
{