> No, the output I saw under Linux was consistent with Solaris, NOT Windows.
Since you did not say that in the original message that had only the output on Solaris, I could not not assume that.
Instead, I relied on the message from Philippe Verdy which had this output:
Hello from main
Hello from func1
Hello from func2 (sic!)
Back to func1
Back to main
Hello from myfun2 (sic!)
Back to main
His message did not say that it was done on Linux, that was my guess. And it did not show the command line options he used to get the result, nor did it specify the details of the toolchain.
ELF shared libraries allow for symbol interposition, so that a shared library may end up calling a function defined elsewhere even if it is also defined in the shared library. This is I think what your results demonstrate. However, that is both inefficient and questionable from the security standpoint so there are ways controlled by a bunch of different options to suppress this behaviour. Even default behaviour in this respect may have changed over the years and tool versions, so it is not completely surprising that you and Philippe got different results.
On the other hand, I do not think such behaviour is available with PE DLLs. I am not sure about MacOS.
I'd say all this demonstrates "undefined behaviour" quite convincingly.