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 #:phases
60 (modify-phases %standard-phases
61 ;; No reason has been found for this test to reliably fail on aarch64-linux.
62 (add-after 'unpack 'disable-failing-aarch64-tests
63 (lambda _
64 (substitute* "tests/Makefile.in"
65 (("run-backtrace-native.sh") ""))
66 #t)))))
67
68 (native-inputs `(("m4" ,m4)))
69 (inputs `(("zlib" ,zlib)))
70 (home-page "https://sourceware.org/elfutils/")
71 (synopsis "Linker and ELF manipulation tools")
72 (description
73 "This package provides command-line tools to manipulate binaries in the
74 Executable and Linkable Format (@dfn{ELF}). This includes @command{ld},
75 @command{ar}, @command{objdump}, @command{addr2line}, and more.")
76
77 ;; Libraries are dual-licensed LGPLv3.0+ | GPLv2, and programs are GPLv3+.
78 (license lgpl3+)))
79
80 (define-public libelf
81 (package
82 (name "libelf")
83 (version "0.8.13")
84 (source (origin
85 (method url-fetch)
86 (uri (string-append "http://www.mr511.de/software/libelf-"
87 version ".tar.gz"))
88 (sha256
89 (base32
90 "0vf7s9dwk2xkmhb79aigqm0x0yfbw1j0b9ksm51207qwr179n6jr"))))
91 (build-system gnu-build-system)
92 (arguments
93 `(#:phases
94 (modify-phases %standard-phases
95 (replace 'configure
96 (lambda* (#:key outputs #:allow-other-keys)
97 ;; This old `configure' script doesn't support
98 ;; variables passed as arguments.
99 (let ((out (assoc-ref outputs "out")))
100 (setenv "CONFIG_SHELL" (which "bash"))
101 (invoke "./configure"
102 (string-append "--prefix=" out)
103 ,@(if (string=? "aarch64-linux"
104 (%current-system))
105 '("--host=aarch64-unknown-linux-gnu")
106 '()))))))))
107 (home-page "http://www.mr511.de/software/english.html")
108 (synopsis "ELF object file access library")
109 (description "Libelf is a C library to access ELF object files.")
110 (license lgpl2.0+)))
111
112 (define-public patchelf
113 (package
114 (name "patchelf")
115 (version "0.8")
116 (source (origin
117 (method url-fetch)
118 (uri (string-append
119 "https://nixos.org/releases/patchelf/patchelf-"
120 version
121 "/patchelf-" version ".tar.bz2"))
122 (sha256
123 (base32
124 "1rqpg84wrd3fa16wa9vqdvasnc05yz49w207cz1l0wrl4k8q97y9"))
125 (patches (search-patches "patchelf-page-size.patch"))))
126 (build-system gnu-build-system)
127
128 ;; XXX: The upstream 'patchelf' doesn't support ARM. The only available
129 ;; patch makes significant changes to the algorithm, possibly
130 ;; introducing bugs. So, we apply the patch only on ARM systems.
131 (inputs
132 (if (target-arm32?)
133 `(("patch/rework-for-arm" ,(search-patch
134 "patchelf-rework-for-arm.patch")))
135 '()))
136 (arguments
137 (if (target-arm32?)
138 `(#:phases
139 (modify-phases %standard-phases
140 (add-after 'unpack 'patch/rework-for-arm
141 (lambda* (#:key inputs #:allow-other-keys)
142 (let ((patch-file (assoc-ref inputs "patch/rework-for-arm")))
143 (invoke "patch" "--force" "-p1" "--input" patch-file))))))
144 '()))
145
146 (home-page "https://nixos.org/patchelf.html")
147 (synopsis "Modify the dynamic linker and RPATH of ELF executables")
148 (description
149 "PatchELF allows the ELF \"interpreter\" and RPATH of an ELF binary to be
150 changed.")
151 (license gpl3+)))