On Wed Jun 21 03:31:32 2023 +0000, Alex Henrie wrote:
I dug into it today and was surprised to learn that w64-mingw32-clang supports `__attribute__((visibility ("hidden")))`, but w64-mingw32-gcc does not. I was also surprised to find that Wine does not include the attribute in DECLSPEC_HIDDEN on either of those compilers. With i686-w64-mingw32-clang and without any visibility attribute:
$ objdump -t dlls/imm32/i386-windows/imm32.dll | grep imm32_module [151](sec 4)(fl 0x00)(ty 0)(scl 3) (nx 1) 0x00002f1c .rdata$.refptr._imm32_module [2686](sec 6)(fl 0x00)(ty 0)(scl 2) (nx 0) 0x00000000 _imm32_module [2762](sec 4)(fl 0x00)(ty 0)(scl 2) (nx 0) 0x00002f1c .refptr._imm32_module $ wc -c dlls/imm32/i386-windows/imm32.dll 368112 dlls/imm32/i386-windows/imm32.dll
With i686-w64-mingw32-clang and the visibility hidden attribute:
$ objdump -t dlls/imm32/i386-windows/imm32.dll | grep imm32_module [2667](sec 6)(fl 0x00)(ty 0)(scl 2) (nx 0) 0x00000000 _imm32_module $ wc -c dlls/imm32/i386-windows/imm32.dll 367158 dlls/imm32/i386-windows/imm32.dll
I have submitted an additional pull request that enables the visibility hidden attribute on w64-mingw32-clang: https://gitlab.winehq.org/wine/wine/-/merge_requests/3125 Limiting the number of exported symbols improves compiler optimization and makes it harder for applications to detect and manipulate Wine implementation details, so yes, I think it is valuable.
It's interesting that the symbol for `_imm32_module` itself remains although its two companions are gone. I've been testing with Clang 15, but I think Clang 16 removes hidden symbols altogether: https://github.com/llvm/llvm-project/commit/c5b3de6745c37dd991430b9b88ff97c3...