Skip to content

Commit 960750f

Browse files
committed
Merge branch 'mips-support' into 'main'
Fix MIPS operand symbolization See merge request rewriting/ddisasm!1251
2 parents 0c6c4f5 + d11591a commit 960750f

File tree

28 files changed

+1549
-172
lines changed

28 files changed

+1549
-172
lines changed

examples/ex_thread_local/ex.c

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,23 @@
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

1313
int 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
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
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
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
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+
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
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+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
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;
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
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

examples/ex_tls_initial_exec/ex.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
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+
}

examples/ex_tls_initial_exec/tls.c

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
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+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
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;
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
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

0 commit comments

Comments
 (0)