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 Efraim Flashner <efraim@flashner.co.il>
6 ;;; Copyright © 2017 Leo Famulari <leo@famulari.name>
7 ;;; Copyright © 2018 Tobias Geerinckx-Rice <me@tobias.gr>
8 ;;;
9 ;;; This file is part of GNU Guix.
10 ;;;
11 ;;; GNU Guix is free software; you can redistribute it and/or modify it
12 ;;; under the terms of the GNU General Public License as published by
13 ;;; the Free Software Foundation; either version 3 of the License, or (at
14 ;;; your option) any later version.
15 ;;;
16 ;;; GNU Guix is distributed in the hope that it will be useful, but
17 ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
18 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 ;;; GNU General Public License for more details.
20 ;;;
21 ;;; You should have received a copy of the GNU General Public License
22 ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
23
24 (define-module (gnu packages elf)
25 #:use-module (guix utils)
26 #:use-module (guix packages)
27 #:use-module (guix download)
28 #:use-module (guix build-system gnu)
29 #:use-module ((guix licenses) #:select (gpl3+ lgpl3+ lgpl2.0+))
30 #:use-module (gnu packages)
31 #:use-module (gnu packages m4)
32 #:use-module (gnu packages compression))
33
34 (define-public elfutils
35 (package
36 (name "elfutils")
37 (version "0.170")
38 (source (origin
39 (method url-fetch)
40 (uri (string-append "https://sourceware.org/elfutils/ftp/"
41 version "/elfutils-" version ".tar.bz2"))
42 (sha256
43 (base32
44 "0rp0r54z44is49c594qy7hr211nhb00aa5y7z74vsybbaxslg10z"))
45 (patches (search-patches "elfutils-tests-ptrace.patch"))))
46 (build-system gnu-build-system)
47
48 ;; Separate programs because that's usually not what elfutils users want,
49 ;; and because they duplicate what Binutils provides.
50 (outputs '("out" ; libelf.so, elfutils/*.h, etc.
51 "bin")) ; ld, nm, objdump, etc.
52
53 (arguments
54 ;; Programs don't have libelf.so in their RUNPATH and libraries don't
55 ;; know where to find each other.
56 `(#:configure-flags (list (string-append "LDFLAGS=-Wl,-rpath="
57 (assoc-ref %outputs "out")
58 "/lib"))
59
60 ;; Disable tests on MIPS (without changing
61 ;; the arguments list on other systems).
62 ,@(if (string-prefix? "mips" (or (%current-target-system)
63 (%current-system)))
64 '(#:tests? #f)
65 '())
66
67 #:phases
68 (modify-phases %standard-phases
69 ;; No reason has been found for this test to reliably fail on aarch64-linux.
70 (add-after 'unpack 'disable-failing-aarch64-tests
71 (lambda _
72 (substitute* "tests/Makefile.in"
73 (("run-backtrace-native.sh") ""))
74 #t)))))
75
76 (native-inputs `(("m4" ,m4)))
77 (inputs `(("zlib" ,zlib)))
78 (home-page "https://sourceware.org/elfutils/")
79 (synopsis "Linker and ELF manipulation tools")
80 (description
81 "This package provides command-line tools to manipulate binaries in the
82 Executable and Linkable Format (@dfn{ELF}). This includes @command{ld},
83 @command{ar}, @command{objdump}, @command{addr2line}, and more.")
84
85 ;; Libraries are dual-licensed LGPLv3.0+ | GPLv2, and programs are GPLv3+.
86 (license lgpl3+)))
87
88 (define-public libelf
89 (package
90 (name "libelf")
91 (version "0.8.13")
92 (source (origin
93 (method url-fetch)
94 (uri (string-append "http://www.mr511.de/software/libelf-"
95 version ".tar.gz"))
96 (sha256
97 (base32
98 "0vf7s9dwk2xkmhb79aigqm0x0yfbw1j0b9ksm51207qwr179n6jr"))))
99 (build-system gnu-build-system)
100 (arguments
101 `(#:phases
102 (modify-phases %standard-phases
103 (replace 'configure
104 (lambda* (#:key outputs #:allow-other-keys)
105 ;; This old `configure' script doesn't support
106 ;; variables passed as arguments.
107 (let ((out (assoc-ref outputs "out")))
108 (setenv "CONFIG_SHELL" (which "bash"))
109 (invoke "./configure"
110 (string-append "--prefix=" out)
111 ,@(if (string=? "aarch64-linux"
112 (%current-system))
113 '("--host=aarch64-unknown-linux-gnu")
114 '()))))))))
115 (home-page "http://www.mr511.de/software/english.html")
116 (synopsis "ELF object file access library")
117 (description "Libelf is a C library to access ELF object files.")
118 (license lgpl2.0+)))
119
120 (define-public patchelf
121 (package
122 (name "patchelf")
123 (version "0.8")
124 (source (origin
125 (method url-fetch)
126 (uri (string-append
127 "https://nixos.org/releases/patchelf/patchelf-"
128 version
129 "/patchelf-" version ".tar.bz2"))
130 (sha256
131 (base32
132 "1rqpg84wrd3fa16wa9vqdvasnc05yz49w207cz1l0wrl4k8q97y9"))
133 (patches (search-patches "patchelf-page-size.patch"))))
134 (build-system gnu-build-system)
135
136 ;; XXX: The upstream 'patchelf' doesn't support ARM. The only available
137 ;; patch makes significant changes to the algorithm, possibly
138 ;; introducing bugs. So, we apply the patch only on ARM systems.
139 (inputs
140 (if (target-arm32?)
141 `(("patch/rework-for-arm" ,(search-patch
142 "patchelf-rework-for-arm.patch")))
143 '()))
144 (arguments
145 (if (target-arm32?)
146 `(#:phases
147 (modify-phases %standard-phases
148 (add-after 'unpack 'patch/rework-for-arm
149 (lambda* (#:key inputs #:allow-other-keys)
150 (let ((patch-file (assoc-ref inputs "patch/rework-for-arm")))
151 (invoke "patch" "--force" "-p1" "--input" patch-file))))))
152 '()))
153
154 (home-page "https://nixos.org/patchelf.html")
155 (synopsis "Modify the dynamic linker and RPATH of ELF executables")
156 (description
157 "PatchELF allows the ELF \"interpreter\" and RPATH of an ELF binary to be
158 changed.")
159 (license gpl3+)))