blog/2021-04-25-weak-symbol #4
Replies: 1 comment 1 reply
-
|
Under the section Mach-O:
Perhaps this sentence could be clarified by noting that a weak definition in the executable does not override a strong definition in a dylib when the symbol is used within the dylib itself. For example: // shared.c
#include <stdio.h>
void f(void) { puts(__FILE_NAME__); }
void g(void) { f(); }
// main.c
#include <stdio.h>
[[gnu::weak]] void f(void) { puts(__FILE_NAME__); }
void g(void);
int main(void) {
f(); // prints "main.c"
g(); // prints "shared.c"
return 0;
} |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
blog/2021-04-25-weak-symbol
Updated in 2023-10. C/C++ GCC and Clang support attribute((weak)) which marks a symbol weak. The same effect can be achieved with a preprocessor directive #pragma weak symbol. Object file format I
https://maskray.me/blog/2021-04-25-weak-symbol
Beta Was this translation helpful? Give feedback.
All reactions