summaryrefslogtreecommitdiffstats
path: root/libdwfl/linux-kernel-modules.c
diff options
context:
space:
mode:
authorUlf Hermann <[email protected]>2017-05-04 12:07:54 +0200
committerUlf Hermann <[email protected]>2017-05-08 09:36:02 +0000
commit0cfab8d6e47c165ee02d027c11b9a11c726516fa (patch)
tree07868d226de62c4f9fd80ddb7882fe19151445b0 /libdwfl/linux-kernel-modules.c
parent8ac52d75d47da355c4ace3224161de097db3e8d9 (diff)
Open files in O_BINARY
If O_BINARY is not defined, define it to 0, so that the change has no effect then. Some systems have separate binary and text modes for files, and we don't want the text mode to be used. Change-Id: If7efb5bd448c2a1c7d1eb5dab276849b1b15a3ce Reviewed-by: Christian Kandeler <[email protected]>
Diffstat (limited to 'libdwfl/linux-kernel-modules.c')
-rw-r--r--libdwfl/linux-kernel-modules.c20
1 files changed, 10 insertions, 10 deletions
diff --git a/libdwfl/linux-kernel-modules.c b/libdwfl/linux-kernel-modules.c
index 5f132b46..139a4774 100644
--- a/libdwfl/linux-kernel-modules.c
+++ b/libdwfl/linux-kernel-modules.c
@@ -97,7 +97,7 @@ try_kernel_name (Dwfl *dwfl, char **fname, bool try_debug)
int fd = ((((dwfl->callbacks->debuginfo_path
? *dwfl->callbacks->debuginfo_path : NULL)
?: DEFAULT_DEBUGINFO_PATH)[0] == ':') ? -1
- : TEMP_FAILURE_RETRY (open (*fname, O_RDONLY)));
+ : TEMP_FAILURE_RETRY (open (*fname, O_RDONLY | O_BINARY)));
if (fd < 0)
{
@@ -132,7 +132,7 @@ try_kernel_name (Dwfl *dwfl, char **fname, bool try_debug)
char *zname;
if (asprintf (&zname, "%s%s", *fname, vmlinux_suffixes[i]) > 0)
{
- fd = TEMP_FAILURE_RETRY (open (zname, O_RDONLY));
+ fd = TEMP_FAILURE_RETRY (open (zname, O_RDONLY | O_BINARY));
if (fd < 0)
free (zname);
else
@@ -488,7 +488,7 @@ intuit_kernel_bounds (Dwarf_Addr *start, Dwarf_Addr *end, Dwarf_Addr *notes)
{
struct read_address_state state = { NULL, NULL, 0, 0, NULL, NULL };
- state.f = fopen (KSYMSFILE, "r");
+ state.f = fopen (KSYMSFILE, "rb");
if (state.f == NULL)
return errno;
@@ -531,7 +531,7 @@ static int
check_notes (Dwfl_Module *mod, const char *notesfile,
Dwarf_Addr vaddr, const char *secname)
{
- int fd = open (notesfile, O_RDONLY);
+ int fd = open (notesfile, O_RDONLY | O_BINARY);
if (fd < 0)
return 1;
@@ -789,7 +789,7 @@ dwfl_linux_kernel_find_elf (Dwfl_Module *mod,
&& (!memcmp (f->fts_name, module_name, namelen)
|| !memcmp (f->fts_name, alternate_name, namelen)))
{
- int fd = open (f->fts_accpath, O_RDONLY);
+ int fd = open (f->fts_accpath, O_RDONLY | O_BINARY);
*file_name = strdup (f->fts_path);
fts_close (fts);
free (modulesdir[0]);
@@ -842,7 +842,7 @@ dwfl_linux_kernel_module_section_address
if (asprintf (&sysfile, SECADDRDIRFMT "%s", modname, secname) < 0)
return DWARF_CB_ABORT;
- FILE *f = fopen (sysfile, "r");
+ FILE *f = fopen (sysfile, "rb");
free (sysfile);
if (f == NULL)
@@ -876,7 +876,7 @@ dwfl_linux_kernel_module_section_address
if (asprintf (&sysfile, SECADDRDIRFMT "_%s",
modname, &secname[1]) < 0)
return ENOMEM;
- f = fopen (sysfile, "r");
+ f = fopen (sysfile, "rb");
free (sysfile);
if (f != NULL)
goto ok;
@@ -896,11 +896,11 @@ dwfl_linux_kernel_module_section_address
do
{
*--end = '\0';
- f = fopen (sysfile, "r");
+ f = fopen (sysfile, "rb");
if (is_init && f == NULL && errno == ENOENT)
{
sysfile[len - namelen] = '_';
- f = fopen (sysfile, "r");
+ f = fopen (sysfile, "rb");
sysfile[len - namelen] = '.';
}
}
@@ -934,7 +934,7 @@ INTDEF (dwfl_linux_kernel_module_section_address)
int
dwfl_linux_kernel_report_modules (Dwfl *dwfl)
{
- FILE *f = fopen (MODULELIST, "r");
+ FILE *f = fopen (MODULELIST, "rb");
if (f == NULL)
return errno;