LINK/LIB_SPEC fixes for FreeBSD

David O'Brien obrien@NUXI.com
Mon Jun 14 13:02:00 GMT 1999


Here is a patch to fix the LINK_SPEC and LIB_SPEC in the current
freebsd-elf.h file.  freebsd-elf.h has a general problem is that it is a
hacked up config/i386/linux.h rather than a proper configuration for
FreeBSD.  The history of freebsd-elf.h is unclear, but I believe it is
part of the proof of concept FreeBSD-ELFkit by John Polstra.  Thus
freebds-elf.h was a quick hack to so John could work on native ELF
support in the kernel.  I don't think John ever intended on it becoming
part of GCC in the form that it did.

-- 
-- David    (obrien@NUXI.com  -or-  obrien@FreeBSD.org)


Wed Jun 14 00:52:34 1999  David O'Brien <obrien@FreeBSD.org>

	* i386/freebsd-elf.h (LINK_SPEC): clean up the linking library 
	specifications and make it realistic.  
	(LIB_SPEC): Likewise.


diff -ru egcs-19990608/gcc/config/i386/freebsd-elf.h egcs-19990608.new/gcc/config/i386/freebsd-elf.h
--- egcs-19990608/gcc/config/i386/freebsd-elf.h	Thu Jun  3 16:18:41 1999
+++ egcs-19990608.new/gcc/config/i386/freebsd-elf.h	Mon Jun 14 12:41:54 1999
@@ -210,22 +210,18 @@
 #define ENDFILE_SPEC \
   "%{!shared:crtend.o%s} %{shared:crtendS.o%s} crtn.o%s"
 
+/* Provide a LIB_SPEC appropriate for FreeBSD.  Just select the appropriate
+   libc, depending on whether we're doing profiling or need threads support.
+   (simular to the default, except no -lg, and no -p.  */
 
-#undef	LIB_SPEC
-#if 1
-/* We no longer link with libc_p.a or libg.a by default. If you
- * want to profile or debug the C library, please add
- * -lc_p or -ggdb to LDFLAGS at the link time, respectively.
- */
-#define LIB_SPEC \
-  "%{!shared: %{mieee-fp:-lieee} %{p:-lgmon} %{pg:-lgmon} \
-     %{!ggdb:-lc} %{ggdb:-lg}}"
-#else
-#define LIB_SPEC \
-  "%{!shared: \
-     %{mieee-fp:-lieee} %{p:-lgmon -lc_p} %{pg:-lgmon -lc_p} \
-       %{!p:%{!pg:%{!g*:-lc} %{g*:-lg}}}}"
-#endif
+#undef LIB_SPEC
+#define LIB_SPEC "%{!shared: \
+   %{!pg:%{!pthread:%{!kthread:-lc} \
+     %{kthread:-lpthread -lc}} \
+     %{pthread:-lc_r}} \
+   %{pg:%{!pthread:%{!kthread:-lc_p} \
+     %{kthread:-lpthread_p -lc_p}} \
+     %{pthread:-lc_r_p}}}"
 
 /* Provide a LINK_SPEC appropriate for FreeBSD.  Here we provide support
    for the special GCC options -static and -shared, which allow us to
@@ -242,13 +238,17 @@
    done.  */
 
 #undef	LINK_SPEC
-#define LINK_SPEC "-m elf_i386 %{shared:-shared} \
-  %{!shared: \
-    %{!ibcs: \
+#define LINK_SPEC "-m elf_i386 \
+  %{Wl,*:%*} \
+  %{v:-V} \
+  %{assert*} %{R*} %{rpath*} %{defsym*} \
+  %{shared:-Bshareable %{h*} %{soname*}} \
+    %{!shared: \
       %{!static: \
-	%{rdynamic:-export-dynamic} \
-	%{!dynamic-linker:-dynamic-linker /usr/libexec/ld-elf.so.1}} \
-	%{static:-Bstatic}}}"
+        %{rdynamic:-export-dynamic} \
+	%{!dynamic-linker:-dynamic-linker /usr/libexec/ld-elf.so.1}} \
+    %{static:-Bstatic}}} \
+  %{symbolic:-Bsymbolic}"
 
 /* A C statement to output to the stdio stream FILE an assembler
    command to advance the location counter to a multiple of 1<<LOG


More information about the Gcc-patches mailing list