Skip to content

Commit bfed7e5

Browse files
authored
Merge pull request #212 from smartobjectoriented/211-align-existing-syscall
Align existing syscalls
2 parents 5088531 + 9d8fd89 commit bfed7e5

File tree

26 files changed

+501
-225
lines changed

26 files changed

+501
-225
lines changed

so3/arch/arm32/include/asm/syscall_number.h

Lines changed: 67 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -24,61 +24,82 @@
2424
*/
2525

2626
#define SYSCALL_EXIT 1
27-
#define SYSCALL_EXECVE 2
28-
#define SYSCALL_WAITPID 3
29-
#define SYSCALL_READ 4
30-
#define SYSCALL_WRITE 5
31-
#define SYSCALL_FORK 7
32-
#define SYSCALL_PTRACE 8
33-
#define SYSCALL_READDIR 9
34-
#define SYSCALL_OPEN 14
35-
#define SYSCALL_CLOSE 15
36-
#define SYSCALL_THREAD_CREATE 16
37-
#define SYSCALL_THREAD_JOIN 17
38-
#define SYSCALL_THREAD_EXIT 18
39-
#define SYSCALL_PIPE 19
40-
#define SYSCALL_IOCTL 20
41-
#define SYSCALL_FCNTL 21
42-
#define SYSCALL_DUP 22
43-
#define SYSCALL_DUP2 23
44-
45-
#define SYSCALL_SOCKET 26
46-
#define SYSCALL_BIND 27
47-
#define SYSCALL_LISTEN 28
48-
#define SYSCALL_ACCEPT 29
49-
#define SYSCALL_CONNECT 30
50-
#define SYSCALL_RECV 31
51-
#define SYSCALL_SEND 32
52-
#define SYSCALL_SENDTO 33
53-
54-
#define SYSCALL_STAT 34
55-
#define SYSCALL_MMAP 35
56-
#define SYSCALL_GETPID 37
57-
58-
#define SYSCALL_GETTIMEOFDAY 38
59-
#define SYSCALL_SETTIMEOFDAY 39
60-
#define SYSCALL_CLOCK_GETTIME 40
27+
#define SYSCALL_FORK 2
28+
#define SYSCALL_READ 3
29+
#define SYSCALL_WRITE 4
30+
#define SYSCALL_OPEN 5
31+
#define SYSCALL_CLOSE 6
6132

62-
#define SYSCALL_THREAD_YIELD 43
33+
#define SYSCALL_EXECVE 11
6334

64-
#define SYSCALL_SBRK 45
65-
#define SYSCALL_SIGACTION 46
66-
#define SYSCALL_KILL 47
67-
#define SYSCALL_SIGRETURN 48
35+
#define SYSCALL_LSEEK 19
36+
#define SYSCALL_GETPID 20
6837

69-
#define SYSCALL_LSEEK 50
38+
#define SYSCALL_PTRACE 26
7039

71-
#define SYSCALL_MUTEX_LOCK 60
72-
#define SYSCALL_MUTEX_UNLOCK 61
40+
#define SYSCALL_KILL 37
41+
42+
#define SYSCALL_DUP 41
43+
#define SYSCALL_PIPE 42
44+
45+
#define SYSCALL_BRK 45
7346

74-
#define SYSCALL_NANOSLEEP 70
47+
#define SYSCALL_IOCTL 54
7548

76-
#define SYSCALL_SYSINFO 99
49+
#define SYSCALL_DUP2 63
7750

78-
#define SYSCALL_SETSOCKOPT 110
79-
#define SYSCALL_RECVFROM 111
51+
#define SYSCALL_GETTIMEOFDAY_TIME32 78
52+
53+
#define SYSCALL_WAIT4 114
54+
55+
#define SYSCALL_SIGRETURN 119
8056

8157
#define SYSCALL_READV 145
8258
#define SYSCALL_WRITEV 146
8359

60+
#define SYSCALL_NANOSLEEP 162
61+
62+
#define SYSCALL_RT_SIGRETURN 173
63+
#define SYSCALL_RT_SIGACTION 174
64+
65+
#define SYSCALL_MMAP2 192
66+
67+
#define SYSCALL_STAT64 195
68+
69+
#define SYSCALL_GETDENTS64 217
70+
71+
#define SYSCALL_CLOCK_GETTIME32 263
72+
73+
#define SYSCALL_SOCKET 281
74+
#define SYSCALL_BIND 282
75+
#define SYSCALL_CONNECT 283
76+
#define SYSCALL_LISTEN 284
77+
#define SYSCALL_ACCEPT 285
78+
79+
#define SYSCALL_SEND 289
80+
#define SYSCALL_SENDTO 290
81+
82+
#define SYSCALL_RECV 291
83+
#define SYSCALL_RECVFROM 292
84+
85+
#define SYSCALL_SETSOCKOPT 294
86+
87+
#define SYSCALL_OPENAT 322
88+
89+
#define SYSCALL_FSTATAT64 327
90+
91+
#define SYSCALL_DUP3 358
92+
#define SYSCALL_PIPE2 359
93+
94+
#define SYSCALL_CLOCK_GETTIME64 403
95+
96+
/* Following syscalls still need to be aligned */
97+
#define SYSCALL_THREAD_CREATE 16
98+
#define SYSCALL_THREAD_JOIN 17
99+
#define SYSCALL_THREAD_EXIT 18
100+
#define SYSCALL_THREAD_YIELD 43
101+
102+
#define SYSCALL_MUTEX_LOCK 60
103+
#define SYSCALL_MUTEX_UNLOCK 61
104+
84105
#endif /* ARCH_ARM32_SYSCALL_NUMBER_H */

so3/arch/arm64/exception.S

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -557,7 +557,7 @@ el01_sync_handler:
557557

558558
// Check if sigreturn has been called. In this case, we
559559
// clean the stack frame which has been used to manage the user handler.
560-
cmp x8, #SYSCALL_SIGRETURN
560+
cmp x8, #SYSCALL_RT_SIGRETURN
561561
bne __ret_from_fork
562562
563563
// Reset the stack frame by removing the one issued from sigreturn

so3/arch/arm64/include/asm/syscall_number.h

Lines changed: 56 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -22,63 +22,70 @@
2222
/*
2323
* Syscall number definition
2424
*/
25+
#define SYSCALL_DUP 23
26+
#define SYSCALL_DUP3 24
2527

26-
#define SYSCALL_EXIT 1
27-
#define SYSCALL_EXECVE 2
28-
#define SYSCALL_WAITPID 3
29-
#define SYSCALL_READ 4
30-
#define SYSCALL_WRITE 5
31-
#define SYSCALL_FORK 7
32-
#define SYSCALL_PTRACE 8
33-
#define SYSCALL_READDIR 9
34-
#define SYSCALL_OPEN 14
35-
#define SYSCALL_CLOSE 15
36-
#define SYSCALL_THREAD_CREATE 16
37-
#define SYSCALL_THREAD_JOIN 17
38-
#define SYSCALL_THREAD_EXIT 18
39-
#define SYSCALL_PIPE 19
40-
#define SYSCALL_IOCTL 20
41-
#define SYSCALL_FCNTL 21
42-
#define SYSCALL_DUP 22
43-
#define SYSCALL_DUP2 23
44-
45-
#define SYSCALL_SOCKET 26
46-
#define SYSCALL_BIND 27
47-
#define SYSCALL_LISTEN 28
48-
#define SYSCALL_ACCEPT 29
49-
#define SYSCALL_CONNECT 30
50-
#define SYSCALL_RECV 31
51-
#define SYSCALL_SEND 32
52-
#define SYSCALL_SENDTO 33
53-
54-
#define SYSCALL_STAT 34
55-
#define SYSCALL_MMAP 35
56-
#define SYSCALL_GETPID 37
57-
58-
#define SYSCALL_GETTIMEOFDAY 38
59-
#define SYSCALL_SETTIMEOFDAY 39
60-
#define SYSCALL_CLOCK_GETTIME 40
61-
62-
#define SYSCALL_THREAD_YIELD 43
63-
64-
#define SYSCALL_SBRK 45
65-
#define SYSCALL_SIGACTION 46
66-
#define SYSCALL_KILL 47
67-
#define SYSCALL_SIGRETURN 48
28+
#define SYSCALL_IOCTL 29
6829

69-
#define SYSCALL_LSEEK 50
30+
#define SYSCALL_OPENAT 56
31+
#define SYSCALL_CLOSE 57
7032

71-
#define SYSCALL_MUTEX_LOCK 60
72-
#define SYSCALL_MUTEX_UNLOCK 61
33+
#define SYSCALL_PIPE2 59
7334

35+
#define SYSCALL_GETDENTS64 61
36+
#define SYSCALL_LSEEK 62
37+
#define SYSCALL_READ 63
38+
#define SYSCALL_WRITE 64
7439
#define SYSCALL_READV 65
7540
#define SYSCALL_WRITEV 66
7641

77-
#define SYSCALL_NANOSLEEP 70
42+
#define SYSCALL_NEWFSTATAT 79
43+
44+
#define SYSCALL_EXIT 93
45+
46+
#define SYSCALL_NANOSLEEP 101
47+
48+
#define SYSCALL_CLOCK_GETTIME 113
49+
50+
#define SYSCALL_PTRACE 117
51+
52+
#define SYSCALL_KILL 129
53+
54+
#define SYSCALL_RT_SIGACTION 134
55+
56+
#define SYSCALL_RT_SIGRETURN 139
7857

79-
#define SYSCALL_SYSINFO 99
58+
#define SYSCALL_GETTIMEOFDAY 169
8059

81-
#define SYSCALL_SETSOCKOPT 110
82-
#define SYSCALL_RECVFROM 111
60+
#define SYSCALL_GETPID 172
61+
62+
#define SYSCALL_SOCKET 198
63+
64+
#define SYSCALL_BIND 200
65+
#define SYSCALL_LISTEN 201
66+
#define SYSCALL_ACCEPT 202
67+
#define SYSCALL_CONNECT 203
68+
69+
#define SYSCALL_SENDTO 206
70+
#define SYSCALL_RECVFROM 207
71+
#define SYSCALL_SETSOCKOPT 208
72+
73+
#define SYSCALL_BRK 214
74+
75+
#define SYSCALL_EXECVE 221
76+
#define SYSCALL_MMAP 222
77+
78+
#define SYSCALL_WAIT4 260
79+
80+
/* Following syscalls still need to be aligned */
81+
#define SYSCALL_FORK 7 // => clone
82+
83+
#define SYSCALL_THREAD_CREATE 16
84+
#define SYSCALL_THREAD_JOIN 17
85+
#define SYSCALL_THREAD_EXIT 18
86+
#define SYSCALL_THREAD_YIELD 43
87+
88+
#define SYSCALL_MUTEX_LOCK 60
89+
#define SYSCALL_MUTEX_UNLOCK 61
8390

8491
#endif /* ARCH_ARM64_SYSCALL_NUMBER_H */

so3/fs/elf.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,12 @@ uint8_t *elf_load_buffer(const char *filename)
3535
struct stat st;
3636

3737
/* open and read file */
38-
fd = sys_do_open(filename, O_RDONLY);
38+
fd = sys_do_open(filename, O_RDONLY, 0);
3939

4040
if (fd < 0)
4141
return NULL;
4242

43-
if (sys_do_stat(filename, &st))
43+
if (sys_do_newfstatat(AT_FDCWD, filename, &st, 0))
4444
return NULL;
4545

4646
if (!st.st_size)

so3/fs/fat/fat.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -415,8 +415,7 @@ int fat_stat(const char *path, struct stat *st)
415415
}
416416

417417
time_fat_fat2so3(finfo.fdate, finfo.ftime, &tm);
418-
st->st_mtim = tm.tv_sec;
419-
strcpy(st->st_name, path);
418+
st->st_mtime = tm.tv_sec;
420419
st->st_size = finfo.fsize;
421420

422421
return 0;

0 commit comments

Comments
 (0)