Merge branch 'master' into core-updates
[jackhill/guix/guix.git] / gnu / packages / elf.scm
1 ;;; GNU Guix --- Functional package management for GNU
2 ;;; Copyright © 2013, 2014, 2015 Ludovic Courtès <ludo@gnu.org>
3 ;;; Copyright © 2014, 2015 Mark H Weaver <mhw@netris.org>
4 ;;; Copyright © 2015 Andreas Enge <andreas@enge.fr>
5 ;;; Copyright © 2017, 2018, 2019 Efraim Flashner <efraim@flashner.co.il>
6 ;;; Copyright © 2017 Leo Famulari <leo@famulari.name>
7 ;;; Copyright © 2018 Tobias Geerinckx-Rice <me@tobias.gr>
8 ;;; Copyright © 2018 Marius Bakke <mbakke@fastmail.com>
9 ;;; Copyright © 2020 Mark Wielaard <mark@klomp.org>
10 ;;;
11 ;;; This file is part of GNU Guix.
12 ;;;
13 ;;; GNU Guix is free software; you can redistribute it and/or modify it
14 ;;; under the terms of the GNU General Public License as published by
15 ;;; the Free Software Foundation; either version 3 of the License, or (at
16 ;;; your option) any later version.
17 ;;;
18 ;;; GNU Guix is distributed in the hope that it will be useful, but
19 ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
20 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 ;;; GNU General Public License for more details.
22 ;;;
23 ;;; You should have received a copy of the GNU General Public License
24 ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
25
26 (define-module (gnu packages elf)
27 #:use-module (guix utils)
28 #:use-module (guix packages)
29 #:use-module (guix download)
30 #:use-module (guix build-system gnu)
31 #:use-module ((guix licenses) #:select (gpl3+ lgpl3+ lgpl2.0+))
32 #:use-module (gnu packages)
33 #:use-module (gnu packages compression)
34 #:use-module (gnu packages documentation)
35 #:use-module (gnu packages gcc)
36 #:use-module (gnu packages m4)
37 #:use-module (gnu packages pkg-config)
38 #:use-module (gnu packages python)
39 #:use-module (gnu packages sphinx)
40 #:use-module (gnu packages texinfo)
41 #:use-module (gnu packages xml))
42
43 (define-public elfutils
44 (package
45 (name "elfutils")
46 (version "0.176")
47 (source (origin
48 (method url-fetch)
49 (uri (string-append "https://sourceware.org/elfutils/ftp/"
50 version "/elfutils-" version ".tar.bz2"))
51 (sha256
52 (base32
53 "08qhrl4g6qqr4ga46jhh78y56a47p3msa5b2x1qhzbxhf71lfmzb"))
54 (patches (search-patches "elfutils-tests-ptrace.patch"))))
55 (build-system gnu-build-system)
56
57 ;; Separate programs because that's usually not what elfutils users want,
58 ;; and because they duplicate what Binutils provides (but are named
59 ;; differently, using the eu- prefix and can be installed in parallel).
60 (outputs '("out" ; libelf.so, elfutils/*.h, etc.
61 "bin")) ; eu-nm, eu-objdump, etc.
62
63 (arguments
64 ;; Programs don't have libelf.so in their RUNPATH and libraries don't
65 ;; know where to find each other.
66 `(#:configure-flags (list (string-append "LDFLAGS=-Wl,-rpath="
67 (assoc-ref %outputs "out")
68 "/lib"))
69
70 ;; Disable tests on MIPS (without changing
71 ;; the arguments list on other systems).
72 ,@(if (string-prefix? "mips" (or (%current-target-system)
73 (%current-system)))
74 '(#:tests? #f)
75 '())
76
77 #:phases
78 (modify-phases %standard-phases
79 ;; No reason has been found for this test to reliably fail on aarch64-linux.
80 (add-after 'unpack 'disable-failing-aarch64-tests
81 (lambda _
82 (substitute* "tests/Makefile.in"
83 (("run-backtrace-native.sh") ""))
84 #t)))))
85
86 (native-inputs `(("m4" ,m4)))
87 (inputs `(("zlib" ,zlib)))
88 (home-page "https://sourceware.org/elfutils/")
89 (synopsis "Collection of utilities and libraries to handle ELF files and
90 DWARF data")
91 (description
92 "Elfutils is a collection of utilities and libraries to read, create and
93 modify Executable and Linkable Format (@dfn{ELF}) binary files, find and
94 handle Debugging With Arbitrary Record Formats (@dfn{DWARF}) debug data,
95 symbols, thread state and stacktraces for processes and core files on
96 GNU/Linux. Elfutils includes @file{libelf} for manipulating ELF files,
97 @file{libdw} for inspecting DWARF data and process state and utilities like
98 @command{eu-stack} (to show backtraces), @command{eu-nm} (for listing symbols
99 from object files), @command{eu-size} (for listing the section sizes of an
100 object or archive file), @command{eu-strip} (for discarding symbols),
101 @command{eu-readelf} (to see the raw ELF file structures),
102 @command{eu-elflint} (to check for well-formed ELF files),
103 @command{eu-elfcompress} (to compress or decompress ELF sections), and more.")
104
105 ;; Libraries are dual-licensed LGPLv3.0+ | GPLv2, and programs are GPLv3+.
106 (license lgpl3+)))
107
108 (define-public libabigail
109 (package
110 (name "libabigail")
111 (home-page "https://sourceware.org/libabigail/")
112 (version "1.6")
113 (source (origin
114 (method url-fetch)
115 (uri (string-append "https://sourceware.org/pub/libabigail/"
116 "libabigail-" version ".tar.gz"))
117 (sha256
118 (base32
119 "04j07lhvwbp6qp8pdwbf7iqnr7kgpabmqylsw4invpmzwnyp6g6g"))))
120 (build-system gnu-build-system)
121 (arguments
122 `(#:configure-flags '("--disable-static"
123 "--enable-bash-completion"
124 "--enable-manual")
125 #:make-flags '("V=1")
126 #:phases (modify-phases %standard-phases
127 (add-after 'unpack 'patch-source
128 (lambda _
129 (substitute* "build-aux/ltmain.sh"
130 ;; Don't add -specs=/usr/lib/rpm/redhat/redhat-hardened-ld
131 ;; to the GCC command line.
132 (("compiler_flags=\"-specs=.*")
133 "compiler_flags=\n"))
134 #t))
135 (add-after 'build 'build-documentation
136 (lambda _
137 (invoke "make" "-C" "doc/manuals" "html-doc" "man" "info")))
138 (add-before 'check 'set-test-environment
139 (lambda _
140 (setenv "XDG_CACHE_HOME" "/tmp")
141 #t))
142 (add-after 'install 'install-documentation
143 (lambda _
144 (invoke "make" "-C" "doc/manuals"
145 "install-man-and-info-doc")))
146 (add-after 'install-documentation 'install-bash-completion
147 (lambda* (#:key outputs #:allow-other-keys)
148 (for-each (lambda (file)
149 (install-file
150 file (string-append (assoc-ref outputs "out")
151 "/share/bash-completion"
152 "/completions")))
153 (find-files "bash-completion" ".*abi.*"))
154 #t)))))
155 (native-inputs
156 `(("pkg-config" ,pkg-config)
157 ("makeinfo" ,texinfo)
158 ("python-sphinx" ,python-sphinx)
159 ("python" ,python))) ;for tests
160 (propagated-inputs
161 `(("elfutils" ,elfutils) ;libabigail.la says -lelf
162 ("libxml2" ,libxml2))) ;in Requires.private of libabigail.pc
163 (synopsis "Analyze application binary interfaces (ABIs)")
164 (description
165 "@dfn{ABIGAIL} stands for the Application Binary Interface Generic
166 Analysis and Instrumentation Library. It is a framework which aims at
167 helping developers and software distributors to spot ABI-related issues
168 like interface incompatibility in ELF shared libraries by performing a
169 static analysis of the ELF binaries at hand.")
170 (license lgpl3+)))
171
172 (define-public libelf
173 (package
174 (name "libelf")
175 (version "0.8.13")
176 (source
177 (origin
178 (method url-fetch)
179 (uri (list
180 ;; As of May 2019, the original URL at mr511.de redirects to a
181 ;; domain that doesn't resolve. Use these two mirrors instead.
182 (string-append "https://fossies.org/linux/misc/old/"
183 "libelf-" version ".tar.gz")
184 (string-append "https://ftp.osuosl.org/pub/blfs/conglomeration/"
185 "libelf/libelf-" version ".tar.gz")))
186 (sha256
187 (base32
188 "0vf7s9dwk2xkmhb79aigqm0x0yfbw1j0b9ksm51207qwr179n6jr"))))
189 (build-system gnu-build-system)
190 (arguments
191 `(#:phases
192 (modify-phases %standard-phases
193 (replace 'configure
194 (lambda* (#:key outputs #:allow-other-keys)
195 ;; This old `configure' script doesn't support
196 ;; variables passed as arguments.
197 (let ((out (assoc-ref outputs "out")))
198 (setenv "CONFIG_SHELL" (which "bash"))
199 (invoke "./configure"
200 (string-append "--prefix=" out)
201 ,@(if (string=? "aarch64-linux"
202 (%current-system))
203 '("--host=aarch64-unknown-linux-gnu")
204 '()))))))))
205 (home-page (string-append "https://web.archive.org/web/20181111033959/"
206 "http://www.mr511.de/software/english.html"))
207 (synopsis "ELF object file access library")
208 (description "Libelf is a C library to access ELF object files.")
209 (license lgpl2.0+)))
210
211 (define-public patchelf
212 (package
213 (name "patchelf")
214 (version "0.10")
215 (source (origin
216 (method url-fetch)
217 (uri (string-append
218 "https://nixos.org/releases/patchelf/patchelf-"
219 version
220 "/patchelf-" version ".tar.bz2"))
221 (sha256
222 (base32
223 "1wzwvnlyf853hw9zgqq5522bvf8gqadk8icgqa41a5n7593csw7n"))))
224 (build-system gnu-build-system)
225 (arguments
226 '(#:phases
227 (modify-phases %standard-phases
228 (add-after 'unpack 'fix-tests
229 ;; Our GCC code ensures that RUNPATH is never empty, it includes
230 ;; at least glibc/lib and gcc:lib/lib.
231 (lambda* (#:key inputs #:allow-other-keys)
232 (substitute* "tests/no-rpath.sh"
233 ;; Disable checking for an empty runpath:
234 (("^if test.*") "")
235 ;; Find libgcc_s.so, which is necessary for the test:
236 (("/xxxxxxxxxxxxxxx") (string-append (assoc-ref inputs "gcc:lib")
237 "/lib")))
238 #t)))))
239 (native-inputs
240 `(("gcc:lib" ,gcc "lib")))
241 (home-page "https://nixos.org/patchelf.html")
242 (synopsis "Modify the dynamic linker and RPATH of ELF executables")
243 (description
244 "PatchELF allows the ELF \"interpreter\" and RPATH of an ELF binary to be
245 changed.")
246 (license gpl3+)))