a.c (726B)
1 /* Reference a thread-local symbol that is *not* a thread-local definition 2 * in the linked image. kit emits local-exec TLS only, so the symbol's 3 * tp-relative offset must be known at link time -- which holds only for a 4 * thread-local defined in this image. Here `shared` resolves to b.c's 5 * ordinary (non-TLS) global, so there is no valid TLS offset; the linker 6 * must reject this rather than bake in a bogus tp-relative offset. 7 * 8 * (clang lowers this external __thread reference to initial-exec on a 9 * non-PIC executable; kit's linker fills the IE GOT slot with the symbol's 10 * local-exec tp-offset, which is where the mismatch surfaces.) */ 11 extern _Thread_local int shared; 12 13 int test_main(void) { return shared; }