]> git.ipfire.org Git - thirdparty/elfutils.git/commitdiff
Trust AC_SYS_LARGEFILE to provide large file support
authorJosh Stone <jistone@redhat.com>
Fri, 9 Oct 2015 17:10:37 +0000 (10:10 -0700)
committerJosh Stone <jistone@redhat.com>
Fri, 9 Oct 2015 17:10:37 +0000 (10:10 -0700)
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:
config/ChangeLog
config/eu.am
libdw/ChangeLog
libdw/dwarf_begin.c
libdwfl/ChangeLog
libdwfl/argp-std.c
libdwfl/core-file.c
libdwfl/dwfl_build_id_find_elf.c
libdwfl/dwfl_module_getdwarf.c
libdwfl/dwfl_report_elf.c
libdwfl/dwfl_segment_report_module.c
libdwfl/find-debuginfo.c
libdwfl/gzip.c
libdwfl/image-header.c
libdwfl/libdwflP.h
libdwfl/link_map.c
libdwfl/linux-kernel-modules.c
libdwfl/linux-proc-maps.c
libdwfl/offline.c
libdwfl/open.c
libelf/ChangeLog
libelf/elf_getdata_rawchunk.c
libelf/libelfP.h
src/ChangeLog
src/elflint.c
src/findtextrel.c
src/ld.c
src/readelf.c
src/strings.c
src/strip.c
src/unstrip.c
tests/ChangeLog
tests/Makefile.am
tests/alldts.c
tests/arls.c
tests/dwarf-getstring.c
tests/ecp.c
tests/lfs-symbols [new file with mode: 0644]
tests/rdwrmmap.c
tests/run-lfs-symbols.sh [new file with mode: 0755]
tests/test-elf_cntl_gelf_getshdr.c
tests/test-flag-nobits.c
tests/testfile-nolfs.bz2 [new file with mode: 0644]

index ba5cb387ab23adf61701a866d41aeff5664e056e..41678214d84388f455360325c47db98d8d345989 100644 (file)
@@ -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.
index 6ad8f822bdb37f6c7bf0f563c8a51b3abfb4c422..1e332efa1e9e39210534b91a00f21b36664356dd 100644 (file)
@@ -74,3 +74,6 @@ else
 textrel_found = $(textrel_msg)
 endif
 textrel_check = if $(READELF) -d $@ | fgrep -q TEXTREL; then $(textrel_found); fi
+
+print-%:
+       @echo $*=$($*)
index efe6ccb8e2b129139488107bb66fad307d1ae7fd..39c49aa48b86a8bc225be742e1087de0c91b5a2b 100644 (file)
@@ -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.
index d04e5b9f1b11ce0c31f12b0e5667153d6460c605..19d16e5c511c6c28a98121e7e58ee7e53962e838 100644 (file)
@@ -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);
index 211f9ecd19ec5cf17914f5ae462eda882b5f0ae5..5cae434ec449d45175e4c050499aa480f1f869ee 100644 (file)
@@ -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
index 42b7e78380047ae67560eb77d7ad8ed9b621ae67..2bbf74fc5f53b26d18618eacbe331d4e887cbddc 100644 (file)
@@ -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;
index ea0725bf547bb7f057b24d87529b399684b4d200..b317ecaa6e6c69e348b85477d9a9cd55523bc4c7 100644 (file)
@@ -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);
 }
 
index 99a5059c9ddb627bc03c639ec8fe0825eed95b47..2e30b7abb1c572531c6d88b51665a06e5d68382e 100644 (file)
@@ -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);
index a35905775d00cdec6e06cdfc566852d8163cee7a..8483fa21690709732f307f8c678acd181f68bbb5 100644 (file)
@@ -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;
index 624284cf6fe170e396b091cc3e2ceaab22127620..1c6e401d1ccd3aaa1d289a51e45f5c4c5078de7e 100644 (file)
@@ -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);
index ca86c3115bb848590f70a871ed23e5d98fda0b11..40553c948bfef2458339c943eb75145f8c502320 100644 (file)
@@ -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);
index 6b8d1ac4b992f83177b2b980ac395bf21e30862e..72461bc3d2a540322406c64411d20950b9377f79 100644 (file)
 #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;
index b7dde5d423080a620c9b38c08b31a85e48829e48..c81e52e33fb240be60f77f3b0f469943a545c174 100644 (file)
@@ -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);
index a4f6799ac48a1fcc80e8edd8b560d71e3506a0a6..62ccc3e35979ba1c23921d5d14ec6aa5bbe88f9a 100644 (file)
@@ -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))
index 42a2669e7851d81555d2f830b1524c04d4bf7090..63556d511b6ee7845373c79cdcaec86c8b952991 100644 (file)
@@ -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;
 
index 9f0b4a2cb507bf4c63204205ccb309d348f744bf..13cac52912e377b933f7615b0d516296088dd36e 100644 (file)
@@ -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;
index dafe893cbda5747649e7468f614f217b858bdcf6..38b5170a1a8137cdc6e0f63e8e581f642824839b 100644 (file)
 #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]);
index 2a65db2ecee53dc6829500754c11058da28410ff..2e2c8f92a712518d47f11f6df90148aa236f65fc 100644 (file)
@@ -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;
index 982ceab0288b453396038d079e7967268b9b12c2..c0a259926a270d71dc99678470cd24c8b4e1d85a 100644 (file)
@@ -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);
index 40aac38801ef5fc2c5a29a0179fed0fcb3fcc8d3..c1d0ed2b8138bc67ba7890d0902c70969e6db08f 100644 (file)
@@ -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),
index 0b9ddf2b8e232cd259ae0db5296341244d9c5bcb..b1d1ecdf11e5bbeab7956b401a49b3edfa20732d 100644 (file)
@@ -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
index 51b3e3e745eb2afb8e0c2f028253cdcba07ead75..31b2fe7d23bfe110ae84260e396c3e804f3f2c39 100644 (file)
@@ -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;
index 3f4d654b7f34e82c6c393ccd7df395b1f6344c7b..993c6556d7da42cffc4c2a1064a3c50bae764524 100644 (file)
@@ -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.  */
index 168bc7254e5f7227476548111af472479651dbf4..ef09a091e2ed7131b6cf2a8cd9a0df72119af276 100644 (file)
@@ -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
index c1f0be5eee1bfbff59f4ee42c51e4d78ecc04f25..fac457ea6c4c573ae5bc10ec9ddb2aa2d3d67f50 100644 (file)
@@ -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);
index 0ac6ede287ea4b0e1e2645b71a6663b6b4c95f0a..e78d7b8a17ab1dd1fac4a5c621b35624f85f6718 100644 (file)
@@ -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);
index b9a4f64b7e67e758781953ec273a166a36369593..59dccb5483a990e071e67bbe74a37a5e89707ca6 100644 (file)
--- a/src/ld.c
+++ b/src/ld.c
@@ -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.  */
index fe7bc392f8b4b92f626c7df591e0a6cf2925b18c..5f6e4edd53c22c1b709f41b3181da715a5168da4 100644 (file)
@@ -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)
        {
index 397ce429bb2d481259c1a72fce27f48dfd9cd620..c1d63cd6fa9bb4e669ac0cdf5fd9451712f84ec9 100644 (file)
@@ -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);
 
index 6fdb3bf9a1fbb80586597752b3b37050b250f7c1..06d7cfd850e70c584f3d72424bf798c3bc4d5d82 100644 (file)
@@ -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);
index b725987c462a507b56e165118c80912af1fb3d5c..bc8ed5037c005c2e17d6ad571eb09a58805068ec 100644 (file)
@@ -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;
index 523a350693e5e6fdd81f76e60e530eedc939d5f9..11515501ce2d8fe19c29b78161a2490e12c283ec 100644 (file)
@@ -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.
index fc9b648d2f02bd7c0c73c69d7640a7730d399b55..5612fc7b5f4834195b36181b14b91a7b63541740 100644 (file)
@@ -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'
index 378aa412a70e76d66851b0828c04e7f35417eef5..c39b8fb617721ddbbb9eb78b3a8d7ddbfe153fd9 100644 (file)
@@ -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);
index cd8e4b81d3ca1396dc5c93763a0db6c04acfd4c5..ca0d3e6e6533d27edd05d4d753f6c36dbc925381 100644 (file)
    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>
index b70c2a70cdd9d41d2fb8bdb90266096d7abe95ff..824edef87f918790138805b22ffc01b0f3917236 100644 (file)
@@ -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]);
index 39a48510ee7dc8b086158a7b0aa21479705b1c8a..38a6859e8b2b71474b4c783451495f33aae4760b 100644 (file)
    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 (file)
index 0000000..282a4ad
--- /dev/null
@@ -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
index 95a4df3554a4cebdc57283ca791959d3e826227d..6f027dfed8a314c54d089cac04ebd259c546faee 100644 (file)
    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 (executable)
index 0000000..f089440
--- /dev/null
@@ -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
index b561b53cb4f191a0cd5799dffa301c03e591d416..7371110c75e27f154c19a2c33279ac8a529f8b69 100644 (file)
    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>
index e58d8c3df5408e08b73956355a93e61431ddd536..ff19ce202ea3dd5ef8630eb54d3efc6b9d23eec0 100644 (file)
    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
new file mode 100644 (file)
index 0000000..ab8351e
Binary files /dev/null and b/tests/testfile-nolfs.bz2 differ