summary refs log tree commit diff
diff options
context:
space:
mode:
authorOrivej Desh <orivej@gmx.fr>2017-11-19 03:30:43 +0000
committerOrivej Desh <orivej@gmx.fr>2017-11-19 03:36:53 +0000
commitc76890f2fe24ca64bc216515149f7316080912f0 (patch)
treef26aabfc2908e3805d25261879f57597e3d86d72
parentd4d7e1ea09642aa6ca8388de735efadd3c2c38d8 (diff)
downloadnixpkgs-c76890f2fe24ca64bc216515149f7316080912f0.tar
nixpkgs-c76890f2fe24ca64bc216515149f7316080912f0.tar.gz
nixpkgs-c76890f2fe24ca64bc216515149f7316080912f0.tar.bz2
nixpkgs-c76890f2fe24ca64bc216515149f7316080912f0.tar.lz
nixpkgs-c76890f2fe24ca64bc216515149f7316080912f0.tar.xz
nixpkgs-c76890f2fe24ca64bc216515149f7316080912f0.tar.zst
nixpkgs-c76890f2fe24ca64bc216515149f7316080912f0.zip
binutils: disambiguate ARM targets
https://github.com/NixOS/nixpkgs/pull/30484#issuecomment-345472766

Since [1] libbfd is compiled with support for all available targets. However, it
can not choose whether an ARM ELF file is elf32-littlearm,
elf32-littlearm-symbian, or elf32-littlearm-vxworks, and fails with the "File
format is ambiguous" error.  Here [2] Alan Modra intended to prioritize the
first of the three, but although his patch was merged and reportedly solved the
issue, currently glibc 2.28.1 and 2.29.1 again fail to disambiguate these
targets.  This commit makes it prioritize elf32-littlearm over the other two.

[1] f8741c38cd546e3ff18ce9d708de14ff2aae68ab
[2] https://sourceware.org/ml/binutils/2013-05/msg00271.html
-rw-r--r--pkgs/development/tools/misc/binutils/default.nix5
-rw-r--r--pkgs/development/tools/misc/binutils/disambiguate-arm-targets.patch23
2 files changed, 28 insertions, 0 deletions
diff --git a/pkgs/development/tools/misc/binutils/default.nix b/pkgs/development/tools/misc/binutils/default.nix
index 83982b1376e..8e44a982067 100644
--- a/pkgs/development/tools/misc/binutils/default.nix
+++ b/pkgs/development/tools/misc/binutils/default.nix
@@ -48,6 +48,11 @@ stdenv.mkDerivation rec {
     # there) and causes a cycle between the lib and bin outputs, so
     # get rid of it.
     ./no-plugins.patch
+
+    # Help bfd choose between elf32-littlearm, elf32-littlearm-symbian, and
+    # elf32-littlearm-vxworks in favor of the first.
+    # https://github.com/NixOS/nixpkgs/pull/30484#issuecomment-345472766
+    ./disambiguate-arm-targets.patch
   ];
 
   outputs = [ "out" "info" ];
diff --git a/pkgs/development/tools/misc/binutils/disambiguate-arm-targets.patch b/pkgs/development/tools/misc/binutils/disambiguate-arm-targets.patch
new file mode 100644
index 00000000000..abbfa73da05
--- /dev/null
+++ b/pkgs/development/tools/misc/binutils/disambiguate-arm-targets.patch
@@ -0,0 +1,23 @@
+diff --git a/bfd/elf32-arm.c b/bfd/elf32-arm.c
+index 9f956d3..f5b61f1 100644
+--- a/bfd/elf32-arm.c
++++ b/bfd/elf32-arm.c
+@@ -19585,7 +19585,10 @@ elf32_arm_vxworks_final_write_processing (bfd *abfd, bfd_boolean linker)
+ #undef  ELF_MAXPAGESIZE
+ #define ELF_MAXPAGESIZE			0x1000
+ 
++/* Prioritize elf32-*arm (priority 1) over elf32-*arm-vxworks (priority 2) */
++#define elf_match_priority 2
+ #include "elf32-target.h"
++#undef  elf_match_priority
+ 
+ 
+ /* Merge backend specific data from an object file to the output
+@@ -19974,4 +19977,7 @@ elf32_arm_symbian_plt_sym_val (bfd_vma i, const asection *plt,
+ #undef  ELF_MAXPAGESIZE
+ #define ELF_MAXPAGESIZE			0x8000
+ 
++/* Prioritize elf32-*arm (priority 1) over elf32-*arm-symbian (priority 2) */
++#define elf_match_priority 2
+ #include "elf32-target.h"
++#undef  elf_match_priority