- emit .extern and .weak directive linkage
the c source code for test cases aix-extern.ll , aix-weak.ll , aix-extern-weak.ll as
bash> cat aix_extern.c
extern int bar_extern(int* ip); extern int bar_ref(); extern int b_e; void foo(){ } int (*bar_p)() = bar_ref; int main() { bar_extern(&b_e); foo(); bar_p(); bar_ref(); }
bash>cat aix_weak.c
__attribute__ ((weak)) void foo_weak(int *p){ (*p)++; } __attribute__ ((weak)) void foo_ref_weak(){ } void (*foo_weak_p)() = foo_ref_weak; int __attribute__ ((weak)) b; int main() { foo_weak_p(); foo_weak(&b); foo_ref_weak(); }
bash>cat aix_extern_weak.c
extern __attribute__ ((weak)) void foo_ext_weak(int* ); extern __attribute__ ((weak)) void foo_ext_weak_ref(void); extern __attribute__ ((weak)) int b; void (*foo_ext_weak_p)() = foo_ext_weak_ref; void (*foo_ext_weak_p_nocall)() = foo_ext_weak_ref; int main() { foo_ext_weak_p(); foo_ext_weak(&b); }
@hubert.reinterpretcast , @jasonliu , do we need to create a NFC patch for the clang format problem of the above first ?