1
1
mirror of https://github.com/rui314/mold.git synced 2024-09-22 10:27:48 +03:00
mold/test/tls-nopic.c
2020-11-25 13:52:31 +09:00

31 lines
934 B
C

// RUN: cc -c -o %t1.o %s
// RUN: echo '_Thread_local int foo;' | cc -xc -c -o %t2.o -
// RUN: mold -o %t.exe /usr/lib/x86_64-linux-gnu/crt1.o \
// RUN: /usr/lib/x86_64-linux-gnu/crti.o \
// RUN: /usr/lib/gcc/x86_64-linux-gnu/9/crtbegin.o \
// RUN: %t1.o %t2.o \
// RUN: /usr/lib/gcc/x86_64-linux-gnu/9/libgcc.a \
// RUN: /usr/lib/x86_64-linux-gnu/libgcc_s.so.1 \
// RUN: /lib/x86_64-linux-gnu/libc.so.6 \
// RUN: /usr/lib/x86_64-linux-gnu/libc_nonshared.a \
// RUN: /lib/x86_64-linux-gnu/ld-linux-x86-64.so.2 \
// RUN: /usr/lib/gcc/x86_64-linux-gnu/9/crtend.o \
// RUN: /usr/lib/x86_64-linux-gnu/crtn.o
// RUN: %t.exe | grep '3 5 3 5'
#include <stdio.h>
extern _Thread_local int foo;
static _Thread_local int bar;
int *get_foo_addr() { return &foo; }
int *get_bar_addr() { return &bar; }
int main() {
foo = 3;
bar = 5;
printf("%d %d %d %d\n", *get_foo_addr(), *get_bar_addr(), foo, bar);
return 0;
}