/usr/src/gcc-4.6/debian/patches/kbsd-gnu.diff is in gcc-4.6-source 4.6.4-6ubuntu2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 | # DP: GNU/k*BSD support
# Author: Robert Millan <rmh@aybabtu.com>
# Status: Not yet submitted
---
gcc/config.gcc | 2 +-
gcc/config/i386/kfreebsd-gnu.h | 22 ++++++++++++++++++++++
gcc/config/i386/linux64.h | 5 ++++-
3 files changed, 27 insertions(+), 2 deletions(-)
Index: b/src/gcc/config.gcc
===================================================================
--- a/src/gcc/config.gcc
+++ b/src/gcc/config.gcc
@@ -1311,7 +1311,7 @@
default_gnu_indirect_function=yes
;;
x86_64-*-kfreebsd*-gnu)
- tm_file="${tm_file} kfreebsd-gnu.h"
+ tm_file="${tm_file} kfreebsd-gnu.h i386/kfreebsd-gnu.h"
;;
x86_64-*-knetbsd*-gnu)
tm_file="${tm_file} knetbsd-gnu.h"
Index: b/src/gcc/config/i386/kfreebsd-gnu.h
===================================================================
--- a/src/gcc/config/i386/kfreebsd-gnu.h
+++ b/src/gcc/config/i386/kfreebsd-gnu.h
@@ -19,7 +19,29 @@
along with GCC; see the file COPYING3. If not see
<http://www.gnu.org/licenses/>. */
+#ifdef GLIBC_DYNAMIC_LINKER32
+#undef GLIBC_DYNAMIC_LINKER32
+#define GLIBC_DYNAMIC_LINKER32 "/lib/ld.so.1"
+#endif
+
+#ifdef GLIBC_DYNAMIC_LINKER64
+#undef GLIBC_DYNAMIC_LINKER64
+#define GLIBC_DYNAMIC_LINKER64 "/lib/ld-kfreebsd-x86-64.so.1"
+#endif
+
#undef LINK_EMULATION
#define LINK_EMULATION "elf_i386_fbsd"
+
+#ifdef LINK_EMULATION32
+#undef LINK_EMULATION32
+#define LINK_EMULATION32 LINK_EMULATION
+#endif
+
+#ifdef LINK_EMULATION64
+#undef LINK_EMULATION64
+#define LINK_EMULATION64 "elf_x86_64_fbsd"
+#endif
+
#undef REG_NAME
#define REG_NAME(reg) sc_ ## reg
+
Index: b/src/gcc/config/i386/linux64.h
===================================================================
--- a/src/gcc/config/i386/linux64.h
+++ b/src/gcc/config/i386/linux64.h
@@ -62,8 +62,11 @@
When the -shared link option is used a final link is not being
done. */
+/* These macros may be overridden in k*bsd-gnu.h and i386/k*bsd-gnu.h. */
#define GLIBC_DYNAMIC_LINKER32 "/lib/ld-linux.so.2"
#define GLIBC_DYNAMIC_LINKER64 "/lib64/ld-linux-x86-64.so.2"
+#define LINK_EMULATION32 "elf_i386"
+#define LINK_EMULATION64 "elf_x86_64"
#if TARGET_64BIT_DEFAULT
#define SPEC_32 "m32"
@@ -78,7 +81,7 @@
%{!mno-sse2avx:%{mavx:-msse2avx}} %{msse2avx:%{!mavx:-msse2avx}}"
#undef LINK_SPEC
-#define LINK_SPEC "%{" SPEC_64 ":-m elf_x86_64} %{" SPEC_32 ":-m elf_i386} --hash-style=gnu \
+#define LINK_SPEC "%{" SPEC_64 ":-m " LINK_EMULATION64 "} %{" SPEC_32 ":-m " LINK_EMULATION32 "} --hash-style=gnu \
%{shared:-shared} \
%{!shared: \
%{!static: \
|