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