a.c (481B)
1 /* --whole-archive: b.c is packaged as b.a and has no symbol referenced by a.c. 2 * With --whole-archive, b.o is included unconditionally so its constructor 3 * runs and b_get_flag() becomes available via a weak reference. 4 * Without --whole-archive, the weak reference resolves to NULL and the 5 * test returns 1 (fail). */ 6 extern __attribute__((weak)) int b_get_flag(void); 7 8 int test_main(void) { 9 if ((void*)b_get_flag == (void*)0) return 1; 10 return b_get_flag() == 1 ? 0 : 1; 11 }