gcc/gcc/config/i386/cygwin.h
Caroline Tice f7f049fa46 Committing VTV Cygwin patch for Patrick Wollgast
* gcc/config/i386/cygwin.h (STARTFILE_SPEC): Add vtv_start.o,
    if -fvtable-verify=preinit/std is used.
* gcc/config/i386/mingw-w64.h (STARTFILE_SPEC): Likewise.
* gcc/config/i386/mingw32.h (STARTFILE_SPEC): Likewise.
* gcc/config/i386/cygwin.h (ENDFILE_SPEC): Add vtv_end.o,
    if -fvtable-verify=preinit/std is used.
* gcc/config/i386/mingw32.h (ENDFILE_SPEC): Likewise.
* gcc/config/i386/cygwin.h (LIB_SPEC): Pass -lvtv and -lpsapi,
    if -fvtable-verify=preinit/std is used.
* gcc/config/i386/mingw-w64.h (LIB_SPEC): Likewise.
* gcc/config/i386/mingw32.h (LIB_SPEC): Likewise.

* gcc/cp/vtable-class-hierarchy.c (vtv_generate_init_routine): Add
    check for not TARGET_PECOFF at the VTV_PREINIT_PRIORITY checks.

* gcc/varasm.c (assemble_variable): Add code to properly set the comdat
    section and name for the .vtable_map_vars section in case the
    target is PE or COFF.


* libgcc/Makefile.in: Move rules to build vtv_*.o out of the check
    for CUSTOM_CRTSTUFF.
* libgcc/config.host (i[34567]86-*-cygwin*, x86_64-*-cygwin*, i[34567]86-*-mingw*)
    (x86_64-*-mingw*): Only add vtv_*.o to extra_parts if enable_vtable_verify.


* libstdc++-v3/acinclude.m4: Define VTV_CYGMIN.
* libstdc++-v3/configure: Regenerate.

* libstdc++-v3/libsupc++/Makefile.am: Add vtv_sources only to
    libsupc___la_SOURCES and libsupc__convenience_la_SOURCES if VTV_CYGMIN is
    not set.
* libstdc++-v3/libsupc++/Makefile.in: Regenerated.
* libstdc++-v3/libsupc++/vtv_stubs.cc: Add none weak declaration of every
    function for Cygwin and MinGW.

* libstdc++-v3/src/Makefile.am: Add libvtv.la to toolexeclib_LTLIBRARIES,
    if VTV_CYGMIN is set. Define libvtv_la_SOURCES, libvtv_la_LDFLAGS,
    libvtv_la_AM_CXXFLAGS and libvtv_la_LINK if VTV_CYGMIN is set.
* libstdc++-v3/src/Makefile.in: Regenerate.


* libvtv/Makefile.am : Add libvtv.la to toolexeclib_LTLIBRARIES, if VTV_CYGMIN
    is set. Define libvtv_la_LIBADD, libvtv_la_LDFLAGS, libvtv_stubs_la_LDFLAGS
    and libvtv_stubs_la_SOURCES if VTV_CYGMIN is set. Add obstac.c to
    libvtv_la_SOURCES if VTV_CYGMIN is set.
* libvtv/Makefile.in : Regenerate.
* libvtv/aclocal.m4 : Regenerate.
* libvtv/configure : Regenerate.
* libvtv/configure.ac : Add ACX_LT_HOST_FLAGS. Define VTV_CYGMIN.
* libvtv/configure.tgt : (x86_64-*-cygwin*, i?86-*-cygwin*, x86_64-*-mingw*)
    (i?86-*-mingw*): Add to supported targets.
* libvtv/vtv_fail.cc : Skip inclusion of execinfo.h on Cygwin and MinGW.
(log_error_message): Skip calls to backtrace and backtrace_symbols_fd on Cygwin
    and MinGW.
* libvtv/vtv_malloc.cc : Include windows.h and skip sys/mman.h inclusion on
    Cygwin and MinGW. Add sysconf port on Cygwin and MinGW.
(obstack_chunk_alloc): Exchange call to mmap with call to VirtualAlloc on Cygwin
    and MinGW.
(__vtv_malloc_init): Exchange call to sysconf with call to port of sysconf on
    Cygwin and MinGW.
* libvtv/vtv_malloc.h : Declare mprotect and define PROT_READ and PROT_WRITE on
    Cygwin and MinGW.
* libvtv/map.h : Include stdint.h on MinGW.
* libvtv/rts.cc : Include windows.h, winternl.h and psapi.h, skip include of
    execinfo.h, sys/mman.h and link.h on Cygwin and MinGW.
    Add port of __fortify_fail on Cygwin and MinGW.
    Change ElfW (Addr) to uintptr_t on Cygwin and MinGW.
(read_section_offset_and_length): Add port for Cygwin and MinGW
(iterate_modules): New function.
(vtv_unprotect_vtable_vars): Use iterate_modules instead of dl_iterate_phdr on
    Cygwin and MinGW.
(vtv_protect_vtable_vars): Likewise.
(count_all_pages): Likewise.
(dl_iterate_phdr_count_pages): Don't build on Cygwin and MinGW.
* libvtv/utils.cc : Include windows.h and skip execinfo.h inclusion on
    Cygwin and MinGW.
(__vtv_open_log): Exchange call to getuid and getpid with GetCurrentProcessId and
    adjust call to snprintf accordingly on Cygwin and MinGW.
    Adjust calls to mkdir on MinGW.
    Adjust call to open on Cygwin and MinGW.
(__vtv_add_to_log): Adjust call to snprintf on Cygwin and MinGW.
(__vtv_log_verification_failure): Don't generate a backtrace on Cygwin and MinGW.

From-SVN: r220232
2015-01-29 00:03:56 -08:00

159 lines
5.0 KiB
C

/* Operating system specific defines to be used when targeting GCC for
hosting on Windows32, using a Unix style C library and tools.
Copyright (C) 1995-2015 Free Software Foundation, Inc.
This file is part of GCC.
GCC is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3, or (at your option)
any later version.
GCC is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with GCC; see the file COPYING3. If not see
<http://www.gnu.org/licenses/>. */
#define EXTRA_OS_CPP_BUILTINS() \
do \
{ \
builtin_define ("__CYGWIN__"); \
if (!TARGET_64BIT) \
builtin_define ("__CYGWIN32__"); \
builtin_define ("__unix__"); \
builtin_define ("__unix"); \
} \
while (0)
#undef CPP_SPEC
#define CPP_SPEC "%(cpp_cpu) %{posix:-D_POSIX_SOURCE} \
%{!ansi:-Dunix} \
%{pthread:-D_REENTRANT} \
%{mwin32:-DWIN32 -D_WIN32 -D__WIN32 -D__WIN32__ %{!ansi:-DWINNT}} \
%{!nostdinc:%{!mno-win32:-idirafter ../include/w32api%s -idirafter ../../include/w32api%s}}\
"
#undef STARTFILE_SPEC
#define STARTFILE_SPEC "\
%{!shared: %{!mdll: crt0%O%s \
%{pg:gcrt0%O%s}}}\
%{shared:crtbeginS.o%s;:crtbegin.o%s} \
%{fvtable-verify=none:%s; \
fvtable-verify=preinit:vtv_start.o%s; \
fvtable-verify=std:vtv_start.o%s}"
#undef ENDFILE_SPEC
#define ENDFILE_SPEC \
"%{Ofast|ffast-math|funsafe-math-optimizations:crtfastmath.o%s}\
%{!shared:%:if-exists(default-manifest.o%s)}\
%{fvtable-verify=none:%s; \
fvtable-verify=preinit:vtv_end.o%s; \
fvtable-verify=std:vtv_end.o%s} \
crtend.o%s"
/* Normally, -lgcc is not needed since everything in it is in the DLL, but we
want to allow things to be added to it when installing new versions of
GCC without making a new CYGWIN.DLL, so we leave it. Profiling is handled
by calling the init function from main. */
#ifdef ENABLE_SHARED_LIBGCC
#define SHARED_LIBGCC_SPEC " \
%{static|static-libgcc:-lgcc -lgcc_eh} \
%{!static: \
%{!static-libgcc: \
-lgcc_s -lgcc \
} \
} "
#else
#define SHARED_LIBGCC_SPEC " -lgcc "
#endif
#undef REAL_LIBGCC_SPEC
#define REAL_LIBGCC_SPEC SHARED_LIBGCC_SPEC
/* We have to dynamic link to get to the system DLLs. All of libc, libm and
the Unix stuff is in cygwin.dll. The import library is called
'libcygwin.a'. For Windows applications, include more libraries, but
always include kernel32. We'd like to specific subsystem windows to
ld, but that doesn't work just yet. */
#undef LIB_SPEC
#define LIB_SPEC "\
%{pg:-lgmon} \
%{pthread: } \
-lcygwin \
%{mwindows:-lgdi32 -lcomdlg32} \
%{fvtable-verify=preinit:-lvtv -lpsapi; \
fvtable-verify=std:-lvtv -lpsapi} \
-ladvapi32 -lshell32 -luser32 -lkernel32"
/* To implement C++ function replacement we always wrap the cxx
malloc-like operators. See N2800 #17.6.4.6 [replacement.functions] */
#define CXX_WRAP_SPEC_LIST " \
--wrap _Znwj \
--wrap _Znaj \
--wrap _ZdlPv \
--wrap _ZdaPv \
--wrap _ZnwjRKSt9nothrow_t \
--wrap _ZnajRKSt9nothrow_t \
--wrap _ZdlPvRKSt9nothrow_t \
--wrap _ZdaPvRKSt9nothrow_t \
"
#if defined (USE_CYGWIN_LIBSTDCXX_WRAPPERS)
#if USE_CYGWIN_LIBSTDCXX_WRAPPERS
/* Default on, only explict -mno disables. */
#define CXX_WRAP_SPEC_OPT "!mno-use-libstdc-wrappers"
#else
/* Default off, only explict -m enables. */
#define CXX_WRAP_SPEC_OPT "muse-libstdc-wrappers"
#endif
#define CXX_WRAP_SPEC "%{" CXX_WRAP_SPEC_OPT ":" CXX_WRAP_SPEC_LIST "}"
#else /* !defined (USE_CYGWIN_LIBSTDCXX_WRAPPERS) */
#define CXX_WRAP_SPEC ""
#endif /* ?defined (USE_CYGWIN_LIBSTDCXX_WRAPPERS) */
#define LINK_SPEC "\
%{mwindows:--subsystem windows} \
%{mconsole:--subsystem console} \
" CXX_WRAP_SPEC " \
%{shared: %{mdll: %eshared and mdll are not compatible}} \
%{shared: --shared} %{mdll:--dll} \
%{static:-Bstatic} %{!static:-Bdynamic} \
%{shared|mdll: --enable-auto-image-base -e __cygwin_dll_entry@12} \
--dll-search-prefix=cyg \
%{!shared: %{!mdll: --large-address-aware --tsaware}}"
/* Binutils does not handle weak symbols from dlls correctly. For now,
do not use them unnecessarily in gthr-posix.h. */
#define GTHREAD_USE_WEAK 0
/* Every program on cygwin links against cygwin1.dll which contains
the pthread routines. There is no need to explicitly link them
and the -pthread flag is accepted only for compatibility. */
#undef GOMP_SELF_SPECS
#define GOMP_SELF_SPECS ""
#undef GTM_SELF_SPECS
#define GTM_SELF_SPECS ""
/* This matches SHLIB_SONAME and SHLIB_SOVERSION in t-cygwin. */
#if DWARF2_UNWIND_INFO
#define LIBGCC_EH_EXTN ""
#else
#define LIBGCC_EH_EXTN "-sjlj"
#endif
#define LIBGCC_SONAME "cyggcc_s" LIBGCC_EH_EXTN "-1.dll"
/* We should find a way to not have to update this manually. */
#define LIBGCJ_SONAME "cyggcj" /*LIBGCC_EH_EXTN*/ "-16.dll"