$NetBSD: patch-al,v 1.1 2002/03/14 14:54:53 wiz Exp $ --- ../gcc-2.95.2/gcc/config/netbsd.h.orig Wed Dec 16 20:59:58 1998 +++ ../gcc-2.95.2/gcc/config/netbsd.h @@ -48,17 +48,38 @@ #define ASM_SPEC " %| %{fpic:-k} %{fPIC:-k -K}" /* Provide a LIB_SPEC appropriate for NetBSD. Just select the appropriate - libc, depending on whether we're doing profiling. */ + libc, depending on whether we're doing profiling; if `-posix' is specified, + link against the appropriate libposix first. Don't include libc when + linking a shared library. */ #undef LIB_SPEC -#define LIB_SPEC "%{!p:%{!pg:-lc}}%{p:-lc_p}%{pg:-lc_p}" +#define LIB_SPEC \ + "%{posix:%{!p:%{!pg:-lposix}}%{p:-lposix_p}%{pg:-lposix_p}} \ + %{!shared:%{!symbolic:%{!p:%{!pg:-lc}}%{p:-lc_p}%{pg:-lc_p}}}" + +/* Provide a LIBGCC_SPEC appropriate for NetBSD. We also want to exclude + libgcc when -symbolic. */ + +#undef LIBGCC_SPEC +#define LIBGCC_SPEC "%{!shared:%{!symbolic:-lgcc}}" + +/* #ifdef NETBSD_AOUT */ + +/* Provide a STARTFILE_SPEC appropriate for NetBSD a.out. Here we + provide support for the special GCC option -static. */ + +#undef STARTFILE_SPEC +#define STARTFILE_SPEC \ + "%{!shared:%{pg:gcrt0%O%s}%{!pg:%{p:mcrt0%O%s}%{!p:%{!static:crt0%O%s}%{static:scrt0%O%s}}}} %{shared:c++rt0%O%s}" /* Provide a LINK_SPEC appropriate for NetBSD. Here we provide support for the special GCC options -static, -assert, and -nostdlib. */ #undef LINK_SPEC #define LINK_SPEC \ - "%{!nostdlib:%{!r*:%{!e*:-e start}}} -dc -dp %{R*} %{static:-Bstatic} %{assert*}" + "%{nostdlib:-nostdlib} %{!shared:%{!nostdlib:%{!r*:%{!e*:-e start}}} -dc -dp %{static:-Bstatic}} %{shared:-Bshareable} %{R*} %{assert*}" + +/* #endif NETBSD_AOUT */ /* This defines which switch letters take arguments. */ #undef SWITCH_TAKES_ARG @@ -127,6 +148,9 @@ entries in an ELF object file under SVR4. These macros also output the starting labels for the relevant functions/objects. */ +/* XXX. This is WRONG for alpha. Needs to be verified on other ELF ports. */ +#ifndef NETBSD_ELF + /* Write the extra assembler code needed to declare a function properly. Some svr4 assemblers need to also have something extra said about the function's return value. We allow for that here. */ @@ -207,3 +231,56 @@ putc ('\n', FILE); \ } \ } while (0) + +#endif /* ! NETBSD_ELF */ + +/* NetBSD ELF support begins here. */ + +#ifdef NETBSD_ELF + +/* Start with generic ELF definitions. */ +#if !defined(__sparc__) +#include "elfos.h" + +#undef DWARF_DEBUGGING_INFO /* XXX */ +#undef DWARF2_DEBUGGING_INFO /* XXX */ +#endif + +/* Provide a STARTFILE_SPEC appropriate for NetBSD ELF targets. Here we + provide support for the special GCC option -static. On ELF targets, + we also add the crtbegin.o file which provides part of the support + for getting C++ file-scope static objects constructed before entering + `main'. */ + +#undef STARTFILE_SPEC +#define STARTFILE_SPEC \ + "%{!shared: \ + %{pg:gcrt0%O%s} \ + %{!pg: \ + %{p:gcrt0%O%s} \ + %{!p:crt0%O%s}}} \ + %{!shared:crtbegin%O%s} %{shared:crtbeginS%O%s}" + +/* Provide an ENDFILE_SPEC appropriate for NetBSD ELF targets. Here we + add crtend.o, which provides part of the support for getting C++ + file-scope static objects deconstructed after exiting `main'. */ + +#undef ENDFILE_SPEC +#define ENDFILE_SPEC \ + "%{!shared:crtend%O%s} %{shared:crtendS%O%s}" + +/* Provide a LINK_SPEC appropriate for a NetBSD ELF target. */ + +#undef LINK_SPEC +#define LINK_SPEC \ + "%{assert*} \ + %{shared:-shared} \ + %{!shared: \ + -dc -dp \ + %{!nostdlib:%{!r*:%{!e*:-e __start}}} \ + %{!static: \ + %{rdynamic:-export-dynamic} \ + %{!dynamic-linker:-dynamic-linker /usr/libexec/ld.elf_so}} \ + %{static:-static}}" + +#endif /* NETBSD_ELF */