Object symbols override library symbols?

When you define the same function (non-static) in two different C source files, compile them and link them to the Microsoft linker, you will get an error message with a duplicate character, as expected.

On the other hand, when you define a function that matches the name of a standard library function, for example. cos(which is not defined as COMDAT), then there is no error; your definition silently overrides the standard library definition. This is also the desired behavior, but I'm trying to figure out what the exact rule is.

Are rule characters defined in an object file overriding characters defined in a library file, or something else? I can't find mention of this in the PE spec, but maybe I'm missing something.

+4
source share
1 answer

MS linker only links member objects from static libraries that are needed to resolve dependencies. Unused member objects from static libraries are optimized. Therefore, if you have a duplicate character in a member object of a static library, but a member object is not needed, an error does not occur. See also: http://msdn.microsoft.com/en-us/library/72zdcz6f.aspx

, MS linker : http://support.microsoft.com/kb/148652/EN-US http://nikoniko-programming.blogspot.ch/2010/09/aliasing-symbol-names-during-link-time.html

MSDN.

+1

Source: https://habr.com/ru/post/1531750/


All Articles