diff options
author | Josh Stone <jistone@redhat.com> | 2015-10-09 10:10:37 -0700 |
---|---|---|
committer | Josh Stone <jistone@redhat.com> | 2015-10-09 10:10:37 -0700 |
commit | 3425454a10d307fae891fb667cf7969e945cde79 (patch) | |
tree | ba30fbaff59ca353f4dad8759770600853fb00c1 | |
parent | f17d101232d6d40e192e61441aa02a12ee8cf9b8 (diff) | |
download | android_external_elfutils-3425454a10d307fae891fb667cf7969e945cde79.tar.gz android_external_elfutils-3425454a10d307fae891fb667cf7969e945cde79.tar.bz2 android_external_elfutils-3425454a10d307fae891fb667cf7969e945cde79.zip |
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 <jistone@redhat.com>
43 files changed, 369 insertions, 105 deletions
diff --git a/config/ChangeLog b/config/ChangeLog index ba5cb387..41678214 100644 --- a/config/ChangeLog +++ b/config/ChangeLog @@ -1,3 +1,7 @@ +2015-10-09 Josh Stone <jistone@redhat.com> + + * eu.am (print-%): New target to print any variable. + 2015-10-05 Josh Stone <jistone@redhat.com> * eu.am (%.os): Add AM_V_CC silencers. diff --git a/config/eu.am b/config/eu.am index 6ad8f822..1e332efa 100644 --- a/config/eu.am +++ b/config/eu.am @@ -74,3 +74,6 @@ else textrel_found = $(textrel_msg) endif textrel_check = if $(READELF) -d $@ | fgrep -q TEXTREL; then $(textrel_found); fi + +print-%: + @echo $*=$($*) diff --git a/libdw/ChangeLog b/libdw/ChangeLog index efe6ccb8..39c49aa4 100644 --- a/libdw/ChangeLog +++ b/libdw/ChangeLog @@ -1,3 +1,8 @@ +2015-10-09 Josh Stone <jistone@redhat.com> + + * dwarf_begin.c (dwarf_begin): Replace stat64 and fstat64 with stat + and fstat. + 2015-10-05 Josh Stone <jistone@redhat.com> * Makefile.am (libdw.so): Add AM_V_CCLD and AM_V_at silencers. diff --git a/libdw/dwarf_begin.c b/libdw/dwarf_begin.c index d04e5b9f..19d16e5c 100644 --- a/libdw/dwarf_begin.c +++ b/libdw/dwarf_begin.c @@ -73,9 +73,9 @@ dwarf_begin (int fd, Dwarf_Cmd cmd) if (elf == NULL) { /* Test why the `elf_begin" call failed. */ - struct stat64 st; + struct stat st; - if (fstat64 (fd, &st) == 0 && ! S_ISREG (st.st_mode)) + if (fstat (fd, &st) == 0 && ! S_ISREG (st.st_mode)) __libdw_seterrno (DWARF_E_NO_REGFILE); else if (errno == EBADF) __libdw_seterrno (DWARF_E_INVALID_FILE); 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 <jistone@redhat.com> + + * 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 <jose.marchesi@oracle.com> * 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), diff --git a/libelf/ChangeLog b/libelf/ChangeLog index 0b9ddf2b..b1d1ecdf 100644 --- a/libelf/ChangeLog +++ b/libelf/ChangeLog @@ -1,3 +1,8 @@ +2015-10-09 Josh Stone <jistone@redhat.com> + + * libelfP.h (struct Elf): Replace off64_t with off_t. + * elf_getdata_rawchunk.c (elf_getdata_rawchunk): Likewise. + 2015-10-05 Chih-Hung Hsieh <chh@google.com> * elf_getarsym.c (elf_getarsym): Do not use diff --git a/libelf/elf_getdata_rawchunk.c b/libelf/elf_getdata_rawchunk.c index 51b3e3e7..31b2fe7d 100644 --- a/libelf/elf_getdata_rawchunk.c +++ b/libelf/elf_getdata_rawchunk.c @@ -41,7 +41,7 @@ #include "common.h" Elf_Data * -elf_getdata_rawchunk (Elf *elf, off64_t offset, size_t size, Elf_Type type) +elf_getdata_rawchunk (Elf *elf, off_t offset, size_t size, Elf_Type type) { if (unlikely (elf == NULL)) return NULL; diff --git a/libelf/libelfP.h b/libelf/libelfP.h index 3f4d654b..993c6556 100644 --- a/libelf/libelfP.h +++ b/libelf/libelfP.h @@ -316,7 +316,7 @@ struct Elf int ehdr_flags; /* Flags (dirty) for ELF header. */ int phdr_flags; /* Flags (dirty|malloc) for program header. */ int shdr_malloced; /* Nonzero if shdr array was allocated. */ - off64_t sizestr_offset; /* Offset of the size string in the parent + off_t sizestr_offset; /* Offset of the size string in the parent if this is an archive member. */ } elf; @@ -335,7 +335,7 @@ struct Elf int ehdr_flags; /* Flags (dirty) for ELF header. */ int phdr_flags; /* Flags (dirty|malloc) for program header. */ int shdr_malloced; /* Nonzero if shdr array was allocated. */ - off64_t sizestr_offset; /* Offset of the size string in the parent + off_t sizestr_offset; /* Offset of the size string in the parent if this is an archive member. */ Elf32_Ehdr ehdr_mem; /* Memory used for ELF header when not mmaped. */ @@ -360,7 +360,7 @@ struct Elf int ehdr_flags; /* Flags (dirty) for ELF header. */ int phdr_flags; /* Flags (dirty|malloc) for program header. */ int shdr_malloced; /* Nonzero if shdr array was allocated. */ - off64_t sizestr_offset; /* Offset of the size string in the parent + off_t sizestr_offset; /* Offset of the size string in the parent if this is an archive member. */ Elf64_Ehdr ehdr_mem; /* Memory used for ELF header when not mmaped. */ diff --git a/src/ChangeLog b/src/ChangeLog index 168bc725..ef09a091 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,20 @@ +2015-10-09 Josh Stone <jistone@redhat.com> + + * elflint.c (main): Replace stat64 and fstat64 with stat and fstat. + * readelf.c (process_file): Likewise. + (process_elf_file): Replace off64_t with off_t. + * findtextrel.c (process_file): Replace open64 with open. + * ld.c (main): Replace sizeof (off64_t) with 8. + * strings.c: Replace off64_t with off_t throughout. + (main): Replace stat64 and fstat64 with stat and fstat. + (map_file): Replace mmap64 with mmap. + (read_block): Likewise, and replace lseek64 with lseek. + * strip.c (handle_elf): Replace ftruncate64 with ftruncate. + (process_file): Replace stat64 and fstat64 with stat and fstat. + * unstrip.c (parse_opt): Replace stat64 with stat. + (handle_file): Replace open64 with open. + (open_file): Likewise. + 2015-10-08 Chih-Hung Hsieh <chh@google.com> * ld.c (determine_output_format): Move recursive nested diff --git a/src/elflint.c b/src/elflint.c index c1f0be5e..fac457ea 100644 --- a/src/elflint.c +++ b/src/elflint.c @@ -164,9 +164,9 @@ main (int argc, char *argv[]) else { unsigned int prev_error_count = error_count; - struct stat64 st; + struct stat st; - if (fstat64 (fd, &st) != 0) + if (fstat (fd, &st) != 0) { printf ("cannot stat '%s': %m\n", argv[remaining]); close (fd); diff --git a/src/findtextrel.c b/src/findtextrel.c index 0ac6ede2..e78d7b8a 100644 --- a/src/findtextrel.c +++ b/src/findtextrel.c @@ -215,7 +215,7 @@ process_file (const char *fname, bool more_than_one) real_fname = new_fname; } - int fd = open64 (real_fname, O_RDONLY); + int fd = open (real_fname, O_RDONLY); if (fd == -1) { error (0, errno, gettext ("cannot open '%s'"), fname); @@ -388,7 +388,7 @@ cannot get program header index at offset %zd: %s"), fname, fname_len), ".debug"); - fd2 = open64 (difname, O_RDONLY); + fd2 = open (difname, O_RDONLY); if (fd2 != -1 && (elf2 = elf_begin (fd2, ELF_C_READ_MMAP, NULL)) != NULL) dw = dwarf_begin_elf (elf2, DWARF_C_READ, NULL); @@ -277,7 +277,7 @@ main (int argc, char *argv[]) int err; /* Sanity check. We always want to use the LFS functionality. */ - if (sizeof (off_t) != sizeof (off64_t)) + if (sizeof (off_t) != 8) abort (); /* We use no threads here which can interfere with handling a stream. */ diff --git a/src/readelf.c b/src/readelf.c index fe7bc392..5f6e4edd 100644 --- a/src/readelf.c +++ b/src/readelf.c @@ -764,8 +764,8 @@ process_file (int fd, const char *fname, bool only_one) dwfl->offline_next_address = 0; if (dwfl_report_offline (dwfl, fname, fname, dwfl_fd) == NULL) { - struct stat64 st; - if (fstat64 (dwfl_fd, &st) != 0) + struct stat st; + if (fstat (dwfl_fd, &st) != 0) error (0, errno, gettext ("cannot stat input file")); else if (unlikely (st.st_size == 0)) error (0, 0, gettext ("input file is empty")); @@ -848,7 +848,7 @@ process_elf_file (Dwfl_Module *dwflmod, int fd) if (ehdr->e_type == ET_REL && print_unrelocated) { /* Read the file afresh. */ - off64_t aroff = elf_getaroff (elf); + off_t aroff = elf_getaroff (elf); pure_elf = elf_begin (fd, ELF_C_READ_MMAP, NULL); if (aroff > 0) { diff --git a/src/strings.c b/src/strings.c index 397ce429..c1d63cd6 100644 --- a/src/strings.c +++ b/src/strings.c @@ -49,8 +49,8 @@ /* Prototypes of local functions. */ -static int read_fd (int fd, const char *fname, off64_t fdlen); -static int read_elf (Elf *elf, int fd, const char *fname, off64_t fdlen); +static int read_fd (int fd, const char *fname, off_t fdlen); +static int read_elf (Elf *elf, int fd, const char *fname, off_t fdlen); /* Name and version of program. */ @@ -138,7 +138,7 @@ static size_t ps; static unsigned char *elfmap; static unsigned char *elfmap_base; static size_t elfmap_size; -static off64_t elfmap_off; +static off_t elfmap_off; int @@ -167,14 +167,14 @@ main (int argc, char *argv[]) /* Determine the page size. We will likely need it a couple of times. */ ps = sysconf (_SC_PAGESIZE); - struct stat64 st; + struct stat st; int result = 0; if (remaining == argc) /* We read from standard input. This we cannot do for a structured file. */ result = read_fd (STDIN_FILENO, print_file_name ? "{standard input}" : NULL, - (fstat64 (STDIN_FILENO, &st) == 0 && S_ISREG (st.st_mode)) + (fstat (STDIN_FILENO, &st) == 0 && S_ISREG (st.st_mode)) ? st.st_size : INT64_C (0x7fffffffffffffff)); else do @@ -189,10 +189,10 @@ main (int argc, char *argv[]) else { const char *fname = print_file_name ? argv[remaining] : NULL; - int fstat_fail = fstat64 (fd, &st); - off64_t fdlen = (fstat_fail + int fstat_fail = fstat (fd, &st); + off_t fdlen = (fstat_fail ? INT64_C (0x7fffffffffffffff) : st.st_size); - if (fdlen > (off64_t) min_len_bytes) + if (fdlen > (off_t) min_len_bytes) { Elf *elf = NULL; if (entire_file @@ -326,7 +326,7 @@ parse_opt (int key, char *arg, static void -process_chunk_mb (const char *fname, const unsigned char *buf, off64_t to, +process_chunk_mb (const char *fname, const unsigned char *buf, off_t to, size_t len, char **unprinted) { size_t curlen = *unprinted == NULL ? 0 : strlen (*unprinted); @@ -403,7 +403,7 @@ process_chunk_mb (const char *fname, const unsigned char *buf, off64_t to, static void -process_chunk (const char *fname, const unsigned char *buf, off64_t to, +process_chunk (const char *fname, const unsigned char *buf, off_t to, size_t len, char **unprinted) { /* We are not going to slow the check down for the 2- and 4-byte @@ -467,7 +467,7 @@ process_chunk (const char *fname, const unsigned char *buf, off64_t to, /* Map a file in as large chunks as possible. */ static void * -map_file (int fd, off64_t start_off, off64_t fdlen, size_t *map_sizep) +map_file (int fd, off_t start_off, off_t fdlen, size_t *map_sizep) { /* Maximum size we mmap. We use an #ifdef to avoid overflows on 32-bit machines. 64-bit machines these days do not have usable @@ -480,7 +480,7 @@ map_file (int fd, off64_t start_off, off64_t fdlen, size_t *map_sizep) # endif /* Try to mmap the file. */ - size_t map_size = MIN ((off64_t) mmap_max, fdlen); + size_t map_size = MIN ((off_t) mmap_max, fdlen); const size_t map_size_min = MAX (MAX (SIZE_MAX / 16, 2 * ps), roundup (2 * min_len_bytes + 1, ps)); void *mem; @@ -489,8 +489,8 @@ map_file (int fd, off64_t start_off, off64_t fdlen, size_t *map_sizep) /* We map the memory for reading only here. Since we will always look at every byte of the file it makes sense to use MAP_POPULATE. */ - mem = mmap64 (NULL, map_size, PROT_READ, MAP_PRIVATE | MAP_POPULATE, - fd, start_off); + mem = mmap (NULL, map_size, PROT_READ, MAP_PRIVATE | MAP_POPULATE, + fd, start_off); if (mem != MAP_FAILED) { /* We will go through the mapping sequentially. */ @@ -515,7 +515,7 @@ map_file (int fd, off64_t start_off, off64_t fdlen, size_t *map_sizep) /* Read the file without mapping. */ static int -read_block_no_mmap (int fd, const char *fname, off64_t from, off64_t fdlen) +read_block_no_mmap (int fd, const char *fname, off_t from, off_t fdlen) { char *unprinted = NULL; #define CHUNKSIZE 65536 @@ -577,7 +577,7 @@ read_block_no_mmap (int fd, const char *fname, off64_t from, off64_t fdlen) static int -read_block (int fd, const char *fname, off64_t fdlen, off64_t from, off64_t to) +read_block (int fd, const char *fname, off_t fdlen, off_t from, off_t to) { if (elfmap == NULL) { @@ -596,23 +596,23 @@ read_block (int fd, const char *fname, off64_t fdlen, off64_t from, off64_t to) read pointer. */ // XXX Eventually add flag which avoids this if the position // XXX is known to match. - if (from != 0 && lseek64 (fd, from, SEEK_SET) != from) - error (EXIT_FAILURE, errno, gettext ("lseek64 failed")); + if (from != 0 && lseek (fd, from, SEEK_SET) != from) + error (EXIT_FAILURE, errno, gettext ("lseek failed")); return read_block_no_mmap (fd, fname, from, to - from); } - assert ((off64_t) min_len_bytes < fdlen); + assert ((off_t) min_len_bytes < fdlen); - if (to < (off64_t) elfmap_off || from > (off64_t) (elfmap_off + elfmap_size)) + if (to < (off_t) elfmap_off || from > (off_t) (elfmap_off + elfmap_size)) { /* The existing mapping cannot fit at all. Map the new area. We always map the full range of ELFMAP_SIZE bytes even if this extend beyond the end of the file. The Linux kernel handles this OK if the access pages are not touched. */ elfmap_off = from & ~(ps - 1); - if (mmap64 (elfmap, elfmap_size, PROT_READ, - MAP_PRIVATE | MAP_POPULATE | MAP_FIXED, fd, from) + if (mmap (elfmap, elfmap_size, PROT_READ, + MAP_PRIVATE | MAP_POPULATE | MAP_FIXED, fd, from) == MAP_FAILED) error (EXIT_FAILURE, errno, gettext ("re-mmap failed")); elfmap_base = elfmap; @@ -622,23 +622,23 @@ read_block (int fd, const char *fname, off64_t fdlen, off64_t from, off64_t to) /* Use the existing mapping as much as possible. If necessary, map new pages. */ - if (from >= (off64_t) elfmap_off - && from < (off64_t) (elfmap_off + elfmap_size)) + if (from >= (off_t) elfmap_off + && from < (off_t) (elfmap_off + elfmap_size)) /* There are at least a few bytes in this mapping which we can use. */ process_chunk (fname, elfmap_base + (from - elfmap_off), - MIN (to, (off64_t) (elfmap_off + elfmap_size)), - MIN (to, (off64_t) (elfmap_off + elfmap_size)) - from, + MIN (to, (off_t) (elfmap_off + elfmap_size)), + MIN (to, (off_t) (elfmap_off + elfmap_size)) - from, &unprinted); - if (to > (off64_t) (elfmap_off + elfmap_size)) + if (to > (off_t) (elfmap_off + elfmap_size)) { unsigned char *remap_base = elfmap_base; size_t read_now = elfmap_size - (elfmap_base - elfmap); - assert (from >= (off64_t) elfmap_off - && from < (off64_t) (elfmap_off + elfmap_size)); - off64_t handled_to = elfmap_off + elfmap_size; + assert (from >= (off_t) elfmap_off + && from < (off_t) (elfmap_off + elfmap_size)); + off_t handled_to = elfmap_off + elfmap_size; assert (elfmap == elfmap_base || (elfmap_base - elfmap == (ptrdiff_t) ((min_len_bytes + ps - 1) & ~(ps - 1)))); @@ -675,8 +675,8 @@ read_block (int fd, const char *fname, off64_t fdlen, off64_t from, off64_t to) assert (handled_to % ps == 0); assert (handled_to % bytes_per_char == 0); - if (mmap64 (remap_base, read_now, PROT_READ, - MAP_PRIVATE | MAP_POPULATE | MAP_FIXED, fd, handled_to) + if (mmap (remap_base, read_now, PROT_READ, + MAP_PRIVATE | MAP_POPULATE | MAP_FIXED, fd, handled_to) == MAP_FAILED) error (EXIT_FAILURE, errno, gettext ("re-mmap failed")); elfmap_off = handled_to; @@ -700,14 +700,14 @@ read_block (int fd, const char *fname, off64_t fdlen, off64_t from, off64_t to) static int -read_fd (int fd, const char *fname, off64_t fdlen) +read_fd (int fd, const char *fname, off_t fdlen) { return read_block (fd, fname, fdlen, 0, fdlen); } static int -read_elf (Elf *elf, int fd, const char *fname, off64_t fdlen) +read_elf (Elf *elf, int fd, const char *fname, off_t fdlen) { assert (fdlen >= 0); diff --git a/src/strip.c b/src/strip.c index 6fdb3bf9..06d7cfd8 100644 --- a/src/strip.c +++ b/src/strip.c @@ -310,12 +310,12 @@ process_file (const char *fname) /* If we have to preserve the modify and access timestamps get them now. We cannot use fstat() after opening the file since the open would change the access time. */ - struct stat64 pre_st; + struct stat pre_st; struct timespec tv[2]; again: if (preserve_dates) { - if (stat64 (fname, &pre_st) != 0) + if (stat (fname, &pre_st) != 0) { error (0, errno, gettext ("cannot stat input file '%s'"), fname); return 1; @@ -338,8 +338,8 @@ process_file (const char *fname) /* We always use fstat() even if we called stat() before. This is done to make sure the information returned by stat() is for the same file. */ - struct stat64 st; - if (fstat64 (fd, &st) != 0) + struct stat st; + if (fstat (fd, &st) != 0) { error (0, errno, gettext ("cannot stat input file '%s'"), fname); return 1; @@ -2115,7 +2115,7 @@ while computing checksum for debug information")); || (pwrite_retry (fd, zero, sizeof zero, offsetof (Elf32_Ehdr, e_shentsize)) != sizeof zero) - || ftruncate64 (fd, shdr_info[shdridx].shdr.sh_offset) < 0) + || ftruncate (fd, shdr_info[shdridx].shdr.sh_offset) < 0) { error (0, errno, gettext ("while writing '%s'"), output_fname ?: fname); @@ -2135,7 +2135,7 @@ while computing checksum for debug information")); || (pwrite_retry (fd, zero, sizeof zero, offsetof (Elf64_Ehdr, e_shentsize)) != sizeof zero) - || ftruncate64 (fd, shdr_info[shdridx].shdr.sh_offset) < 0) + || ftruncate (fd, shdr_info[shdridx].shdr.sh_offset) < 0) { error (0, errno, gettext ("while writing '%s'"), output_fname ?: fname); diff --git a/src/unstrip.c b/src/unstrip.c index b725987c..bc8ed503 100644 --- a/src/unstrip.c +++ b/src/unstrip.c @@ -176,9 +176,9 @@ parse_opt (int key, char *arg, struct argp_state *state) if (info->output_dir != NULL) { - struct stat64 st; + struct stat st; error_t fail = 0; - if (stat64 (info->output_dir, &st) < 0) + if (stat (info->output_dir, &st) < 0) fail = errno; else if (!S_ISDIR (st.st_mode)) fail = ENOTDIR; @@ -1988,7 +1988,7 @@ DWARF data in '%s' not adjusted for prelinking bias; consider prelink -u"), make_directories (output_file); /* Copy the unstripped file and then modify it. */ - int outfd = open64 (output_file, O_RDWR | O_CREAT, + int outfd = open (output_file, O_RDWR | O_CREAT, stripped_ehdr->e_type == ET_REL ? 0666 : 0777); if (outfd < 0) error (EXIT_FAILURE, errno, _("cannot open '%s'"), output_file); @@ -2018,7 +2018,7 @@ DWARF data in '%s' not adjusted for prelinking bias; consider prelink -u"), static int open_file (const char *file, bool writable) { - int fd = open64 (file, writable ? O_RDWR : O_RDONLY); + int fd = open (file, writable ? O_RDWR : O_RDONLY); if (fd < 0) error (EXIT_FAILURE, errno, _("cannot open '%s'"), file); return fd; diff --git a/tests/ChangeLog b/tests/ChangeLog index 523a3506..11515501 100644 --- a/tests/ChangeLog +++ b/tests/ChangeLog @@ -1,3 +1,20 @@ +2015-10-09 Josh Stone <jistone@redhat.com> + + * lfs-symbols: New list of LFS-related symbols from lintian. + * testfile-nolfs.bz2: New test binary for sanity checking. + * run-lfs-symbols.sh: New test. + * Makefile.am (TESTS): Add run-lfs-symbols.sh. + (EXTRA_DIST): Add lfs-symbols, testfile-nolfs.bz2, and + run-lfs-symbols.sh. + * alldts.c (main): Replace open64 with open. + * dwarf-getstring.c (main): Likewise. + * arls.c: Include config.h. + * ecp.c: Likewise. + * rdwrmmap.c: Likewise. + * test-elf_cntl_gelf_getshdr.c: Likewise. + * test-flag-nobits.c: Include config.h. + (main): Replace open64 with open. + 2015-10-09 Mark Wielaard <mjw@redhat.com> * elfshphehdr.c (check): Rename argument from check to statement. diff --git a/tests/Makefile.am b/tests/Makefile.am index fc9b648d..5612fc7b 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -120,7 +120,7 @@ TESTS = run-arextract.sh run-arsymtest.sh newfile test-nlist \ run-readelf-dwz-multi.sh run-allfcts-multi.sh run-deleted.sh \ run-linkmap-cut.sh run-aggregate-size.sh vdsosyms run-readelf-A.sh \ run-getsrc-die.sh run-strptr.sh newdata elfstrtab dwfl-proc-attach \ - elfshphehdr + elfshphehdr run-lfs-symbols.sh if !BIARCH export ELFUTILS_DISABLE_BIARCH = 1 @@ -303,7 +303,8 @@ EXTRA_DIST = run-arextract.sh run-arsymtest.sh \ run-getsrc-die.sh run-strptr.sh \ testfile-x32-core.bz2 testfile-x32.bz2 \ backtrace.x32.core.bz2 backtrace.x32.exec.bz2 \ - testfile-x32-s.bz2 testfile-x32-d.bz2 testfile-x32-debug.bz2 + testfile-x32-s.bz2 testfile-x32-d.bz2 testfile-x32-debug.bz2 \ + run-lfs-symbols.sh lfs-symbols testfile-nolfs.bz2 if USE_VALGRIND valgrind_cmd='valgrind -q --error-exitcode=1 --run-libc-freeres=no' diff --git a/tests/alldts.c b/tests/alldts.c index 378aa412..c39b8fb6 100644 --- a/tests/alldts.c +++ b/tests/alldts.c @@ -68,7 +68,7 @@ main (void) (void) __fsetlocking (stdout, FSETLOCKING_BYCALLER); /* Open the file. */ - int fd = open64 (fname, O_RDWR | O_CREAT | O_TRUNC, 0666); + int fd = open (fname, O_RDWR | O_CREAT | O_TRUNC, 0666); if (fd == -1) { printf ("cannot open `%s': %m\n", fname); diff --git a/tests/arls.c b/tests/arls.c index cd8e4b81..ca0d3e6e 100644 --- a/tests/arls.c +++ b/tests/arls.c @@ -14,6 +14,10 @@ You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>. */ +#ifdef HAVE_CONFIG_H +# include <config.h> +#endif + #include <ar.h> #include <fcntl.h> #include <libelf.h> diff --git a/tests/dwarf-getstring.c b/tests/dwarf-getstring.c index b70c2a70..824edef8 100644 --- a/tests/dwarf-getstring.c +++ b/tests/dwarf-getstring.c @@ -37,7 +37,7 @@ main (int argc, char *argv[]) Dwarf_Off offset = 0; size_t len; - int fd = open64 (argv[cnt], O_RDONLY); + int fd = open (argv[cnt], O_RDONLY); if (fd == -1) { printf ("cannot open '%s': %m\n", argv[cnt]); diff --git a/tests/ecp.c b/tests/ecp.c index 39a48510..38a6859e 100644 --- a/tests/ecp.c +++ b/tests/ecp.c @@ -15,6 +15,10 @@ You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>. */ +#ifdef HAVE_CONFIG_H +# include <config.h> +#endif + #include <errno.h> #include <error.h> #include <fcntl.h> diff --git a/tests/lfs-symbols b/tests/lfs-symbols new file mode 100644 index 00000000..282a4ad4 --- /dev/null +++ b/tests/lfs-symbols @@ -0,0 +1,73 @@ +# Imported from lintian/data/binaries/lfs-symbols +# +# Exceptions: +# fts* - linux-kernel-modules.c is careful with FTS_NOSTAT + +# Manually maintained list of non-lfs symbols +# +# List was found by grepping around in /usr/include on an i386 system +# with build-essential installed +# +# Please keep this sorted by key. + +__fxstat +__fxstatat +__lxstat +__xstat +aio_cancel +aio_error +aio_fsync +aio_read +aio_return +aio_suspend +aio_write +alphasort +creat +fallocate +fgetpos +fopen +freopen +fseeko +fsetpos +fstatfs +fstatvfs +ftello +ftruncate +#fts_open +#fts_read +#fts_children +#fts_set +#fts_close +ftw +getdirentries +getrlimit +glob +globfree +lio_listio +lockf +lseek +mkostemp +mkostemps +mkstemp +mkstemps +mmap +nftw +open +openat +posix_fadvise +posix_fallocate +pread +preadv +prlimit +pwrite +pwritev +readdir +readdir_r +scandir +sendfile +setrlimit +statfs +statvfs +tmpfile +truncate +versionsort diff --git a/tests/rdwrmmap.c b/tests/rdwrmmap.c index 95a4df35..6f027dfe 100644 --- a/tests/rdwrmmap.c +++ b/tests/rdwrmmap.c @@ -14,6 +14,10 @@ You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>. */ +#ifdef HAVE_CONFIG_H +# include <config.h> +#endif + #include <errno.h> #include <error.h> #include <stdio.h> diff --git a/tests/run-lfs-symbols.sh b/tests/run-lfs-symbols.sh new file mode 100755 index 00000000..f0894405 --- /dev/null +++ b/tests/run-lfs-symbols.sh @@ -0,0 +1,86 @@ +#! /bin/bash +# Copyright (C) 2015 Red Hat, Inc. +# This file is part of elfutils. +# +# This file is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# elfutils is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/>. + +. $srcdir/test-subr.sh + +if ! grep -q -F '#define _FILE_OFFSET_BITS' ${abs_top_builddir}/config.h; then + echo "LFS testing is irrelevent on this system" + exit 77 +fi + +# #include <stdio.h> +# int main () { +# FILE *f = fopen ("/dev/null", "r"); +# return f == NULL; +# } +# +# Built for Linux i686, without setting _FILE_OFFSET_BITS. +# $ gcc -m32 -O2 nolfs.c -o testfile-nolfs +testfiles testfile-nolfs + +LFS_FORMAT='BEGIN { + while ((getline < "%s") > 0) + /^\w/ && bad[$0] + FS="@" +} +/@@GLIBC_/ && $1 in bad { print $1 }' + +LFS=$(printf "$LFS_FORMAT" "${abs_srcdir}/lfs-symbols") + +makeprint() { + make print-$1 -C $2 |& awk -F= "/^$1=/{ print \$2 }" +} + +testrun_lfs() { + bad=$(testrun ${abs_top_builddir}/src/nm -u "$1" | awk "$LFS") + if [ -n "$bad" ]; then + echo "$1 contains non-lfs symbols:" $bad + exit_status=1 + fi +} + +# First sanity-check that LFS detection works. +exit_status=0 +testrun_lfs ./testfile-nolfs +if [ $exit_status -eq 0 ]; then + echo "Didn't detect any problem with testfile-nolfs!" + exit 99 +fi + +exit_status=0 + +# Check all normal build targets. +for dir in libelf libdw libasm libcpu src; do + dir=${abs_top_builddir}/$dir + for program in $(makeprint PROGRAMS $dir); do + testrun_lfs $dir/$program + done +done + +# Check all libebl modules. +dir=${abs_top_builddir}/backends +for module in $(makeprint modules $dir); do + testrun_lfs $dir/libebl_$module.so +done + +# Check all test programs. +dir=${abs_builddir} +for program in $(makeprint check_PROGRAMS $dir); do + testrun_lfs $dir/$program +done + +exit $exit_status diff --git a/tests/test-elf_cntl_gelf_getshdr.c b/tests/test-elf_cntl_gelf_getshdr.c index b561b53c..7371110c 100644 --- a/tests/test-elf_cntl_gelf_getshdr.c +++ b/tests/test-elf_cntl_gelf_getshdr.c @@ -14,6 +14,10 @@ You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>. */ +#ifdef HAVE_CONFIG_H +# include <config.h> +#endif + #include <sys/types.h> #include <sys/stat.h> #include <stdio.h> diff --git a/tests/test-flag-nobits.c b/tests/test-flag-nobits.c index e58d8c3d..ff19ce20 100644 --- a/tests/test-flag-nobits.c +++ b/tests/test-flag-nobits.c @@ -14,6 +14,10 @@ You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>. */ +#ifdef HAVE_CONFIG_H +# include <config.h> +#endif + #include <fcntl.h> #include <stdlib.h> #include <gelf.h> @@ -26,7 +30,7 @@ main (int argc, char **argv) elf_version (EV_CURRENT); - int fd = open64 (argv[1], O_RDONLY); + int fd = open (argv[1], O_RDONLY); Elf *stripped = elf_begin (fd, ELF_C_READ, NULL); Elf_Scn *scn = NULL; diff --git a/tests/testfile-nolfs.bz2 b/tests/testfile-nolfs.bz2 Binary files differnew file mode 100644 index 00000000..ab8351e9 --- /dev/null +++ b/tests/testfile-nolfs.bz2 |