+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.
textrel_found = $(textrel_msg)
endif
textrel_check = if $(READELF) -d $@ | fgrep -q TEXTREL; then $(textrel_found); fi
+
+print-%:
+ @echo $*=$($*)
+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.
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);
+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
if (opt->core)
{
- int fd = open64 (opt->core, O_RDONLY);
+ int fd = open (opt->core, O_RDONLY);
if (fd < 0)
{
int code = errno;
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;
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
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. */
*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
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);
}
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)
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);
/* 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;
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);
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);
#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)
{
: 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)
{
}
/* 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;
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)
{
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);
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))
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;
{
/* 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;
#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"
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)
{
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
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;
&& (!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]);
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;
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;
/* 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);
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);
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;
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);
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;
/* 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),
+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
#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;
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;
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. */
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. */
+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
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);
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);
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);
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. */
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"));
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)
{
/* 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. */
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
/* 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
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
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);
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
/* 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
# 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;
/* 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. */
/* 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
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)
{
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;
/* 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))));
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;
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);
/* 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;
/* 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;
|| (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);
|| (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);
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;
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);
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;
+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.
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
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'
(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);
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>
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]);
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>
--- /dev/null
+# 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
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>
--- /dev/null
+#! /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
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>
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>
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;