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