elf.scm 9.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231
  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. ;;; 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. (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 compression)
  32. #:use-module (gnu packages documentation)
  33. #:use-module (gnu packages m4)
  34. #:use-module (gnu packages pkg-config)
  35. #:use-module (gnu packages python)
  36. #:use-module (gnu packages python-xyz)
  37. #:use-module (gnu packages texinfo)
  38. #:use-module (gnu packages xml))
  39. (define-public elfutils
  40. (package
  41. (name "elfutils")
  42. (version "0.173")
  43. (source (origin
  44. (method url-fetch)
  45. (uri (string-append "https://sourceware.org/elfutils/ftp/"
  46. version "/elfutils-" version ".tar.bz2"))
  47. (sha256
  48. (base32
  49. "1zq0l12k64hrbjmdjc4llrad96c25i427hpma1id9nk87w9qqvdp"))
  50. (patches (search-patches "elfutils-tests-ptrace.patch"))))
  51. (build-system gnu-build-system)
  52. ;; Separate programs because that's usually not what elfutils users want,
  53. ;; and because they duplicate what Binutils provides.
  54. (outputs '("out" ; libelf.so, elfutils/*.h, etc.
  55. "bin")) ; ld, nm, objdump, etc.
  56. (arguments
  57. ;; Programs don't have libelf.so in their RUNPATH and libraries don't
  58. ;; know where to find each other.
  59. `(#:configure-flags (list (string-append "LDFLAGS=-Wl,-rpath="
  60. (assoc-ref %outputs "out")
  61. "/lib"))
  62. ;; Disable tests on MIPS (without changing
  63. ;; the arguments list on other systems).
  64. ,@(if (string-prefix? "mips" (or (%current-target-system)
  65. (%current-system)))
  66. '(#:tests? #f)
  67. '())
  68. #:phases
  69. (modify-phases %standard-phases
  70. ;; No reason has been found for this test to reliably fail on aarch64-linux.
  71. (add-after 'unpack 'disable-failing-aarch64-tests
  72. (lambda _
  73. (substitute* "tests/Makefile.in"
  74. (("run-backtrace-native.sh") ""))
  75. #t)))))
  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. ;; Libraries are dual-licensed LGPLv3.0+ | GPLv2, and programs are GPLv3+.
  85. (license lgpl3+)))
  86. (define-public libabigail
  87. (package
  88. (name "libabigail")
  89. (home-page "https://sourceware.org/libabigail/")
  90. (version "1.5")
  91. (source (origin
  92. (method url-fetch)
  93. (uri (string-append "https://sourceware.org/pub/" name
  94. "/" name "-" version ".tar.gz"))
  95. (sha256
  96. (base32
  97. "0srfnkbm386sl2n85686nl28da6ksbs7jgnfks9k0n61c772aas4"))))
  98. (build-system gnu-build-system)
  99. (arguments
  100. `(#:configure-flags '("--disable-static"
  101. "--enable-bash-completion"
  102. "--enable-manual")
  103. #:make-flags '("V=1")
  104. #:phases (modify-phases %standard-phases
  105. (add-after 'unpack 'patch-source
  106. (lambda _
  107. (substitute* "build-aux/ltmain.sh"
  108. ;; Don't add -specs=/usr/lib/rpm/redhat/redhat-hardened-ld
  109. ;; to the GCC command line.
  110. (("compiler_flags=\"-specs=.*")
  111. "compiler_flags=\n"))
  112. #t))
  113. (add-after 'build 'build-documentation
  114. (lambda _
  115. (invoke "make" "-C" "doc/manuals" "html-doc" "man" "info")))
  116. (add-before 'check 'set-test-environment
  117. (lambda _
  118. (setenv "XDG_CACHE_HOME" "/tmp")
  119. #t))
  120. (add-after 'install 'install-documentation
  121. (lambda _
  122. (invoke "make" "-C" "doc/manuals"
  123. "install-man-and-info-doc")))
  124. (add-after 'install-documentation 'install-bash-completion
  125. (lambda* (#:key outputs #:allow-other-keys)
  126. (for-each (lambda (file)
  127. (install-file
  128. file (string-append (assoc-ref outputs "out")
  129. "/share/bash-completion"
  130. "/completions")))
  131. (find-files "bash-completion" ".*abi.*"))
  132. #t)))))
  133. (native-inputs
  134. `(("pkg-config" ,pkg-config)
  135. ("makeinfo" ,texinfo)
  136. ("python-sphinx" ,python-sphinx)
  137. ("python" ,python))) ;for tests
  138. (propagated-inputs
  139. `(("elfutils" ,elfutils) ;libabigail.la says -lelf
  140. ("libxml2" ,libxml2))) ;in Requires.private of libabigail.pc
  141. (synopsis "Analyze application binary interfaces (ABIs)")
  142. (description
  143. "@dfn{ABIGAIL} stands for the Application Binary Interface Generic
  144. Analysis and Instrumentation Library. It is a framework which aims at
  145. helping developers and software distributors to spot ABI-related issues
  146. like interface incompatibility in ELF shared libraries by performing a
  147. static analysis of the ELF binaries at hand.")
  148. (license lgpl3+)))
  149. (define-public libelf
  150. (package
  151. (name "libelf")
  152. (version "0.8.13")
  153. (source (origin
  154. (method url-fetch)
  155. (uri (string-append "http://www.mr511.de/software/libelf-"
  156. version ".tar.gz"))
  157. (sha256
  158. (base32
  159. "0vf7s9dwk2xkmhb79aigqm0x0yfbw1j0b9ksm51207qwr179n6jr"))))
  160. (build-system gnu-build-system)
  161. (arguments
  162. `(#:phases
  163. (modify-phases %standard-phases
  164. (replace 'configure
  165. (lambda* (#:key outputs #:allow-other-keys)
  166. ;; This old `configure' script doesn't support
  167. ;; variables passed as arguments.
  168. (let ((out (assoc-ref outputs "out")))
  169. (setenv "CONFIG_SHELL" (which "bash"))
  170. (invoke "./configure"
  171. (string-append "--prefix=" out)
  172. ,@(if (string=? "aarch64-linux"
  173. (%current-system))
  174. '("--host=aarch64-unknown-linux-gnu")
  175. '()))))))))
  176. (home-page "http://www.mr511.de/software/english.html")
  177. (synopsis "ELF object file access library")
  178. (description "Libelf is a C library to access ELF object files.")
  179. (license lgpl2.0+)))
  180. (define-public patchelf
  181. (package
  182. (name "patchelf")
  183. (version "0.8")
  184. (source (origin
  185. (method url-fetch)
  186. (uri (string-append
  187. "https://nixos.org/releases/patchelf/patchelf-"
  188. version
  189. "/patchelf-" version ".tar.bz2"))
  190. (sha256
  191. (base32
  192. "1rqpg84wrd3fa16wa9vqdvasnc05yz49w207cz1l0wrl4k8q97y9"))
  193. (patches (search-patches "patchelf-page-size.patch"))))
  194. (build-system gnu-build-system)
  195. ;; XXX: The upstream 'patchelf' doesn't support ARM. The only available
  196. ;; patch makes significant changes to the algorithm, possibly
  197. ;; introducing bugs. So, we apply the patch only on ARM systems.
  198. (inputs
  199. (if (target-arm32?)
  200. `(("patch/rework-for-arm" ,(search-patch
  201. "patchelf-rework-for-arm.patch")))
  202. '()))
  203. (arguments
  204. (if (target-arm32?)
  205. `(#:phases
  206. (modify-phases %standard-phases
  207. (add-after 'unpack 'patch/rework-for-arm
  208. (lambda* (#:key inputs #:allow-other-keys)
  209. (let ((patch-file (assoc-ref inputs "patch/rework-for-arm")))
  210. (invoke "patch" "--force" "-p1" "--input" patch-file))))))
  211. '()))
  212. (home-page "https://nixos.org/patchelf.html")
  213. (synopsis "Modify the dynamic linker and RPATH of ELF executables")
  214. (description
  215. "PatchELF allows the ELF \"interpreter\" and RPATH of an ELF binary to be
  216. changed.")
  217. (license gpl3+)))