initial import
[patches.git] / binutils-freebsd-sparc64-support.patch
CommitLineData
5e993f12 12006-10-17 Roy Marples <uberlord@gentoo.org>
2
3 * bfd/elf64-sparc.c: Add FreeBSD support.
4 (elf64_sparc_fbsd_post_process_headers): New function.
5 * bfd/targets.c (_bfd_target_vector): Add bfd_elf64_sparc_freebsd_vec.
6 * bfd/config.bfd (sparc64-*-freebsd*): Set targ_defvec to bfd_elf64_sparc_freebsd_vec.
7 * bfd/configure.in: Add entry for bfd_elf64_sparc_freebsd_vec.
8 * bfd/configure: Regenerate.
9 * gas/config/tc-sparc.c (md_parse_option): Treat any target starting with elf32-sparc
10 as a viable target for the -32 switch and any target starting with elf64-sparc as a
11 viable target for the -64 switch.
12 (sparc_target_format): For 64-bit ELF flavoured output use ELF_TARGET_FORMAT64
13 while for 32-bit ELF flavoured output use ELF_TARGET_FORMAT.
14 * gas/config/tc-sparc.h (ELF_TARGET_FORMAT, ELF_TARGET_FORMAT64): Define.
15 * ld/emulparams/elf64_sparc_fbsd.sh (OUTPUT_FORMAT): Define as elf64-sparc-freebsd.
16
17--- bfd/elf64-sparc.c
18+++ bfd/elf64-sparc.c
19@@ -902,3 +902,33 @@ const struct elf_size_info elf64_sparc_s
20 #define elf_backend_plt_alignment 8
21
22 #include "elf64-target.h"
23+
24+/* FreeBSD support */
25+#undef TARGET_BIG_SYM
26+#define TARGET_BIG_SYM bfd_elf64_sparc_freebsd_vec
27+#undef TARGET_BIG_NAME
28+#define TARGET_BIG_NAME "elf64-sparc-freebsd"
29+
30+/* The kernel recognizes executables as valid only if they carry a
31+ "FreeBSD" label in the ELF header. So we put this label on all
32+ executables and (for simplicity) also all other object files. */
33+
34+static void
35+elf64_sparc_fbsd_post_process_headers (bfd *abfd,
36+ struct bfd_link_info *info ATTRIBUTE_UNUSED)
37+{
38+ Elf_Internal_Ehdr *i_ehdrp; /* ELF file header, internal form. */
39+
40+ i_ehdrp = elf_elfheader (abfd);
41+
42+ /* Put an ABI label supported by FreeBSD >= 4.1 */
43+ i_ehdrp->e_ident[EI_OSABI] = ELFOSABI_FREEBSD;
44+}
45+
46+#undef elf_backend_post_process_headers
47+#define elf_backend_post_process_headers elf64_sparc_fbsd_post_process_headers
48+#undef elf64_bed
49+#define elf64_bed elf64_sparc_fbsd_bed
50+
51+#include "elf64-target.h"
52+
53--- bfd/targets.c
54+++ bfd/targets.c
55@@ -674,6 +674,7 @@ extern const bfd_target bfd_elf64_sh64bl
56 extern const bfd_target bfd_elf64_sh64lnbsd_vec;
57 extern const bfd_target bfd_elf64_sh64nbsd_vec;
58 extern const bfd_target bfd_elf64_sparc_vec;
59+extern const bfd_target bfd_elf64_sparc_freebsd_vec;
60 extern const bfd_target bfd_elf64_tradbigmips_vec;
61 extern const bfd_target bfd_elf64_tradlittlemips_vec;
62 extern const bfd_target bfd_elf64_x86_64_freebsd_vec;
63@@ -1002,6 +1003,7 @@ static const bfd_target * const _bfd_tar
64 &bfd_elf64_sh64lin_vec,
65 &bfd_elf64_sh64blin_vec,
66 &bfd_elf64_sparc_vec,
67+ &bfd_elf64_sparc_freebsd_vec,
68 &bfd_elf64_tradbigmips_vec,
69 &bfd_elf64_tradlittlemips_vec,
70 &bfd_elf64_x86_64_freebsd_vec,
71--- bfd/config.bfd
72+++ bfd/config.bfd
73@@ -182,7 +182,11 @@ case "${targ}" in
74 targ_selvecs="bfd_elf64_ia64_hpux_big_vec"
75 want64=true
76 ;;
77- sparc64-*-freebsd* | sparc64-*-netbsd* | sparc64-*-openbsd* | sparc64-*-kfreebsd*-gnu)
78+ sparc64-*-freebsd* | sparc64-*-kfreebsd*-gnu)
79+ targ_defvec=bfd_elf64_sparc_freebsd_vec
80+ targ_selvecs="bfd_elf32_sparc_vec sunos_big_vec"
81+ ;;
82+ sparc64-*-netbsd* | sparc64-*-openbsd*)
83 targ_defvec=bfd_elf64_sparc_vec
84 targ_selvecs="bfd_elf32_sparc_vec sunos_big_vec"
85 want64=true
86--- bfd/configure.in
87+++ bfd/configure.in
88@@ -716,6 +716,7 @@ do
89 bfd_elf64_sh64lnbsd_vec) tb="$tb elf64-sh64.lo elf64.lo $elf" target_size=64 ;;
90 bfd_elf64_sh64nbsd_vec) tb="$tb elf64-sh64.lo elf64.lo $elf" target_size=64 ;;
91 bfd_elf64_sparc_vec) tb="$tb elf64-sparc.lo elfxx-sparc.lo elf-vxworks.lo elf64.lo $elf"; target_size=64 ;;
92+ bfd_elf64_sparc_freebsd_vec) tb="$tb elf64-sparc.lo elfxx-sparc.lo elf-vxworks.lo elf64.lo $elf"; target_size=64 ;;
93 bfd_elf64_tradbigmips_vec) tb="$tb elf64-mips.lo elf64.lo elfxx-mips.lo elf-vxworks.lo elf32.lo $elf ecofflink.lo"; target_size=64 ;;
94 bfd_elf64_tradlittlemips_vec) tb="$tb elf64-mips.lo elf64.lo elfxx-mips.lo elf-vxworks.lo elf32.lo $elf ecofflink.lo"; target_size=64 ;;
95 bfd_elf64_x86_64_freebsd_vec) tb="$tb elf64-x86-64.lo elf64.lo $elf"; target_size=64 ;;
96--- bfd/configure
97+++ bfd/configure
98@@ -716,6 +716,7 @@ do
99 bfd_elf64_sh64lnbsd_vec) tb="$tb elf64-sh64.lo elf64.lo $elf" target_size=64 ;;
100 bfd_elf64_sh64nbsd_vec) tb="$tb elf64-sh64.lo elf64.lo $elf" target_size=64 ;;
101 bfd_elf64_sparc_vec) tb="$tb elf64-sparc.lo elfxx-sparc.lo elf-vxworks.lo elf64.lo $elf"; target_size=64 ;;
102+ bfd_elf64_sparc_freebsd_vec) tb="$tb elf64-sparc.lo elfxx-sparc.lo elf-vxworks.lo elf64.lo $elf"; target_size=64 ;;
103 bfd_elf64_tradbigmips_vec) tb="$tb elf64-mips.lo elf64.lo elfxx-mips.lo elf-vxworks.lo elf32.lo $elf ecofflink.lo"; target_size=64 ;;
104 bfd_elf64_tradlittlemips_vec) tb="$tb elf64-mips.lo elf64.lo elfxx-mips.lo elf-vxworks.lo elf32.lo $elf ecofflink.lo"; target_size=64 ;;
105 bfd_elf64_x86_64_freebsd_vec) tb="$tb elf64-x86-64.lo elf64.lo $elf"; target_size=64 ;;
106--- gas/config/tc-sparc.c
107+++ gas/config/tc-sparc.c
108@@ -337,7 +337,7 @@ sparc_target_format ()
109 #endif
110
111 #ifdef OBJ_ELF
112- return sparc_arch_size == 64 ? "elf64-sparc" : "elf32-sparc";
113+ return sparc_arch_size == 64 ? ELF64_TARGET_FORMAT : ELF_TARGET_FORMAT;
114 #endif
115
116 abort ();
117@@ -545,12 +545,12 @@ md_parse_option (c, arg)
118 {
119 if (sparc_arch_size == 32)
120 {
121- if (strcmp (*l, "elf32-sparc") == 0)
122+ if (CONST_STRNEQ (*l, "elf32-sparc"))
123 break;
124 }
125 else
126 {
127- if (strcmp (*l, "elf64-sparc") == 0)
128+ if (CONST_STRNEQ (*l, "elf64-sparc"))
129 break;
130 }
131 }
132--- gas/config/tc-sparc.h
133+++ gas/config/tc-sparc.h
134@@ -31,6 +31,19 @@ struct frag;
135
136 #define TARGET_ARCH bfd_arch_sparc
137
138+#ifdef TE_FreeBSD
139+#define ELF_TARGET_FORMAT "elf32-sparc-freebsd"
140+#define ELF64_TARGET_FORMAT "elf64-sparc-freebsd"
141+#endif
142+
143+#ifndef ELF_TARGET_FORMAT
144+#define ELF_TARGET_FORMAT "elf32-sparc"
145+#endif
146+
147+#ifndef ELF64_TARGET_FORMAT
148+#define ELF64_TARGET_FORMAT "elf64-sparc"
149+#endif
150+
151 extern const char *sparc_target_format PARAMS ((void));
152 #define TARGET_FORMAT sparc_target_format ()
153
154--- ld/emulparams/elf64_sparc_fbsd.sh
155+++ ld/emulparams/elf64_sparc_fbsd.sh
156@@ -1,2 +1,4 @@
157 . ${srcdir}/emulparams/elf64_sparc.sh
158 . ${srcdir}/emulparams/elf_fbsd.sh
159+
160+OUTPUT_FORMAT="elf64-sparc-freebsd"