diff options
| author | Josh Stone <[email protected]> | 2015-10-09 10:10:37 -0700 |
|---|---|---|
| committer | Josh Stone <[email protected]> | 2015-10-09 10:10:37 -0700 |
| commit | 3425454a10d307fae891fb667cf7969e945cde79 (patch) | |
| tree | ba30fbaff59ca353f4dad8759770600853fb00c1 /libdwfl/linux-kernel-modules.c | |
| parent | f17d101232d6d40e192e61441aa02a12ee8cf9b8 (diff) | |
Trust AC_SYS_LARGEFILE to provide large file support
AC_SYS_LARGEFILE defines _FILE_OFFSET_BITS in config.h if needed for
LFS, and this automatically maps things like open to open64. But quite
a few places used explicit 64-bit names, which won't work on platforms
like FreeBSD where off_t is always 64-bit and there are no foo64 names.
It's better to just trust that AC_SYS_LARGEFILE is doing it correctly.
But we can verify this too, as some file could easily forget to include
config.h. The new tests/run-lfs-symbols.sh checks all build targets
against lfs-symbols (taken from lintian) to make sure everything was
implicitly mapped to 64-bit variants when _FILE_OFFSET_BITS is set.
Signed-off-by: Josh Stone <[email protected]>
Diffstat (limited to 'libdwfl/linux-kernel-modules.c')
| -rw-r--r-- | libdwfl/linux-kernel-modules.c | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/libdwfl/linux-kernel-modules.c b/libdwfl/linux-kernel-modules.c index dafe893c..38b5170a 100644 --- a/libdwfl/linux-kernel-modules.c +++ b/libdwfl/linux-kernel-modules.c @@ -44,6 +44,13 @@ #include <fcntl.h> #include <unistd.h> +/* Since fts.h is included before config.h, its indirect inclusions may not + give us the right LFS aliases of these functions, so map them manually. */ +#ifdef _FILE_OFFSET_BITS +#define open open64 +#define fopen fopen64 +#endif + #define KERNEL_MODNAME "kernel" @@ -84,7 +91,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 (open64 (*fname, O_RDONLY))); + : TEMP_FAILURE_RETRY (open (*fname, O_RDONLY))); if (fd < 0) { @@ -116,7 +123,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 (open64 (zname, O_RDONLY)); + fd = TEMP_FAILURE_RETRY (open (zname, O_RDONLY)); if (fd < 0) free (zname); else @@ -514,7 +521,7 @@ static int check_notes (Dwfl_Module *mod, const char *notesfile, Dwarf_Addr vaddr, const char *secname) { - int fd = open64 (notesfile, O_RDONLY); + int fd = open (notesfile, O_RDONLY); if (fd < 0) return 1; @@ -772,7 +779,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 = open64 (f->fts_accpath, O_RDONLY); + int fd = open (f->fts_accpath, O_RDONLY); *file_name = strdup (f->fts_path); fts_close (fts); free (modulesdir[0]); |
