#
# spec file for package elfutils
#
# Copyright (c) 2015 SUSE LINUX Products GmbH, Nuernberg, Germany.
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
# upon. The license for this file, and modifications and additions to the
# file, is the same license as for the pristine package itself (unless the
# license for the pristine package is not an Open Source License, in which
# case the license is the MIT License). An "Open Source License" is a
# license that conforms to the Open Source Definition (Version 1.9)
# published by the Open Source Initiative.

# Please submit bugfixes or comments via http://bugs.opensuse.org/
#


Name:           elfutils
Version:        0.158
Release:        10.50
Summary:        Higher-level library to access ELF
License:        SUSE-GPL-2.0-with-OSI-exception
Group:          System/Libraries
Url:            http://elfutils.fedorahosted.org
Source:         https://fedorahosted.org/releases/e/l/%{name}/%{version}/%{name}-%{version}.tar.bz2
Source1:        README-BEFORE-ADDING-PATCHES
Source2:        baselibs.conf
Source3:        %{name}.changes
Patch1:         https://fedorahosted.org/releases/e/l/%{name}/%{version}/elfutils-portability.patch
Patch2:         https://fedorahosted.org/releases/e/l/%{name}/%{version}/elfutils-robustify.patch
Patch3:         elfutils-no-po-test-build.diff
Patch4:         libebl-prototype-fix.diff
Patch5:         elfutils-uninitialized.diff
Patch6:         elfutils-0.137-dwarf-header-check-fix.diff
Patch7:         elfutils-0.148-dont-crash.diff
Patch8:         elfutils-revert-portability-scanf.patch
Patch9:         elfutils-check-for-overflow-before-calling-malloc-to-uncompress-data.patch
Patch10:        elfutils-fix-dir-traversal-vuln-in-ar-extraction.patch
BuildRoot:      %{_tmppath}/%{name}-%{version}-build
BuildRequires:  bison
BuildRequires:  flex
BuildRequires:  libbz2-devel
BuildRequires:  xz-devel
BuildRequires:  zlib-devel

%description
This package provides a higher-level library to access ELF files. This
is a part of elfutils package.

%package -n libasm1
Summary:        A collection of utilities and DSOs to handle compiled objects
Group:          Development/Tools/Other

%description -n libasm1
Elfutils is a collection of utilities, including ld (a linker), nm (for
listing symbols from object files), size (for listing the section sizes
of an object or archive file), strip (for discarding symbols), readline
(the see the raw ELF file structures), and elflint (to check for
well-formed ELF files).  Also included are numerous helper libraries
which implement DWARF, ELF, and machine-specific ELF handling.

%package -n libasm-devel
Summary:        A collection of utilities and DSOs to handle compiled objects
Group:          Development/Tools/Other
Requires:       glibc-devel
Requires:       libasm1 = %{version}

%description -n libasm-devel
Elfutils is a collection of utilities, including ld (a linker), nm (for
listing symbols from object files), size (for listing the section sizes
of an object or archive file), strip (for discarding symbols), readline
(the see the raw ELF file structures), and elflint (to check for
well-formed ELF files).  Also included are numerous helper libraries
which implement DWARF, ELF, and machine-specific ELF handling.

%package -n libebl1
Summary:        A collection of utilities and DSOs to handle compiled objects
Group:          Development/Tools/Other
Provides:       libebl = %{version}
Obsoletes:      libebl < %{version}

%description -n libebl1
Elfutils is a collection of utilities, including ld (a linker), nm (for
listing symbols from object files), size (for listing the section sizes
of an object or archive file), strip (for discarding symbols), readline
(the see the raw ELF file structures), and elflint (to check for
well-formed ELF files).  Also included are numerous helper libraries
which implement DWARF, ELF, and machine-specific ELF handling.

%package -n libebl-devel
Summary:        Include Files and Libraries mandatory for Development
Group:          Development/Libraries/C and C++
Requires:       glibc-devel
Requires:       libdw-devel = %{version}
Requires:       libebl1 = %{version}

%description -n libebl-devel
This package contains all necessary include files and libraries needed
to develop applications that require these.

%package -n libelf1
Summary:        Library to read and write ELF files
Group:          System/Libraries

%description -n libelf1
This package provides a high-level library to read and write ELF files.
This is a part of elfutils package.

%package -n libelf-devel
Summary:        Include Files and Libraries mandatory for Development
Group:          Development/Libraries/C and C++
Requires:       glibc-devel
Requires:       libelf1 = %{version}
Conflicts:      libelf0-devel

%description -n libelf-devel
This package contains all necessary include files and libraries needed
to develop applications that require these.

%package -n libdw1
Summary:        Library to access DWARF debugging information
Group:          System/Libraries

%description -n libdw1
This package provides a high-level library to access the DWARF debugging
information.  This is a part of elfutils package.

%package -n libdw-devel
Summary:        Include Files and Libraries mandatory for Development
Group:          Development/Libraries/C and C++
Requires:       glibc-devel
Requires:       libdw1 = %{version}
Requires:       libelf-devel = %{version}

%description -n libdw-devel
This package contains all necessary include files and libraries needed
to develop applications that require these.

%prep
%setup -q -n elfutils-%{version}
%patch1 -p1
%patch2 -p1
%patch3 -p1
%patch4 -p1
%patch5 -p1
%patch6 -p1
%patch7 -p1
%patch8 -p1 -R
%patch9 -p1
%patch10 -p1

%build
# Change DATE/TIME macros to use last change time of elfutils.changes
# See http://lists.opensuse.org/opensuse-factory/2011-05/msg00304.html
modified="$(sed -n '/^----/n;s/ - .*$//;p;q' "%{_sourcedir}/%{name}.changes")"
DATE="\"$(date -d "${modified}" "+%%b %%e %%Y")\""
TIME="\"$(date -d "${modified}" "+%%R")\""
find . -type f -regex ".*\.c\|.*\.cpp\|.*\.h" -exec sed -i "s/__DATE__/${DATE}/g;s/__TIME__/${TIME}/g" {} +
%ifarch %sparc
# Small PIC model not sufficient
export CFLAGS="%optflags -fPIC"
%endif
%configure --program-prefix=eu-
make %{?_smp_mflags}

%install
make DESTDIR=$RPM_BUILD_ROOT install
# remove unneeded files
rm -f $RPM_BUILD_ROOT%{_libdir}/*.la
ls -lR $RPM_BUILD_ROOT%{_libdir}/libelf*

%post -n libebl1 -p /sbin/ldconfig

%post -n libelf1 -p /sbin/ldconfig

%post -n libdw1 -p /sbin/ldconfig

%postun -n libebl1 -p /sbin/ldconfig

%postun -n libelf1 -p /sbin/ldconfig

%postun -n libdw1 -p /sbin/ldconfig

%files
%defattr(-,root,root)
%doc AUTHORS ChangeLog COPYING NEWS NOTES README THANKS TODO
%{_bindir}/*

%files -n libasm1
%defattr(-,root,root)
%{_libdir}/libasm.so.*
%{_libdir}/libasm-%{version}.so

%files -n libasm-devel
%defattr(-,root,root)
%{_libdir}/libasm.so
%{_libdir}/libasm.a
%dir %{_includedir}/elfutils
%{_includedir}/elfutils/libasm.h

%files -n libebl1
%defattr(-,root,root)
%{_libdir}/elfutils

%files -n libebl-devel
%defattr(-,root,root)
%{_libdir}/libebl.a
%dir %{_includedir}/elfutils
%{_includedir}/elfutils/libebl.h

%files -n libelf1
%defattr(-,root,root)
%{_libdir}/libelf.so.*
%{_libdir}/libelf-%{version}.so

%files -n libelf-devel
%defattr(-,root,root)
%{_libdir}/libelf.so
%{_libdir}/libelf.a
%{_includedir}/libelf.h
%{_includedir}/gelf.h
%{_includedir}/nlist.h
%dir %{_includedir}/elfutils
%{_includedir}/elfutils/elf-knowledge.h
%{_includedir}/elfutils/version.h

%files -n libdw1
%defattr(-,root,root)
%{_libdir}/libdw.so.*
%{_libdir}/libdw-%{version}.so

%files -n libdw-devel
%defattr(-,root,root)
%{_libdir}/libdw.a
%{_libdir}/libdw.so
%{_includedir}/dwarf.h
%dir %{_includedir}/elfutils
%{_includedir}/elfutils/libdw.h
%{_includedir}/elfutils/libdwfl.h

%changelog
* Fri Jan  9 2015 tonyj@suse.com
- CVE-2014-9447: elfutils: Directory traversal vulnerability (bnc#911662)
  Add patch: elfutils-fix-dir-traversal-vuln-in-ar-extraction.patch
* Thu Jun 19 2014 tonyj@suse.com
- Package changes file to support local rpmbuild (bnc#879011)
* Tue Apr 15 2014 tonyj@suse.com
- Fix integer overflow in check_section (CVE-2014-0172, bnc#872785)
  Add patch: elfutils-check-for-overflow-before-calling-malloc-to-uncompress-data.patch
* Sat Mar 22 2014 jengelh@inai.de
- SPARC build requires the large PIC model (or else build fails)
* Tue Jan 28 2014 tonyj@suse.com
- Update to 0.158:
  - libdwfl:
  - dwfl_core_file_report has new parameter executable.
  - New functions dwfl_module_getsymtab_first_global,
    dwfl_module_getsym_info and dwfl_module_addrinfo.
  - Added unwinder with type Dwfl_Thread_Callbacks, opaque types
    Dwfl_Thread and Dwfl_Frame and functions dwfl_attach_state,
    dwfl_pid, dwfl_thread_dwfl, dwfl_thread_tid, dwfl_frame_thread,
    dwfl_thread_state_registers, dwfl_thread_state_register_pc,
    dwfl_getthread_frames, dwfl_getthreads, dwfl_thread_getframes
    and dwfl_frame_pc.
  - addr2line: New option -x to show the section an address was found in.
  - stack: New utility that uses the new unwinder for processes and cores.
  - backends: Unwinder support for i386, x86_64, s390, s390x, ppc and ppc64.
    aarch64 support.
* Wed Nov 13 2013 sweet_f_a@gmx.de
- update to 0.157:
  libdw: Add new functions dwarf_getlocations, dwarf_getlocation_attr
    and dwarf_getlocation_die.
  readelf: Show contents of NT_SIGINFO and NT_FILE core notes.
  addr2line: Support -i, --inlines output option.
  backends: abi_cfi hook for arm, ppc and s390.
- update to 0.156:
  lib: New macro COMPAT_VERSION_NEWPROTO.
  libdw: Handle GNU extension opcodes in dwarf_getlocation.
  libdwfl: Fix STB_GLOBAL over STB_WEAK preference in dwfl_module_addrsym.
    Add minisymtab support.
    Add parameter add_p_vaddr to dwfl_report_elf.
    Use DT_DEBUG library search first.
  libebl: Handle new core note types in EBL.
  backends: Interpret NT_ARM_VFP.
    Implement core file registers parsing for s390/s390x.
  readelf: Add --elf-section input option to inspect an embedded ELF file.
    Add -U, --unresolved-address-offsets output control.
    Add --debug-dump=decodedline support.
    Accept version 8 .gdb_index section format.
    Adjust output formatting width.
    When highpc is in constant form print it also as address.
    Display raw .debug_aranges. Use libdw only for decodedaranges.
  elflint: Add __bss_start__ to the list of allowed symbols.
  tests: Add configure --enable-valgrind option to run all tests under valgrind.
    Enable automake parallel-tests for make check.
  translations: Updated Polish translation.
  Updates for Automake 1.13.
- remove elfutils-aarch64.patch and elfutils-sizeof-pointer-memaccess.patch
  (fixed by upstream)
- rebase elfutils-robustify.patch and elfutils-portability.patch, they are
  provided by ustream
* Tue Jun 18 2013 schwab@suse.de
- elfutils-sizeof-pointer-memaccess.patch: Fix sizeof-pointer-memaccess
  warnings
* Tue Mar 26 2013 mmeister@suse.com
- Added url as source.
  Please see http://en.opensuse.org/SourceUrls
* Wed Nov 28 2012 adrian@suse.de
- add elfutils-aarch64.patch to support aarch64
- update to 0.155
  libelf: elf*_xlatetomd now works for cross-endian ELF note data.
  elf_getshdr now works consistently on non-mmaped ELF files after
  calling elf_cntl(ELF_C_FDREAD).
  Implement support for ar archives with 64-bit symbol table.
  [g]elf[32|64]_offscn() do not match SHT_NOBITS sections at OFFSET.
  libdw: dwarf.h corrected the DW_LANG_ObjC constant name (was DW_LANG_Objc).
    Any existing sources using the old name will have to be updated.
    Add DW_MACRO_GNU .debug_macro type encodings constants, DW_ATE_UTF
    and DW_OP_GNU_parameter_ref to dwarf.h.
    Experimental support for DWZ multifile forms DW_FORM_GNU_ref_alt
    and DW_FORM_GNU_strp_alt.  Disabled by default.  Use configure
  - -enable-dwz to test it.
    dwarf_highpc function now handles DWARF 4 DW_AT_high_pc constant form.
    Fix bug using dwarf_next_unit to iterate over .debug_types.
  elflint: Now accepts gold linker produced executables.
  readelf: Add .debug_macro parsing support.
  Add .gdb_index version 7 parsing support.
  Recognize DW_OP_GNU_parameter_ref.
  backends: Add support for Tilera TILE-Gx processor.
  translations: Updated Ukrainian translation.
  The license is now GPLv2/LGPLv3+ for the libraries and GPLv3+ for stand-alone
  programs. There is now also a formal CONTRIBUTING document describing how to
  submit patches.
* Mon Oct  8 2012 schwab@linux-m68k.org
- Fix baselibs.conf: elfutils-devel -> libelf-devel
* Thu Sep 20 2012 cfarrell@suse.com
- license update: SUSE-GPL-2.0-with-OSI-exception
  Use a license available on the spreadsheet linked at
  license.opensuse.org
* Wed May 30 2012 sweet_f_a@gmx.de
- avoid automake dependency
* Thu Mar 15 2012 aj@suse.de
- Update to 0.153:
  * Fix building with gcc 4.7
  * New --disable-werror for portability.
  * Support for .zdebug sections
  * type_units and DW_AT_GNU_odr_signature support
  * low level support DW_OP_GNU_entry_value and DW_TAG_GNU_call_site
- Revert scanf changes in portability patch since C99 gives %%a a new
  meaning.
* Fri Dec  2 2011 cfarrell@suse.com
- license update: GPL-2.0-with-osi-exception
  elfutils is GPL-2.0 (only) with an exception for osi approved licenses.
  Also, use SPDX format
* Thu Dec  1 2011 coolo@suse.com
- add automake as buildrequire to avoid implicit dependency
* Sun Sep 18 2011 jengelh@medozas.de
- Remove redundant/obsolete tags/sections from specfile
  (cf. packaging guidelines)
- Add elfutils-devel to baselibs
* Tue May 24 2011 crrodriguez@opensuse.org
- Remote timestamps on binaries, breaks build compare
- Add missing build requires on zlib, bzip2 and lzma .
* Wed Apr 27 2011 tonyj@novell.com
- Upgrade to 0.152, upstream changelog:
  - Various build and warning nits fixed for newest GCC and Autoconf.
  - libdwfl: Yet another prelink-related fix for another regression.
    Look for Linux kernel images in files named with compression
    suffixes.
  - elfcmp: New flag --ignore-build-id to ignore differing build ID bits.
  New flag -l/--verbose to print all differences.
* Fri Jan 21 2011 tonyj@novell.com
- Update to 0.151
- Upstream changelog for 0.151/0.150
  - libdwfl: Fix for more prelink cases with separate debug file.
  - eu-strip: New flag --strip-sections to remove section headers entirely.
  - libdwfl: Remove bogus assert.
  - libdw: Fix for handling huge .debug_aranges section.
  - libdwfl: Fix for handling prelinked DSO with separate debug file.
  - findtextrel: Fix diagnostics to work with usual section ordering.
  - libebl: i386 backend fix for multi-register integer return value location
* Sat Sep 18 2010 tonyj@novell.com
- Update to 0.149
- Upstream changelog
  - libdwfl: Fix Linux kernel module search when dwfl_build_id_find_elf and
    dwfl_build_id_find_debuginfo close fd on success
  - readelf: Use symbolic printing for FDE initial_location address
  - readelf: Print .debug_loc/.debug_ranges with cognizance of actual DIE
    pointers into them.
  - readelf: Fix crash in .debug_loc with garbage data.
  - readelf: Fix DW_OP_call_ref printing for version 2 CUs.
  - Handle DW_OP_GNU_implicit_pointer.
  - Add dwfl_dwarf_line, addr2line -F to print out more line info bits.
  - Add missing size entries for ELF_T_LIB and ELF_T_GNUHASH.
  - Fix dwarf_formref_die DW_FORM_ref_sig8 hash table insertion.
  - Consider .gdb_index as a debugging section
  - Misc intendation, typo, translation and cleanup fixes
* Mon Sep 13 2010 coolo@novell.com
- add small patch to avoid crash in systemtap while building preload
* Thu Aug 26 2010 tonyj@suse.de
- Update to 0.148
- Upstream changelog
  - libdw: Accept DWARF 4 format: new functions dwarf_next_unit,
    dwarf_offdie_types.  New functions dwarf_lineisa,
    dwarf_linediscriminator, dwarf_lineop_index.
  - libdwfl: Fixes in core-file handling, support cores from PIEs.
    When working from build IDs, don't open a named file that mismatches.
  - readelf: Handle DWARF 4 formats.
* Mon Jun 28 2010 jengelh@medozas.de
- use %%_smp_mflags
* Tue May 11 2010 tonyj@novell.com
- update to version 0.147 (fix bnc#588293)
- dropped patches for 10.3 and older
- dropped elfutils-0.97-ftruncate-mmap-fix, libelf-ignore-NOBITS, test and
  build patches. According to jbl these were mistakenly checked in from
  home:janblunck:debuginfo:libs/elfutils and the purpose of this project is
  no longer known. Absense of any patch header makes confirmation difficult.
- Upstream changelog:
  0.147
  - libdw: Fixes in CFI handling, best possible handling of bogus CFA
    ops.
  - libdwfl: Ignore R_*_NONE relocs, works around old (binutils) ld -r
    bugs.
  0.146
  - libdwfl: New function dwfl_core_file_report.
  0.145
  - Fix build with --disable-dependency-tracking.
  - Fix build with most recent glibc headers.
  - libelf: More robust to bogus section headers.
  - libdw: Fix CFI decoding.
  - libdwfl: Fix address bias returned by CFI accessors.   Fix core
    file module layout identification.
  - readelf: Fix CFI decoding.
  0.144
  - libelf: New function elf_getphdrnum.  Now support using more than
    65536 program headers in a file.
  - libdw: New function dwarf_aggregate_size for computing (constant)
    type        sizes, including array_type cases with nontrivial
    calculation.
  - readelf: Don't give errors for missing info under -a.
    Handle Linux "VMCOREINFO" notes under -n.
  0.143
  - libdw: Various convenience functions for individual attributes now
    use dwarf_attr_integrate to look up indirect inherited
    attributes.  Location expression handling now supports
    DW_OP_implicit_value.
  - libdwfl: Support automatic decompression of files in XZ format,
    and of Linux kernel images made with bzip2 or LZMA (as well
    as gzip).
* Wed Feb 10 2010 rguenther@suse.de
- Fix uninitialized variable.
* Sat Dec 12 2009 jengelh@medozas.de
- Enable parallel building
- add baselibs.conf as a source
* Thu Aug 20 2009 rguenther@suse.de
- Fix elfutils-old-scanf-fix.diff patch.
* Thu Aug 13 2009 tiwai@suse.de
- updated to 0.142:
  - Fix handling filling caps between sections in libelf
  - Add elf_getshdrnum alias for elf_getshnum and elf_getshdrstrndx
    alias for elf_getshstrndx and deprecate original names.
  - Add support for STB_GNU_UNIQUE
  - Add -N option to readelf, speeds up DWARF printing without
    address->name lookups
  - Add support for decoding DWARF CFI into location description
    form to libdw.
    Some new DWARF 3 expression operations.
    Basic handling of some new encodings slated for DWARF 4.
* Wed Apr 29 2009 tiwai@suse.de
- updated to 0.141:
  - libebl: sparc backend fixes
    some more arm backend support
  - libdwfl: fix dwfl_module_build_id for prelinked DSO case
    fixes in core file support dwfl_module_getsym interface
    improved for non-address symbols
  - eu-strip: fix infinite loop on strange inputs with -f
  - eu-addr2line: take -j/--section=NAME option for binutils
    compatibility (same effect as '(NAME)0x123' syntax already
    supported)
* Thu Feb 19 2009 tiwai@suse.de
- Update to 0.139
  - libcpu: Add Intel SSE4 disassembler support
  - readelf: Implement call frame information and exception
    handling dumping.
    Add -e option.  Enable it implicitly for -a.
  - elflint: Check PT_GNU_EH_FRAME program header entry.
  - libdwfl: Support automatic gzip/bzip2 decompression of ELF
    files.
- updated to 0.140:
  - libelf: Fix regression in creation of section header.
  - Misc bug fixes
* Tue Jan 27 2009 tiwai@suse.de
- revert the ET_DYN address fix patch; causing a regression
  (bnc#468814)
* Wed Jan  7 2009 tiwai@suse.de
- Fix the header size check in dwarf_getsrclines() (bnc#455992)
- Backport the fix for ET_DYN addresses
* Tue Dec 16 2008 tiwai@suse.de
- Fix dwfl_getmodules(), assert in systemtap (bnc#448331)
- Fix libebl1 dependency
- Fix crashes of elfutils binaries, backports from upstream
* Tue Nov 25 2008 tiwai@suse.de
- fix libdwfl regression with realloc DWFL->lookup_module in
  the fix patch (bnc#448331, likely bnc#445783)
* Tue Oct 28 2008 tiwai@suse.de
- added baselibs.conf for 32bit libs (bnc#439582)
* Tue Oct  7 2008 tiwai@suse.de
- renamed to libebl1
- provides libasm1 package
- fix provides and obsolets of libebl1
- updated to version 0.137:
  * libdwfl: bug fixes
* Tue Aug 26 2008 tiwai@suse.de
- updated to version 0.135:
  * libdwfl: bug fixes
- updated to version 0.134:
  * libdwfl, libelf: bug fixes
- updated to version 0.133:
  * readelf, elflint, libebl: SHT_GNU_ATTRIBUTE section handling
    (readelf -A)
  * libdwfl: bug fixes and optimization in relocation handling
- updated to version 0.132:
  * libcpu: Implement x86 and x86-64 disassembler.
  * libasm: Add interface for disassembler.
- fixed post scripts
* Fri Feb 29 2008 dmueller@suse.de
- fix build for older distributions
* Mon Jan 28 2008 tiwai@suse.de
- fix compile errors regarding missing prototypes.
* Tue Nov 20 2007 tiwai@suse.de
- fix off64_t in libelf.h again...
* Tue Nov 20 2007 tiwai@suse.de
- updated to version 0.131
  * libdw: DW_FORM_ref_addr support
    dwarf_formref entry point now deprecated
    bug fixes for oddly-formatted DWARF
  * libdwfl: bug fixes in offline archive support
    apply partial relocations for dwfl_module_address_section
    on ET_REL
  * libebl: powerpc backend support for Altivec registers
* Mon Oct 22 2007 tiwai@suse.de
- fix comiple errors regarding missing off64_t definitions
  in libelf.h
* Mon Oct 22 2007 tiwai@suse.de
- updated to version 0.129:
  readelf: new options --hex-dump (or -x), --strings (or -p)
- updated to version 0.130
  * readelf: -p option can take an argument like -x for one
    section
  * libelf: new function elf_getdata_rawchunk, replaces
    gelf_rawchunk;
    new functions gelf_getnote, gelf_getauxv, gelf_update_auxv
  * libdwfl: new functions dwfl_build_id_find_elf,
    dwfl_build_id_find_debuginfo, dwfl_module_build_id,
    dwfl_module_report_build_id;
    support dynamic symbol tables found via phdrs;
    dwfl_standard_find_debuginfo now uses build IDs when available
  * libebl: backend improvements for sparc, alpha, powerpc
* Thu Oct  4 2007 rguenther@suse.de
- fix build with gcc-4.3, same patch as for the copy in rpm
* Wed Jul  4 2007 tiwai@suse.de
- updated to version 0.128
  * auto-tool fixes
* Sun Jun 10 2007 ro@suse.de
- use __attribute__ ((gnu_inline)) to fix build with gcc-4.2
* Mon May 21 2007 tiwai@suse.de
- initial packages, built from elfutils-0.127.
  A problematic file regarding the license is removed from the
  tarball.