File tree Expand file tree Collapse file tree 28 files changed +1549
-172
lines changed
Expand file tree Collapse file tree 28 files changed +1549
-172
lines changed Original file line number Diff line number Diff line change 11#include <stdio.h>
22
33// Initialized thread-local object (.tdata):
4- __thread int i = 4 ;
4+ __thread int initialized1 = 4 ;
55
66// Uninitialized thread-local object (.tbss):
7- __thread int j ;
7+ __thread int uninitialized1 ;
88
9- __thread long k = 10 ;
9+ __thread long initialized2 = 10 ;
1010
11- __thread int l ;
11+ __thread int uninitialized2 ;
1212
1313int main ()
1414{
15- i ++ ;
16- printf ("%d\n" , i );
17- j ++ ;
18- printf ("%d\n" , j );
19- k ++ ;
20- printf ("%ld\n" , k );
21- l ++ ;
22- printf ("%d\n" , l );
15+ initialized1 ++ ;
16+ printf ("%d\n" , initialized1 );
17+ uninitialized1 ++ ;
18+ printf ("%d\n" , uninitialized1 );
19+ initialized2 ++ ;
20+ printf ("%ld\n" , initialized2 );
21+ uninitialized2 ++ ;
22+ printf ("%d\n" , uninitialized2 );
2323}
Original file line number Diff line number Diff line change 1+ CC ="gcc"
2+ CFLAGS =
3+ EXEC =
4+
5+ all : tls.c tls_def.c ex.c
6+ $(CC ) -fPIC -c tls.c " -ftls-model=global-dynamic" $(CFLAGS ) -o tls.o
7+ $(CC ) -fPIC -c tls_def.c " -ftls-model=global-dynamic" $(CFLAGS ) -o tls_def.o
8+ $(CC ) -shared -o libtls.so tls.o tls_def.o
9+ $(CC ) ex.c -fPIC $(CFLAGS ) -ltls -L./ -o ex
10+ @LD_LIBRARY_PATH=$LD_LIBRARY_PATH :. $(EXEC ) ./ex > out.txt
11+ clean :
12+ rm -f ex out.txt
13+ rm -fr ex.unstripped * .old* * .s dl_files * .gtirb * .o * .so
14+ check :
15+ @LD_LIBRARY_PATH=$LD_LIBRARY_PATH :. $(EXEC ) ./ex > /tmp/res.txt
16+ @ diff out.txt /tmp/res.txt && echo TEST OK
Original file line number Diff line number Diff line change 1+ #include <stdio.h>
2+
3+ extern int foo (void );
4+
5+ int main (void )
6+ {
7+ printf ("foo() = %d\n" , foo ());
8+ return 0 ;
9+ }
Original file line number Diff line number Diff line change 1+ #include <stdio.h>
2+
3+ extern __thread int initialized1 ;
4+
5+ extern __thread int uninitialized1 ;
6+
7+ extern __thread long initialized2 ;
8+
9+ extern __thread int uninitialized2 ;
10+
11+ int foo ()
12+ {
13+ initialized1 ++ ;
14+ printf ("%d\n" , initialized1 );
15+ uninitialized1 ++ ;
16+ printf ("%d\n" , uninitialized1 );
17+ initialized2 ++ ;
18+ printf ("%ld\n" , initialized2 );
19+ uninitialized2 ++ ;
20+ printf ("%d\n" , uninitialized2 );
21+
22+ return initialized1 + uninitialized1 + initialized2 + uninitialized2 ;
23+ }
Original file line number Diff line number Diff line change 1+ // Initialized thread-local object (.tdata):
2+ __thread int initialized1 = 4 ;
3+
4+ // Uninitialized thread-local object (.tbss):
5+ __thread int uninitialized1 ;
6+
7+ __thread long initialized2 = 10 ;
8+
9+ __thread int uninitialized2 ;
Original file line number Diff line number Diff line change 1+ CC ="gcc"
2+ CFLAGS =
3+ EXEC =
4+
5+ all : ex.c tls_def.c tls.c
6+ $(CC ) -fPIC -c tls.c " -ftls-model=initial-exec" $(CFLAGS ) -o tls.o
7+ $(CC ) -fPIC -c tls_def.c " -ftls-model=initial-exec" $(CFLAGS ) -o tls_def.o
8+ $(CC ) -shared -o libtls.so tls.o tls_def.o
9+ $(CC ) ex.c -fPIC $(CFLAGS ) -ltls -L./ -o ex
10+ @LD_LIBRARY_PATH=$LD_LIBRARY_PATH :. $(EXEC ) ./ex > out.txt
11+ clean :
12+ rm -f ex out.txt
13+ rm -fr ex.unstripped * .old* * .s dl_files * .gtirb * .o * .so
14+ check :
15+ @LD_LIBRARY_PATH=$LD_LIBRARY_PATH :. $(EXEC ) ./ex > /tmp/res.txt
16+ @ diff out.txt /tmp/res.txt && echo TEST OK
Original file line number Diff line number Diff line change 1+ #include <stdio.h>
2+
3+ extern int foo (void );
4+
5+ int main (void )
6+ {
7+ printf ("foo() = %d\n" , foo ());
8+ return 0 ;
9+ }
Original file line number Diff line number Diff line change 1+ #include <stdio.h>
2+
3+ extern __thread int initialized1 ;
4+
5+ extern __thread int uninitialized1 ;
6+
7+ extern __thread long initialized2 ;
8+
9+ extern __thread int uninitialized2 ;
10+
11+ int foo ()
12+ {
13+ initialized1 ++ ;
14+ printf ("%d\n" , initialized1 );
15+ uninitialized1 ++ ;
16+ printf ("%d\n" , uninitialized1 );
17+ initialized2 ++ ;
18+ printf ("%ld\n" , initialized2 );
19+ uninitialized2 ++ ;
20+ printf ("%d\n" , uninitialized2 );
21+
22+ return initialized1 + uninitialized1 + initialized2 + uninitialized2 ;
23+ }
Original file line number Diff line number Diff line change 1+ // Initialized thread-local object (.tdata):
2+ __thread int initialized1 = 4 ;
3+
4+ // Uninitialized thread-local object (.tbss):
5+ __thread int uninitialized1 ;
6+
7+ __thread long initialized2 = 10 ;
8+
9+ __thread int uninitialized2 ;
Original file line number Diff line number Diff line change 1+ CC ="gcc"
2+ CFLAGS =
3+ EXEC =
4+
5+ all : tls.c tls_def.c ex.c
6+ $(CC ) -fPIC -c tls.c " -ftls-model=local-dynamic" $(CFLAGS ) -o tls.o
7+ $(CC ) -fPIC -c tls_def.c " -ftls-model=local-dynamic" $(CFLAGS ) -o tls_def.o
8+ $(CC ) -shared -o libtls.so tls.o tls_def.o
9+ $(CC ) ex.c -fPIC $(CFLAGS ) -ltls -L./ -o ex
10+ @LD_LIBRARY_PATH=$LD_LIBRARY_PATH :. $(EXEC ) ./ex > out.txt
11+ clean :
12+ rm -f ex out.txt
13+ rm -fr ex.unstripped * .old* * .s dl_files * .gtirb * .o * .so
14+ check :
15+ @LD_LIBRARY_PATH=$LD_LIBRARY_PATH :. $(EXEC ) ./ex > /tmp/res.txt
16+ @ diff out.txt /tmp/res.txt && echo TEST OK
You can’t perform that action at this time.
0 commit comments