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