summaryrefslogtreecommitdiffstats
path: root/libdwfl/linux-proc-maps.c
diff options
context:
space:
mode:
Diffstat (limited to 'libdwfl/linux-proc-maps.c')
-rw-r--r--libdwfl/linux-proc-maps.c14
1 files changed, 7 insertions, 7 deletions
diff --git a/libdwfl/linux-proc-maps.c b/libdwfl/linux-proc-maps.c
index c4438c0f..8eb9a5cb 100644
--- a/libdwfl/linux-proc-maps.c
+++ b/libdwfl/linux-proc-maps.c
@@ -63,7 +63,7 @@ get_pid_class (pid_t pid)
if (asprintf (&fname, PROCEXEFMT, pid) < 0)
return ELFCLASSNONE;
- int fd = open (fname, O_RDONLY);
+ int fd = open (fname, O_RDONLY | O_BINARY);
free (fname);
if (fd < 0)
return ELFCLASSNONE;
@@ -99,7 +99,7 @@ grovel_auxv (pid_t pid, Dwfl *dwfl, GElf_Addr *sysinfo_ehdr)
if (asprintf (&fname, PROCAUXVFMT, pid) < 0)
return ENOMEM;
- int fd = open (fname, O_RDONLY);
+ int fd = open (fname, O_RDONLY | O_BINARY);
free (fname);
if (fd < 0)
return errno == ENOENT ? 0 : errno;
@@ -245,7 +245,7 @@ proc_maps_report (Dwfl *dwfl, FILE *f, GElf_Addr sysinfo_ehdr, pid_t pid)
}
char *file = line + nread + strspn (line + nread, " \t");
- if (file[0] != '/' || (ino == 0 && dmajor == 0 && dminor == 0))
+ if (!IS_ABSOLUTE_PATH(file) || (ino == 0 && dmajor == 0 && dminor == 0))
/* This line doesn't indicate a file mapping. */
continue;
@@ -306,7 +306,7 @@ dwfl_linux_proc_report (Dwfl *dwfl, pid_t pid)
if (asprintf (&fname, PROCMAPSFMT, pid) < 0)
return ENOMEM;
- FILE *f = fopen (fname, "r");
+ FILE *f = fopen (fname, "rb");
free (fname);
if (f == NULL)
return errno;
@@ -362,7 +362,7 @@ dwfl_linux_proc_find_elf (Dwfl_Module *mod __attribute__ ((unused)),
char **file_name, Elf **elfp)
{
int pid = -1;
- if (module_name[0] == '/')
+ if (IS_ABSOLUTE_PATH (module_name))
{
/* When this callback is used together with dwfl_linux_proc_report
then we might see mappings of special character devices. Make
@@ -380,7 +380,7 @@ dwfl_linux_proc_find_elf (Dwfl_Module *mod __attribute__ ((unused)),
if (pid == -1)
{
- int fd = open (module_name, O_RDONLY);
+ int fd = open (module_name, O_RDONLY | O_BINARY);
if (fd >= 0)
{
*file_name = strdup (module_name);
@@ -417,7 +417,7 @@ dwfl_linux_proc_find_elf (Dwfl_Module *mod __attribute__ ((unused)),
if (asprintf (&fname, PROCMEMFMT, pid) < 0)
goto detach;
- int fd = open (fname, O_RDONLY);
+ int fd = open (fname, O_RDONLY | O_BINARY);
free (fname);
if (fd < 0)
goto detach;