Imported Upstream version 0.165
[platform/upstream/elfutils.git] / libdwfl / open.c
index 40aac38..92f2798 100644 (file)
@@ -1,5 +1,5 @@
-/* Decompression support for libdwfl: zlib (gzip) and/or bzlib (bzip2).
-   Copyright (C) 2009 Red Hat, Inc.
+/* Decompression support for libdwfl: zlib (gzip), bzlib (bzip2) or lzma (xz).
+   Copyright (C) 2009, 2016 Red Hat, Inc.
    This file is part of elfutils.
 
    This file is free software; you can redistribute it and/or modify
 
 #include <unistd.h>
 
-#if !USE_ZLIB
-# define __libdw_gunzip(...)   DWFL_E_BADELF
-#endif
-
 #if !USE_BZLIB
 # define __libdw_bunzip2(...)  DWFL_E_BADELF
 #endif
@@ -52,8 +48,7 @@ decompress (int fd __attribute__ ((unused)), Elf **elf)
   void *buffer = NULL;
   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;
@@ -65,7 +60,6 @@ decompress (int fd __attribute__ ((unused)), Elf **elf)
     error = __libdw_bunzip2 (fd, offset, mapped, mapped_size, &buffer, &size);
   if (error == DWFL_E_BADELF)
     error = __libdw_unlzma (fd, offset, mapped, mapped_size, &buffer, &size);
-#endif
 
   if (error == DWFL_E_NOERROR)
     {
@@ -132,7 +126,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),