Comment 1 for bug 1868064

Revision history for this message
David Brown (davidbrown) wrote :

The "used" attribute does not do quite what you seem to think it does. It tells the compiler that the function might be used even if the compiler doesn't see it (such as from assembly) - so the compiler will generate the code for the function even if it can't see it being used. If your code already calls the function name somewhere, the "used" attribute is redundant.

Your issue is not with compilation, and can't be solved by compile-time attributes. It is in linking. I think what you are seeing is that a weak symbol definition in one library is not being overridden by a symbol definition in another library - but it does get overridden by a definition in an object code file. Definitions in libraries are always considered a bit lower priority than definitions in object code files, and resolution of symbols in libraries and object code files is done in different orderings.

I am not sure of the exact rules here. The binutils "ld" manual might give you ideas. As a starting point, you might change your linker file to load the user_lib library first, before the third_party_lib files.