build 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. #!/bin/bash
  2. [% c("var/set_default_env") -%]
  3. distdir=/var/tmp/dist/binutils
  4. [% IF c("var/linux") %]
  5. # Config options for hardening-wrapper
  6. export DEB_BUILD_HARDENING=1
  7. export DEB_BUILD_HARDENING_STACKPROTECTOR=1
  8. export DEB_BUILD_HARDENING_FORTIFY=1
  9. export DEB_BUILD_HARDENING_FORMAT=1
  10. export DEB_BUILD_HARDENING_PIE=1
  11. [% END %]
  12. tar xf [% project %]-[% c("version") %].tar.xz
  13. cd [% project %]-[% c("version") %]
  14. ./configure --prefix=$distdir [% c('var/configure_opt') %]
  15. make -j[% c("buildconf/num_procs") %]
  16. make install
  17. [% IF c("var/linux") && ! c("var/linux-cross") %]
  18. # Make sure gold is used with the hardening wrapper for full RELRO, see #13031.
  19. cd $distdir/bin
  20. rm ld
  21. cp /usr/bin/hardened-ld ./
  22. mv ld.gold ld.gold.real
  23. ln -sf hardened-ld ld.gold
  24. ln -sf ld.gold ld
  25. [% END %]
  26. [% IF c("var/linux-cross") && 0 %]
  27. # gold is disabled for cross-compiles, because of
  28. # https://sourceware.org/bugzilla/show_bug.cgi?id=14995
  29. # Once we upgrade to glibc 2.26 and binutils 2.28, we should be able to
  30. # re-introduce gold for cross-compiles.
  31. # Make sure gold is used with the hardening wrapper for full RELRO, see #13031.
  32. # First do the filename-prefixed ones...
  33. cd $distdir/bin
  34. rm [% c('var/crosstarget') %]-ld
  35. cp /usr/bin/hardened-ld ./
  36. mv [% c('var/crosstarget') %]-ld.gold [% c('var/crosstarget') %]-ld.gold.real
  37. ln -sf hardened-ld [% c('var/crosstarget') %]-ld.gold
  38. ln -sf [% c('var/crosstarget') %]-ld.gold [% c('var/crosstarget') %]-ld
  39. # Then do the directory-prefixed ones...
  40. cd $distdir/[% c('var/crosstarget') %]/bin
  41. rm ld
  42. cp /usr/bin/hardened-ld ./
  43. mv ld.gold ld.gold.real
  44. ln -sf hardened-ld ld.gold
  45. ln -sf ld.gold ld
  46. [% END %]
  47. cd /var/tmp/dist
  48. [% c('tar', {
  49. tar_src => [ project ],
  50. tar_args => '-czf ' _ dest_dir _ '/' _ c('filename'),
  51. }) %]