Commit Graph

7860 Commits

Author SHA1 Message Date
Pali Rohár
48cf32beae headers: Fix compile warning: FACILITY_VISUALCPP redefined
Warning is:

    In file included from misc/delay-f.c:11:
    mingw-w64-headers/include/delayimp.h:64: warning: "FACILITY_VISUALCPP" redefined
     #define FACILITY_VISUALCPP ((LONG)0x6d)

    In file included from mingw-w64-headers/include/winbase.h:2817,
                     from mingw-w64-headers/include/windows.h:70,
                     from misc/delay-f.c:10:
    mingw-w64-headers/include/winerror.h:88: note: this is the location of the previous definition
     #define FACILITY_VISUALCPP 109

This same header from Visual Studio has such a definition commented out,
suggesting that it should be defined in winerror.h. We notice that delayimp.h
can't be used without including Windows SDK headers first, so don't redefine
`FACILITY_VISUALCPP` if one has already been defined.

Signed-off-by: LIU Hao <lh_mouse@126.com>
2024-07-31 11:11:36 +08:00
Pali Rohár
a0cac0b4a2 headers: Fix compile warning: FindResource redefined
Warning is:

    In file included from mingw-w64-headers/include/windows.h:70,
                     from libsrc/dxerr.c:15,
                     from libsrc/dxerr8w.c:20:
    mingw-w64-headers/include/winbase.h:2171: warning: "FindResource" redefined
     #define FindResource __MINGW_NAME_AW(FindResource)

    In file included from mingw-w64-headers/include/winbase.h:24,
                     from mingw-w64-headers/include/windows.h:70,
                     from libsrc/dxerr.c:15,
                     from libsrc/dxerr8w.c:20:
    mingw-w64-headers/include/libloaderapi.h:62: note: this is the location of the previous definition
     #define FindResource FindResourceW

Fix it by conditionally defining FindResource in winbase.h directly as
FindResourceA for non-UNICODE builds and let libloaderapi.h to define
FindResource as FindResourceW for UNICODE builds.

Signed-off-by: LIU Hao <lh_mouse@126.com>
2024-07-30 23:57:30 +08:00
Pali Rohár
715da56221 headers: Fix compile warning: EnumResourceNames redefined
Warning is:

    In file included from mingw-w64-headers/include/windows.h:70,
                     from crt/crtexewin.c:6,
                     from crt/ucrtexewin.c:14:
    mingw-w64-headers/include/winbase.h:2084: warning: "EnumResourceNames" redefined
     #define EnumResourceNames __MINGW_NAME_AW(EnumResourceNames)

    In file included from mingw-w64-headers/include/winbase.h:24,
                     from mingw-w64-headers/include/windows.h:70,
                     from crt/crtexewin.c:6,
                     from crt/ucrtexewin.c:14:
    mingw-w64-headers/include/libloaderapi.h:80: note: this is the location of the previous definition
     #define EnumResourceNames EnumResourceNamesW

Fix it by conditionally defining EnumResourceNames in winbase.h directly as
EnumResourceNamesA for non-UNICODE builds and let libloaderapi.h to define
EnumResourceNames as EnumResourceNamesW for UNICODE builds.

libloaderapi.h is automatically included in winbase.h, so caller of
winbase.h would have definition of EnumResourceNames for both UNICODE and
non-UNICODE builds.

Caller of libloaderapi.h would have only UNICODE definition of
EnumResourceNames because api-ms-win-core-libraryloader-l1-2-2.def and
kernel32_onecore.def do not provide non-UNICODE EnumResourceNamesA symbol.

Signed-off-by: LIU Hao <lh_mouse@126.com>
2024-07-30 23:57:30 +08:00
Pali Rohár
8106880ee5 headers: Fix compile warning: FACILITY_USERMODE_FILTER_MANAGER redefined
Warning is:

    In file included from mingw-w64-headers/include/winerror.h:4920,
                     from mingw-w64-headers/include/winbase.h:2817,
                     from mingw-w64-headers/include/windows.h:70,
                     from intrincs/RtlSecureZeroMemory.c:2:
    mingw-w64-headers/include/fltwinerror.h:12: warning: "FACILITY_USERMODE_FILTER_MANAGER" redefined
     #define FACILITY_USERMODE_FILTER_MANAGER 0x1f

    In file included from mingw-w64-headers/include/winbase.h:2817,
                     from mingw-w64-headers/include/windows.h:70,
                     from intrincs/RtlSecureZeroMemory.c:2:
    mingw-w64-headers/include/winerror.h:38: note: this is the location of the previous definition
     #define FACILITY_USERMODE_FILTER_MANAGER 31

WinSDK10 header file fltWinError.h contains #ifndef guard. Do same.

Signed-off-by: LIU Hao <lh_mouse@126.com>
2024-07-30 23:57:30 +08:00
Martin Storsjö
c228e5cc20 crt: Regenerate Makefile.in
Signed-off-by: Martin Storsjö <martin@martin.st>
2024-07-30 14:41:54 +03:00
Pali Rohár
df61d420e1 crt: Move strnlen from libmingwex.a to individual CRT import libraries
POSIX strnlen symbol is natively available since msvcr80 and also in all
ARM versions of msvcrt.dll.

Signed-off-by: Martin Storsjö <martin@martin.st>
2024-07-30 14:41:20 +03:00
Pali Rohár
d127ca98d2 crt: Move wctype from libmingwex.a to individual CRT import libraries
C95 wctype symbol is natively available since msvcr120.

Signed-off-by: Martin Storsjö <martin@martin.st>
2024-07-30 14:41:20 +03:00
Pali Rohár
1b8ac51757 crt: Move wctob from libmingwex.a to individual CRT import libraries
C95 wctob symbol is natively available since msvcr80 and also in all ARM
versions of msvcrt.dll.

Signed-off-by: Martin Storsjö <martin@martin.st>
2024-07-30 14:41:20 +03:00
Pali Rohár
5a6adae5ad crt: Move wcsrtombs and wcrtomb from libmsvcrt_common.a to individual CRT import libraries
C99 wcsrtombs and wcrtomb symbols are natively available since msvcr80 and
also in all ARM versions of msvcrt.dll.

Signed-off-by: Martin Storsjö <martin@martin.st>
2024-07-30 14:41:20 +03:00
Pali Rohár
bbcd196782 crt: Move wctrans and towctrans from libmingwex.a to individual CRT import libraries
C99 wctrans and towctrans symbols are natively available since msvcr120.

Signed-off-by: Martin Storsjö <martin@martin.st>
2024-07-30 14:41:20 +03:00
Pali Rohár
b69e742650 crt: Move mbrtowc, mbsrtowcs and mbrlen from libmsvcrt_common.a to individual CRT import libraries
C95 mbrtowc, mbsrtowcs and mbrlen symbols are natively available since
msvcr80 and also in all ARM versions of msvcrt.dll.

Signed-off-by: Martin Storsjö <martin@martin.st>
2024-07-30 14:41:20 +03:00
Pali Rohár
395f812e36 crt: Move btowc from libmingwex.a to individual CRT import libraries
C95 btowc symbol is natively available since msvcr80 and also in all ARM
versions of msvcrt.dll.

Signed-off-by: Martin Storsjö <martin@martin.st>
2024-07-30 14:41:20 +03:00
Pali Rohár
424f1bbac6 crt: Move iswblank from libmingwex.a to individual CRT import libraries
C99 iswblank symbol is natively available since msvcr120.

Signed-off-by: Martin Storsjö <martin@martin.st>
2024-07-30 14:41:20 +03:00
Martin Storsjö
36c6211d05 headers: Stop including mm3dnow.h in intrin.h
Clang 19 has removed all support for 3dnow, see
f0eb5587ce
and
https://github.com/llvm/llvm-project/pull/96246.

Since this commit, including the mm3dnow.h header still works,
but it produces a warning about the header being deprecated.

As 3DNow! has been deprecated for a very long time, stop
including this header, for all compiler configurations.

This issue was reported in
https://github.com/mstorsjo/llvm-mingw/issues/443.

Signed-off-by: Martin Storsjö <martin@martin.st>
2024-07-29 23:53:39 +03:00
LIU Hao
f785aaee17 crt: Regenerate Makefile.in
Signed-off-by: LIU Hao <lh_mouse@126.com>
2024-07-28 20:17:20 +08:00
LIU Hao
656b9da302 crt: Unify bcryptprimitives.def for ARM and ARM64
Signed-off-by: LIU Hao <lh_mouse@126.com>
2024-07-28 20:16:32 +08:00
Marc-André Lureau
9f6cadc68f crt: Add bcryptprimitives.def for x86
Makefile.in regeneration not included, per request.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Signed-off-by: LIU Hao <lh_mouse@126.com>
2024-07-28 20:12:06 +08:00
Pali Rohár
527522b8b0 headers: Unify _HUGE definition between UCRT and non-UCRT builds
Provide __MINGW_IMP_SYMBOL(_HUGE) via UCRT import library and unify math.h
header file to always define _HUGE via __MINGW_IMP_SYMBOL(_HUGE).

Signed-off-by: Martin Storsjö <martin@martin.st>
2024-07-24 13:30:17 +03:00
Pali Rohár
5e09537075 crt: Guard local _commode variable in crtexe.c
Currently mingw-w64 does not define or provide _commode in header files,
so this guard does not change current behavior.

But in case that in future some mingw-w64 header file starts providing
global _commode macro (as expansion to __p__commode() funcion call), add
guard for local _commode variable which undefines _commode. Same what is
done for _fmode. This ensures that _commode in crtexe.c would always refers
to local _commode variable.

Signed-off-by: Martin Storsjö <martin@martin.st>
2024-07-24 13:30:17 +03:00
Martin Storsjö
d1558c7a3d crt: Regenerate Makefile.in
Signed-off-by: Martin Storsjö <martin@martin.st>
2024-07-24 13:25:00 +03:00
Pali Rohár
3c573036b2 crt: msvcr120d.def.in: Add ARM32 import library
Signed-off-by: Martin Storsjö <martin@martin.st>
2024-07-24 13:24:19 +03:00
Pali Rohár
87ce4f44d5 crt: msvcr120.def.in: Add ARM32 import library
Signed-off-by: Martin Storsjö <martin@martin.st>
2024-07-24 13:24:19 +03:00
Pali Rohár
b8d9df769c crt: msvcr110d.def.in: Add ARM32 import library
Signed-off-by: Martin Storsjö <martin@martin.st>
2024-07-24 13:24:19 +03:00
Pali Rohár
e5122b8e5b crt: msvcr110.def.in: Update ARM32 version
* Regenerate symbols from the original ARM32 version
* Add symbols introduced in Visual C++ 2012 Update 1
* Include aliases from crt-aliases.def.in

Signed-off-by: Martin Storsjö <martin@martin.st>
2024-07-24 13:24:19 +03:00
Pali Rohár
f5bc0640a4 crt: Remove ARM32 msvcr120_clr0400.def file
msvcr120_clr0400.dll is private copy of msvcr120.dll library for .NET CLR
runtime. It is not for application usage. Applications should use
msvcr120.dll instead of msvcr120_clr0400.dll.

So remove msvcr120_clr0400.def file and in future changes include
msvcr120.def file.

Signed-off-by: Martin Storsjö <martin@martin.st>
2024-07-24 13:24:19 +03:00
Pali Rohár
7f9875d467 crt: Remove ARM32 references for: msvcr80.def msvcr90.def msvcr90d.def msvcr100.def
First versioned msvcrt library for ARM32 is msvcr110.dll. Libraries
msvcr80.dll, msvcr90.dll, msvcr90d.dll and msvcr100.dll do not exist.

Signed-off-by: Martin Storsjö <martin@martin.st>
2024-07-24 13:24:07 +03:00
Martin Storsjö
1c506e8940 gendef: Regenerate configure
Signed-off-by: Martin Storsjö <martin@martin.st>
2024-07-24 13:11:17 +03:00
Pali Rohár
8cde1a6725 gendef: Increase gendef version number to 1.1
Signed-off-by: Martin Storsjö <martin@martin.st>
2024-07-24 13:11:17 +03:00
Pali Rohár
a0a52fc204 gendef: Fix generating ordinal-only exports
When using GNU ld or GNU dlltool, it is needed to mark ordinal-only export
with NONAME keyword. Otherwise the import library would use export by name,
instead of by ordinal.

Signed-off-by: Martin Storsjö <martin@martin.st>
2024-07-24 13:11:17 +03:00
Pali Rohár
251b6394a5 gendef: Update Check!!! comment about return value
This code block detected that the return value is from other library
function. It does not mean that function forwards to another one.

For example lot of times gendef detected that the call is GetLastError()
from kernel32.dll. But it does not mean that the function was forwarded to
GetLastError(). It just means that one of the code branch was propagating
return value from GetLastError().

Signed-off-by: Martin Storsjö <martin@martin.st>
2024-07-24 13:11:17 +03:00
Pali Rohár
3a2ac9a216 gendef: Add new option --no-include-current-dir
gendef by default always scans current directory for other hint .def files
which are later parsed. This default behavior is sometimes problematic, so
add an option --no-include-current-dir which disables scanning of the
current directory for other hint .def files.

Signed-off-by: Martin Storsjö <martin@martin.st>
2024-07-24 13:11:17 +03:00
Pali Rohár
2ff2b1c8d8 gendef: Show comment how to process generated def file
Generated file has be processed by --kill-at (-k) option of dlltool
or ld.

Signed-off-by: Martin Storsjö <martin@martin.st>
2024-07-24 13:11:17 +03:00
Pali Rohár
f35e3abb8c gendef: Recognize decorated I386 fastcall function exports
Decorated I386 fastcall functions have symbols with "@NAME@SIZE" pattern.

Normally function symbols from libraries are exported undecorated, symbol
name matches the function name. But some libraries export I386 fastcall
functions with decorated symbol names.

For example msvcr80.dll library exports symbol "@_calloc_crt@8" for which
gendef without this change generates line "@_calloc_crt@8@8", which cannot
be easily used by applications. With this change it generates line
"@_calloc_crt@8 == @_calloc_crt@8" which allows applications to call
fastcall function _calloc_crt(void *ptr, size_t size).

Signed-off-by: Martin Storsjö <martin@martin.st>
2024-07-24 12:37:20 +03:00
Pali Rohár
4bd6b87e9c gendef: Recognize decorated I386 stdcall function exports
Decorated I386 stdcall functions have symbols with "_NAME@SIZE" pattern.

Normally function symbols from libraries are exported undecorated, symbol
name matches the function name. But some libraries export I386 stdcall
functions with decorated symbol names.

For example msvcrt20.dll library exports symbol "__seh_longjmp_unwind@4"
and gendef without this change generated line "__seh_longjmp_unwind@4@4",
which cannot be easily used by applications. With this change it generates
line "_seh_longjmp_unwind@4 == __seh_longjmp_unwind@4" which allows
applications to call stdcall function _seh_longjmp_unwind(void *jmp).

Signed-off-by: Martin Storsjö <martin@martin.st>
2024-07-24 12:37:20 +03:00
Pali Rohár
b2b319d518 gendef: Recognize I386 PE with zeroed NT magic
binutils (objdump) accepts PE binaries (EXE/DLL) with zero value in
OptionalHeader's Magic field. Do same in gendef. Such I386 DLL binaries are
distributed as part of the Win32s.

Signed-off-by: Martin Storsjö <martin@martin.st>
2024-07-24 12:37:20 +03:00
Pali Rohár
ad8edb65bc gendef: Show gendef version in generated file and also in help
Signed-off-by: Martin Storsjö <martin@martin.st>
2024-07-24 12:37:19 +03:00
Pali Rohár
d408f51e5a crt: msvcr120_app: Do not include aliases for symbols which are not present
msvcr120_app.dll compared to msvcr120.dll is missing not only _getpid symbol
but it is missing also other symbols for which are specified underscore
aliases in crt-aliases.def.in file.

Change NO_GETPID_ALIAS macro to CRTAPP and conditionally disable all
symbols for CRTAPP in crt-aliases.def.in file which are not present in
msvcr120_app.dll library.

Signed-off-by: Martin Storsjö <martin@martin.st>
2024-07-24 12:31:09 +03:00
Pali Rohár
9e27bb062a crt: msvcr120_app: Fix list of ARM32 symbols
msvcr120_app.def.in file contains incorrect list of ARM32 symbols.

Seems that the list of symbols was generated from the ARM32 msvcrt.dll
library and not from the ARM32 msvcr120_app.dll library.

List of ARM32 symbols is imported from the vclibs_redist_packages.zip
package (Visual C++ 2013 Runtime for Sideloaded Windows 8.1 apps):
https://learn.microsoft.com/en-us/cpp/windows/latest-supported-vc-redist

List of I386 and X64 symbols from that package already matches the
msvcr120_app.def.in file.

Signed-off-by: Martin Storsjö <martin@martin.st>
2024-07-24 12:31:09 +03:00
Martin Storsjö
353085a10e crt: Regenerate Makefile.in
Signed-off-by: Martin Storsjö <martin@martin.st>
2024-07-24 12:31:09 +03:00
Pali Rohár
5a6df919af crt: msvcr120_app: Provide emulation of __p__environ and __p__wenviron symbols
msvcr120_app.dll library does not provide __p__environ() and
__p__wenviron() functions, but provides _environ[] and _wenviron[] arrays.

So include mingw-w64 emulation of __p__environ() and __p__wenviron()
functions via _environ[] and _wenviron[] arrays into msvcr120_app import
library.

Signed-off-by: Martin Storsjö <martin@martin.st>
2024-07-24 12:31:09 +03:00
Martin Storsjö
ef6692f311 crt: Regenerate Makefile.in
Signed-off-by: Martin Storsjö <martin@martin.st>
2024-07-24 12:28:17 +03:00
Pali Rohár
0f03e49a67 crt: Access __initenv and __winitenv global variables via __p___initenv() and __p___winitenv() functions
MS Visual C++ also access these variables via __p_*() functions which
return pointer to those variables. Do same in mingw-w64 startup code.

UCRT, msvcr120_app.dll and non-i386 versions of msvcrt.dll do not export
__p_*() functions. So provide them via mingw-w64 import libraries.

Signed-off-by: Martin Storsjö <martin@martin.st>
2024-07-24 12:28:04 +03:00
Martin Storsjö
1a1b3deb2e crt: Regenerate Makefile.in
Signed-off-by: Martin Storsjö <martin@martin.st>
2024-07-24 12:28:03 +03:00
Pali Rohár
ec2f45aace crt: Split __initenv and __winitenv symbols into separate files
Every executable references only one of those symbols. So if symbols are
split into separate files, linker includes only the one which is used.

(While splitting, simplify the use of headers as well.)

crtdll.dll and msvcrt10.dll do not have entry point for wide wmain() and
therefore they do not need __winitenv init symbol. So do not provide
__winitenv symbol for these two CRT import libraries.

Signed-off-by: Martin Storsjö <martin@martin.st>
2024-07-24 12:27:42 +03:00
Martin Storsjö
97be41760d crt: Regenerate Makefile.in
Signed-off-by: Martin Storsjö <martin@martin.st>
2024-07-23 13:04:20 +03:00
Pali Rohár
3c60ad9c7a crt: Remove duplicate file mingw-w64-crt/misc/initenv.c
File mingw-w64-crt/misc/initenv.c provides same implementation of __initenv
and __winitenv symbols as file mingw-w64-crt/misc/__initenv.c.

So remove duplicate file.

Signed-off-by: Martin Storsjö <martin@martin.st>
2024-07-23 13:04:20 +03:00
Pali Rohár
f1075a71a0 crt: msvcrt.def.in: Do not overwrite math frexp symbol on ARM
Same as for other math symbols, do not overwrite them in msvcrt.def.in on ARM.

Signed-off-by: Martin Storsjö <martin@martin.st>
2024-07-23 13:03:41 +03:00
Martin Storsjö
7cdb381e35 crt: Regenerate Makefile.in
Signed-off-by: Martin Storsjö <martin@martin.st>
2024-07-23 11:58:23 +03:00
Pali Rohár
464266725d crt: Provide __badioinfo variable import symbol for all CRT libraries
Global variable __badioinfo is exported from VC42+ CRT import libraries.
It is not exported from UCRT.

So it is not available in UCRT, msvcrt40.dll and older CRT versions.

Symbol is just a global ioinfo structure with bad (-1) file descriptor.

Provide this structure also in import libraries for older CRT versions and
UCRT, so the symbols will be in all CRT import libraries.

Signed-off-by: Martin Storsjö <martin@martin.st>
2024-07-23 11:57:27 +03:00
Pali Rohár
e3da5d008d crt: Fix declaration of __badioinfo import symbol
Symbol __badioinfo represents a variable of structure type. Not a pointer
to structure and neither not a pointer to array of structures.

Signed-off-by: Martin Storsjö <martin@martin.st>
2024-07-23 11:57:27 +03:00