diff options
Diffstat (limited to 'libdwfl')
-rw-r--r-- | libdwfl/ChangeLog | 26 | ||||
-rw-r--r-- | libdwfl/argp-std.c | 2 | ||||
-rw-r--r-- | libdwfl/core-file.c | 14 | ||||
-rw-r--r-- | libdwfl/dwfl_build_id_find_elf.c | 4 | ||||
-rw-r--r-- | libdwfl/dwfl_module_getdwarf.c | 2 | ||||
-rw-r--r-- | libdwfl/dwfl_report_elf.c | 2 | ||||
-rw-r--r-- | libdwfl/dwfl_segment_report_module.c | 2 | ||||
-rw-r--r-- | libdwfl/find-debuginfo.c | 16 | ||||
-rw-r--r-- | libdwfl/gzip.c | 4 | ||||
-rw-r--r-- | libdwfl/image-header.c | 2 | ||||
-rw-r--r-- | libdwfl/libdwflP.h | 8 | ||||
-rw-r--r-- | libdwfl/link_map.c | 2 | ||||
-rw-r--r-- | libdwfl/linux-kernel-modules.c | 15 | ||||
-rw-r--r-- | libdwfl/linux-proc-maps.c | 12 | ||||
-rw-r--r-- | libdwfl/offline.c | 2 | ||||
-rw-r--r-- | libdwfl/open.c | 4 |
16 files changed, 75 insertions, 42 deletions
diff --git a/libdwfl/ChangeLog b/libdwfl/ChangeLog index 211f9ecd..5cae434e 100644 --- a/libdwfl/ChangeLog +++ b/libdwfl/ChangeLog @@ -1,3 +1,29 @@ +2015-10-09 Josh Stone <[email protected]> + + * core-file.c (elf_begin_rand): Replace loff_t with off_t. + * open.c (decompress): Replace off64_t with off_t. + * gzip.c (unzip): Likewise. + * image-header.c (__libdw_image_header): Likewise. + * libdwflP.h: Likewise in function declarations. + * argp-std.c (parse_opt): Replace open64 with open. + * dwfl_build_id_find_elf.c (__libdwfl_open_mod_by_build_id, + dwfl_build_id_find_elf): Likewise. + * dwfl_module_getdwarf.c (open_elf_file): Likewise. + * dwfl_report_elf.c (dwfl_report_elf): Likewise. + * dwfl_segment_report_module.c (dwfl_segment_report_module): Likewise. + * link_map.c (report_r_debug): Likewise. + * offline.c (dwfl_report_offline): Likewise. + * linux-proc-maps.c (grovel_auxv, get_pid_class, + dwfl_linux_proc_find_elf): Likewise. + (read_proc_memory): Replace off64_t with off_t. + * find-debuginfo.c (find_debuginfo_in_path): Replace stat64 and + fstat64 with stat and fstat. + (try_open): Likewise, and replace open64 with open. + * linux-kernel-modules.c: Manually define open and fopen to open64 and + fopen64 when needed, since the early fts.h include breaks that. + (try_kernel_name): Replace open64 with open. + (check_notes): Likewise. + 2015-10-09 Jose E. Marchesi <[email protected]> * linux-proc-maps.c (read_proc_memory): Use seek+read instead of diff --git a/libdwfl/argp-std.c b/libdwfl/argp-std.c index 42b7e783..2bbf74fc 100644 --- a/libdwfl/argp-std.c +++ b/libdwfl/argp-std.c @@ -273,7 +273,7 @@ parse_opt (int key, char *arg, struct argp_state *state) if (opt->core) { - int fd = open64 (opt->core, O_RDONLY); + int fd = open (opt->core, O_RDONLY); if (fd < 0) { int code = errno; diff --git a/libdwfl/core-file.c b/libdwfl/core-file.c index ea0725bf..b317ecaa 100644 --- a/libdwfl/core-file.c +++ b/libdwfl/core-file.c @@ -43,7 +43,7 @@ This implementation is pessimal for non-mmap cases and should be replaced by more diddling inside libelf internals. */ static Elf * -elf_begin_rand (Elf *parent, loff_t offset, loff_t size, loff_t *next) +elf_begin_rand (Elf *parent, off_t offset, off_t size, off_t *next) { if (parent == NULL) return NULL; @@ -58,14 +58,14 @@ elf_begin_rand (Elf *parent, loff_t offset, loff_t size, loff_t *next) return NULL; } - loff_t min = (parent->kind == ELF_K_ELF ? + off_t min = (parent->kind == ELF_K_ELF ? (parent->class == ELFCLASS32 ? sizeof (Elf32_Ehdr) : sizeof (Elf64_Ehdr)) : parent->kind == ELF_K_AR ? SARMAG : 0); if (unlikely (offset < min) - || unlikely (offset >= (loff_t) parent->maximum_size)) + || unlikely (offset >= (off_t) parent->maximum_size)) return fail (ELF_E_RANGE); /* For an archive, fetch just the size field @@ -92,11 +92,11 @@ elf_begin_rand (Elf *parent, loff_t offset, loff_t size, loff_t *next) char *endp; size = strtoll (h.ar_size, &endp, 10); if (unlikely (endp == h.ar_size) - || unlikely ((loff_t) parent->maximum_size - offset < size)) + || unlikely ((off_t) parent->maximum_size - offset < size)) return fail (ELF_E_INVALID_ARCHIVE); } - if (unlikely ((loff_t) parent->maximum_size - offset < size)) + if (unlikely ((off_t) parent->maximum_size - offset < size)) return fail (ELF_E_RANGE); /* Even if we fail at this point, update *NEXT to point past the file. */ @@ -104,7 +104,7 @@ elf_begin_rand (Elf *parent, loff_t offset, loff_t size, loff_t *next) *next = offset + size; if (unlikely (offset == 0) - && unlikely (size == (loff_t) parent->maximum_size)) + && unlikely (size == (off_t) parent->maximum_size)) return elf_clone (parent, parent->cmd); /* Note the image is guaranteed live only as long as PARENT @@ -114,7 +114,7 @@ elf_begin_rand (Elf *parent, loff_t offset, loff_t size, loff_t *next) Elf_Data *data = elf_getdata_rawchunk (parent, offset, size, ELF_T_BYTE); if (data == NULL) return NULL; - assert ((loff_t) data->d_size == size); + assert ((off_t) data->d_size == size); return elf_memory (data->d_buf, size); } diff --git a/libdwfl/dwfl_build_id_find_elf.c b/libdwfl/dwfl_build_id_find_elf.c index 99a5059c..2e30b7ab 100644 --- a/libdwfl/dwfl_build_id_find_elf.c +++ b/libdwfl/dwfl_build_id_find_elf.c @@ -89,7 +89,7 @@ __libdwfl_open_by_build_id (Dwfl_Module *mod, bool debug, char **file_name, break; memcpy (mempcpy (name, dir, dirlen), id_name, sizeof id_name); - fd = TEMP_FAILURE_RETRY (open64 (name, O_RDONLY)); + fd = TEMP_FAILURE_RETRY (open (name, O_RDONLY)); if (fd >= 0) { if (*file_name != NULL) @@ -146,7 +146,7 @@ dwfl_build_id_find_elf (Dwfl_Module *mod, name this callback will replace the Dwfl_Module main.name with the recorded executable file when MOD was identified as main executable (which then triggers opening and reporting of the executable). */ - int fd = open64 (mod->dwfl->executable_for_core, O_RDONLY); + int fd = open (mod->dwfl->executable_for_core, O_RDONLY); if (fd >= 0) { *file_name = strdup (mod->dwfl->executable_for_core); diff --git a/libdwfl/dwfl_module_getdwarf.c b/libdwfl/dwfl_module_getdwarf.c index a3590577..8483fa21 100644 --- a/libdwfl/dwfl_module_getdwarf.c +++ b/libdwfl/dwfl_module_getdwarf.c @@ -46,7 +46,7 @@ open_elf_file (Elf **elf, int *fd, char **name) /* If there was a pre-primed file name left that the callback left behind, try to open that file name. */ if (*fd < 0 && *name != NULL) - *fd = TEMP_FAILURE_RETRY (open64 (*name, O_RDONLY)); + *fd = TEMP_FAILURE_RETRY (open (*name, O_RDONLY)); if (*fd < 0) return CBFAIL; diff --git a/libdwfl/dwfl_report_elf.c b/libdwfl/dwfl_report_elf.c index 624284cf..1c6e401d 100644 --- a/libdwfl/dwfl_report_elf.c +++ b/libdwfl/dwfl_report_elf.c @@ -291,7 +291,7 @@ dwfl_report_elf (Dwfl *dwfl, const char *name, const char *file_name, int fd, if (fd < 0) { closefd = true; - fd = open64 (file_name, O_RDONLY); + fd = open (file_name, O_RDONLY); if (fd < 0) { __libdwfl_seterrno (DWFL_E_ERRNO); diff --git a/libdwfl/dwfl_segment_report_module.c b/libdwfl/dwfl_segment_report_module.c index ca86c311..40553c94 100644 --- a/libdwfl/dwfl_segment_report_module.c +++ b/libdwfl/dwfl_segment_report_module.c @@ -691,7 +691,7 @@ dwfl_segment_report_module (Dwfl *dwfl, int ndx, const char *name, name = file_note_name; name_is_final = true; bool invalid = false; - fd = open64 (name, O_RDONLY); + fd = open (name, O_RDONLY); if (fd >= 0) { Dwfl_Error error = __libdw_open_file (&fd, &elf, true, false); diff --git a/libdwfl/find-debuginfo.c b/libdwfl/find-debuginfo.c index 6b8d1ac4..72461bc3 100644 --- a/libdwfl/find-debuginfo.c +++ b/libdwfl/find-debuginfo.c @@ -34,10 +34,10 @@ #include "system.h" -/* Try to open64 [DIR/][SUBDIR/]DEBUGLINK, return file descriptor or -1. +/* Try to open [DIR/][SUBDIR/]DEBUGLINK, return file descriptor or -1. On success, *DEBUGINFO_FILE_NAME has the malloc'd name of the open file. */ static int -try_open (const struct stat64 *main_stat, +try_open (const struct stat *main_stat, const char *dir, const char *subdir, const char *debuglink, char **debuginfo_file_name) { @@ -53,11 +53,11 @@ try_open (const struct stat64 *main_stat, : asprintf (&fname, "%s/%s/%s", dir, subdir, debuglink)) < 0) return -1; - struct stat64 st; - int fd = TEMP_FAILURE_RETRY (open64 (fname, O_RDONLY)); + struct stat st; + int fd = TEMP_FAILURE_RETRY (open (fname, O_RDONLY)); if (fd < 0) free (fname); - else if (fstat64 (fd, &st) == 0 + else if (fstat (fd, &st) == 0 && st.st_ino == main_stat->st_ino && st.st_dev == main_stat->st_dev) { @@ -205,9 +205,9 @@ find_debuginfo_in_path (Dwfl_Module *mod, const char *file_name, } /* XXX dev/ino should be cached in struct dwfl_file. */ - struct stat64 main_stat; - if (unlikely ((mod->main.fd != -1 ? fstat64 (mod->main.fd, &main_stat) - : file_name != NULL ? stat64 (file_name, &main_stat) + struct stat main_stat; + if (unlikely ((mod->main.fd != -1 ? fstat (mod->main.fd, &main_stat) + : file_name != NULL ? stat (file_name, &main_stat) : -1) < 0)) { main_stat.st_dev = 0; diff --git a/libdwfl/gzip.c b/libdwfl/gzip.c index b7dde5d4..c81e52e3 100644 --- a/libdwfl/gzip.c +++ b/libdwfl/gzip.c @@ -75,7 +75,7 @@ is not null on entry, we'll use it in lieu of repeating a read. */ Dwfl_Error internal_function -unzip (int fd, off64_t start_offset, +unzip (int fd, off_t start_offset, void *mapped, size_t mapped_size, void **whole, size_t *whole_size) { @@ -231,7 +231,7 @@ unzip (int fd, off64_t start_offset, return DWFL_E_BADELF; if (start_offset != 0) { - off64_t off = lseek (d, start_offset, SEEK_SET); + off_t off = lseek (d, start_offset, SEEK_SET); if (off != start_offset) { close (d); diff --git a/libdwfl/image-header.c b/libdwfl/image-header.c index a4f6799a..62ccc3e3 100644 --- a/libdwfl/image-header.c +++ b/libdwfl/image-header.c @@ -57,7 +57,7 @@ Dwfl_Error internal_function -__libdw_image_header (int fd, off64_t *start_offset, +__libdw_image_header (int fd, off_t *start_offset, void *mapped, size_t mapped_size) { if (likely (mapped_size > H_END)) diff --git a/libdwfl/libdwflP.h b/libdwfl/libdwflP.h index 42a2669e..63556d51 100644 --- a/libdwfl/libdwflP.h +++ b/libdwfl/libdwflP.h @@ -588,21 +588,21 @@ extern GElf_Addr __libdwfl_segment_end (Dwfl *dwfl, GElf_Addr end) internal_function; /* Decompression wrappers: decompress whole file into memory. */ -extern Dwfl_Error __libdw_gunzip (int fd, off64_t start_offset, +extern Dwfl_Error __libdw_gunzip (int fd, off_t start_offset, void *mapped, size_t mapped_size, void **whole, size_t *whole_size) internal_function; -extern Dwfl_Error __libdw_bunzip2 (int fd, off64_t start_offset, +extern Dwfl_Error __libdw_bunzip2 (int fd, off_t start_offset, void *mapped, size_t mapped_size, void **whole, size_t *whole_size) internal_function; -extern Dwfl_Error __libdw_unlzma (int fd, off64_t start_offset, +extern Dwfl_Error __libdw_unlzma (int fd, off_t start_offset, void *mapped, size_t mapped_size, void **whole, size_t *whole_size) internal_function; /* Skip the image header before a file image: updates *START_OFFSET. */ -extern Dwfl_Error __libdw_image_header (int fd, off64_t *start_offset, +extern Dwfl_Error __libdw_image_header (int fd, off_t *start_offset, void *mapped, size_t mapped_size) internal_function; diff --git a/libdwfl/link_map.c b/libdwfl/link_map.c index 9f0b4a2c..13cac529 100644 --- a/libdwfl/link_map.c +++ b/libdwfl/link_map.c @@ -385,7 +385,7 @@ report_r_debug (uint_fast8_t elfclass, uint_fast8_t elfdata, { /* This code is mostly inlined dwfl_report_elf. */ // XXX hook for sysroot - int fd = open64 (name, O_RDONLY); + int fd = open (name, O_RDONLY); if (fd >= 0) { Elf *elf; 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]); diff --git a/libdwfl/linux-proc-maps.c b/libdwfl/linux-proc-maps.c index 2a65db2e..2e2c8f92 100644 --- a/libdwfl/linux-proc-maps.c +++ b/libdwfl/linux-proc-maps.c @@ -59,7 +59,7 @@ get_pid_class (pid_t pid) if (asprintf (&fname, PROCEXEFMT, pid) < 0) return ELFCLASSNONE; - int fd = open64 (fname, O_RDONLY); + int fd = open (fname, O_RDONLY); free (fname); if (fd < 0) return ELFCLASSNONE; @@ -95,7 +95,7 @@ grovel_auxv (pid_t pid, Dwfl *dwfl, GElf_Addr *sysinfo_ehdr) if (asprintf (&fname, PROCAUXVFMT, pid) < 0) return ENOMEM; - int fd = open64 (fname, O_RDONLY); + int fd = open (fname, O_RDONLY); free (fname); if (fd < 0) return errno == ENOENT ? 0 : errno; @@ -318,10 +318,10 @@ read_proc_memory (void *arg, void *data, GElf_Addr address, /* This code relies on the fact the Linux kernel accepts negative offsets when seeking /dev/$$/mem files, as a special case. In - particular pread[64] cannot be used here, because it will always + particular pread cannot be used here, because it will always return EINVAL when passed a negative offset. */ - if (lseek (fd, (off64_t) address, SEEK_SET) == -1) + if (lseek (fd, (off_t) address, SEEK_SET) == -1) return -1; ssize_t nread = read (fd, data, maxread); @@ -369,7 +369,7 @@ dwfl_linux_proc_find_elf (Dwfl_Module *mod __attribute__ ((unused)), if (pid == -1) { - int fd = open64 (module_name, O_RDONLY); + int fd = open (module_name, O_RDONLY); if (fd >= 0) { *file_name = strdup (module_name); @@ -406,7 +406,7 @@ dwfl_linux_proc_find_elf (Dwfl_Module *mod __attribute__ ((unused)), if (asprintf (&fname, PROCMEMFMT, pid) < 0) goto detach; - int fd = open64 (fname, O_RDONLY); + int fd = open (fname, O_RDONLY); free (fname); if (fd < 0) goto detach; diff --git a/libdwfl/offline.c b/libdwfl/offline.c index 982ceab0..c0a25992 100644 --- a/libdwfl/offline.c +++ b/libdwfl/offline.c @@ -298,7 +298,7 @@ dwfl_report_offline (Dwfl *dwfl, const char *name, if (fd < 0) { closefd = true; - fd = open64 (file_name, O_RDONLY); + fd = open (file_name, O_RDONLY); if (fd < 0) { __libdwfl_seterrno (DWFL_E_ERRNO); diff --git a/libdwfl/open.c b/libdwfl/open.c index 40aac388..c1d0ed2b 100644 --- a/libdwfl/open.c +++ b/libdwfl/open.c @@ -53,7 +53,7 @@ decompress (int fd __attribute__ ((unused)), Elf **elf) size_t size = 0; #if USE_ZLIB || USE_BZLIB || USE_LZMA - const off64_t offset = (*elf)->start_offset; + const off_t offset = (*elf)->start_offset; void *const mapped = ((*elf)->map_address == NULL ? NULL : (*elf)->map_address + offset); const size_t mapped_size = (*elf)->maximum_size; @@ -132,7 +132,7 @@ __libdw_open_file (int *fdp, Elf **elfp, bool close_on_fail, bool archive_ok) /* It's not an ELF file or a compressed file. See if it's an image with a header preceding the real file. */ - off64_t offset = elf->start_offset; + off_t offset = elf->start_offset; error = __libdw_image_header (*fdp, &offset, (elf->map_address == NULL ? NULL : elf->map_address + offset), |