Hello Pelle,
Happy new year to you and all friends of this community.
Hoping to be helpful to perfectionate your compiler here I give you a little more work to do. Using version 2.90.1 (but I think this problem is present also in the previous versions) I find a bug in RVA generation in the calling module toward external DLL functions.
Consider a simple program that call a function in an external module (i.e. test_function) you can declare this function trough prototypes as:
void test_function(void);
or (more efficently) as:
__cdecl(dllimport) void test_function(void);
and everything works fine, but somthing wrong happen if for some mistake both declarations are applied in the same module.
When the executable try to call the external function the program hangs with an access violation.
After some checks I found that the error is due to a wrong RVA generation from the export address table that wrongly points to the JMP instuction code (byte code 0xFF25) in the jump table. Due to this the relocation from the loader modify the first 4 bytes instead of the last 4 of the jump table.
The problem is not easy visible becouse no error nor warning is generated in the compiler when it founds the two declarations.
At your option to add an error or correct the compiler code to always generate the correct RVA address.
Best regards
F.