This should most likely be done in ntdll. Also please add tests for these different cases.
For tests should create dll which can be loaded. But I do not know how to implement this in tests on WINE. I tried to copy and rename .exe.so module but it seems like the problem is existing only for PE modules.