PING^2 [PATCH] Support for AMD64 targets running GNU/kFreeBSD
Robert Millan
rmh@gnu.org
Thu Mar 31 09:49:00 GMT 2011
Ping^2
2011/1/26 Robert Millan <rmh@gnu.org>:
> Ping!
>
> 2011/1/18 Robert Millan <rmh@gnu.org>:
>> 2011/1/14 Robert Millan <rmh@gnu.org>:
>>> 2011/1/12 Robert Millan <rmh@gnu.org>:
>>>>> * The headers config/kfreebsd-gnu.h etc. override
>>>>> GLIBC_DYNAMIC_LINKER. But the 64-bit configurations
>>>>> x86_64-*-kfreebsd*-gnu and x86_64-*-knetbsd*-gnu do not appear to
>>>>> use any header that would override GLIBC_DYNAMIC_LINKER32 and
>>>>> GLIBC_DYNAMIC_LINKER64, which are what LINK_SPEC in linux64.h
>>>>> actually uses. Thus those configurations would use Linux-specific
>>>>> dynamic linker settings, which seems unlikely to be as intended.
>>>>
>>>> It's not as intended. On amd64 we use /lib/ld.so.1 and
>>>> /lib/ld-kfreebsd-x86-64.so.1.
>>>
>>> It seems x86_64-kfreebsd-gnu has been broken for a while. I
>>> just realized that I wrote a patch to fix this in 2006 [1], but
>>> somehow it was never merged in GCC (actually I'm not even
>>> sure I submitted it).
>>>
>>> In the meantime Debian GNU/kFreeBSD has been using this
>>> patch to build GCC on their "kfreebsd-amd64" port.
>>>
>>> I can prepare an updated version of this patch (relative to
>>> trunk + your linux.h overhaul [2]).
>>
>> Here is it.
>>
>> --
>> Robert Millan
>>
>
>
>
> --
> Robert Millan
>
--
Robert Millan
-------------- next part --------------
2011-01-18 Robert Millan <rmh@gnu.org>
Support for AMD64 targets running GNU/kFreeBSD.
* config.gcc (tm_file): Include `i386/kfreebsd-gnu.h' on
x86_64-*-kfreebsd*-gnu.
* config/i386/kfreebsd-gnu.h
(GLIBC_DYNAMIC_LINKER32): If defined, redefine to "/lib/ld.so.1".
(GLIBC_DYNAMIC_LINKER64): If defined, redefine to
"/lib/ld-kfreebsd-x86-64.so.1".
* config/i386/linux.h (LINK_EMULATION): Redefine this macro
to a noop filter, which can be overriden by other headers.
* config/i386/linux64.h (LINK_SPEC): Process emulation names
through LINK_EMULATION().
* config/kfreebsd-gnu.h (LINK_EMULATION): Redefine to append
a "_fbsd" suffix.
* config/i386/kfreebsd-gnu.h (LINK_EMULATION): Remove macro
(superceded by the definition in config/kfreebsd-gnu.h).
Index: gcc/config.gcc
===================================================================
--- gcc/config.gcc (revision 168952)
+++ gcc/config.gcc (working copy)
@@ -1267,7 +1267,7 @@
case ${target} in
x86_64-*-linux*)
default_gnu_indirect_function=glibc-2011 ;;
- x86_64-*-kfreebsd*-gnu) tm_file="${tm_file} kfreebsd-gnu.h" ;;
+ x86_64-*-kfreebsd*-gnu) tm_file="${tm_file} kfreebsd-gnu.h i386/kfreebsd-gnu.h" ;;
x86_64-*-knetbsd*-gnu) tm_file="${tm_file} knetbsd-gnu.h" ;;
esac
tmake_file="${tmake_file} i386/t-linux64 i386/t-crtstuff i386/t-crtpc i386/t-crtfm t-dfprules"
Index: gcc/config/i386/linux.h
===================================================================
--- gcc/config/i386/linux.h (revision 168952)
+++ gcc/config/i386/linux.h (working copy)
@@ -91,7 +91,7 @@
done. */
/* These macros may be overridden in k*bsd-gnu.h and i386/k*bsd-gnu.h. */
-#define LINK_EMULATION "elf_i386"
+#define LINK_EMULATION(em) em
#define GLIBC_DYNAMIC_LINKER "/lib/ld-linux.so.2"
#undef ASM_SPEC
@@ -100,7 +100,7 @@
#undef SUBTARGET_EXTRA_SPECS
#define SUBTARGET_EXTRA_SPECS \
- { "link_emulation", LINK_EMULATION },\
+ { "link_emulation", LINK_EMULATION("elf_i386") },\
{ "dynamic_linker", LINUX_DYNAMIC_LINKER }
#undef LINK_SPEC
Index: gcc/config/i386/kfreebsd-gnu.h
===================================================================
--- gcc/config/i386/kfreebsd-gnu.h (revision 168952)
+++ gcc/config/i386/kfreebsd-gnu.h (working copy)
@@ -19,7 +19,15 @@
along with GCC; see the file COPYING3. If not see
<http://www.gnu.org/licenses/>. */
-#undef LINK_EMULATION
-#define LINK_EMULATION "elf_i386_fbsd"
+#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 REG_NAME
#define REG_NAME(reg) sc_ ## reg
Index: gcc/config/i386/linux64.h
===================================================================
--- gcc/config/i386/linux64.h (revision 168952)
+++ gcc/config/i386/linux64.h (working copy)
@@ -75,7 +75,8 @@
%{!mno-sse2avx:%{mavx:-msse2avx}} %{msse2avx:%{!mavx:-msse2avx}}"
#undef LINK_SPEC
-#define LINK_SPEC "%{" SPEC_64 ":-m elf_x86_64} %{" SPEC_32 ":-m elf_i386} \
+#define LINK_SPEC "%{" SPEC_64 ":-m " LINK_EMULATION("elf_x86_64") "} \
+ %{" SPEC_32 ":-m " LINK_EMULATION("elf_i386") "} \
%{shared:-shared} \
%{!shared: \
%{!static: \
Index: gcc/config/kfreebsd-gnu.h
===================================================================
--- gcc/config/kfreebsd-gnu.h (revision 168952)
+++ gcc/config/kfreebsd-gnu.h (working copy)
@@ -35,3 +35,6 @@
#undef GLIBC_DYNAMIC_LINKER
#define GLIBC_DYNAMIC_LINKER "/lib/ld.so.1"
#endif
+
+#undef LINK_EMULATION
+#define LINK_EMULATION(em) em "_fbsd"
More information about the Gcc-patches
mailing list