1// Assembly code for making x86 syscalls. 2// 3// On x86 we use the "fastcall" convention which passes the first two 4// arguments in ecx and edx. Outline.rs reorders the arguments to put 5// a1 and a2 in those registers so they we don't have to move them to 6// set up the kernel convention. 7// 8// "fastcall" expects callee to pop argument stack space, so we use 9// `ret imm` instructions to clean up the stack. We don't need callee 10// cleanup per se, it just comes along with using "fastcall". 11 12 .file "x86.s" 13 .intel_syntax noprefix 14 15 .section .text.rustix_indirect_syscall0_nr_last_fastcall,"ax",@progbits 16 .p2align 4 17 .weak rustix_indirect_syscall0_nr_last_fastcall 18 .hidden rustix_indirect_syscall0_nr_last_fastcall 19 .type rustix_indirect_syscall0_nr_last_fastcall, @function 20rustix_indirect_syscall0_nr_last_fastcall: 21 .cfi_startproc 22 mov eax,ecx 23 call edx 24 ret 25 .cfi_endproc 26 .size rustix_indirect_syscall0_nr_last_fastcall, .-rustix_indirect_syscall0_nr_last_fastcall 27 28 .section .text.rustix_indirect_syscall1_nr_last_fastcall,"ax",@progbits 29 .p2align 4 30 .weak rustix_indirect_syscall1_nr_last_fastcall 31 .hidden rustix_indirect_syscall1_nr_last_fastcall 32 .type rustix_indirect_syscall1_nr_last_fastcall, @function 33rustix_indirect_syscall1_nr_last_fastcall: 34 .cfi_startproc 35 push ebx 36 .cfi_def_cfa_offset 8 37 .cfi_offset ebx, -8 38 mov ebx,ecx 39 mov eax,edx 40 call DWORD PTR [esp+0x8] 41 pop ebx 42 .cfi_def_cfa_offset 4 43 ret 0x4 44 .cfi_endproc 45 .size rustix_indirect_syscall1_nr_last_fastcall, .-rustix_indirect_syscall1_nr_last_fastcall 46 47 .section .text.rustix_indirect_syscall1_noreturn_nr_last_fastcall,"ax",@progbits 48 .p2align 4 49 .weak rustix_indirect_syscall1_noreturn_nr_last_fastcall 50 .hidden rustix_indirect_syscall1_noreturn_nr_last_fastcall 51 .type rustix_indirect_syscall1_noreturn_nr_last_fastcall, @function 52rustix_indirect_syscall1_noreturn_nr_last_fastcall: 53 .cfi_startproc 54 mov ebx,ecx 55 mov eax,edx 56 call DWORD PTR [esp+0x4] 57 ud2 58 .cfi_endproc 59 .size rustix_indirect_syscall1_noreturn_nr_last_fastcall, .-rustix_indirect_syscall1_noreturn_nr_last_fastcall 60 61 .section .text.rustix_indirect_syscall2_nr_last_fastcall,"ax",@progbits 62 .p2align 4 63 .weak rustix_indirect_syscall2_nr_last_fastcall 64 .hidden rustix_indirect_syscall2_nr_last_fastcall 65 .type rustix_indirect_syscall2_nr_last_fastcall, @function 66rustix_indirect_syscall2_nr_last_fastcall: 67 .cfi_startproc 68 push ebx 69 .cfi_def_cfa_offset 8 70 .cfi_offset ebx, -8 71 mov ebx,edx 72 mov eax,DWORD PTR [esp+0x8] 73 call DWORD PTR [esp+0xc] 74 pop ebx 75 .cfi_def_cfa_offset 4 76 ret 0x8 77 .cfi_endproc 78 .size rustix_indirect_syscall2_nr_last_fastcall, .-rustix_indirect_syscall2_nr_last_fastcall 79 80 .section .text.rustix_indirect_syscall3_nr_last_fastcall,"ax",@progbits 81 .p2align 4 82 .weak rustix_indirect_syscall3_nr_last_fastcall 83 .hidden rustix_indirect_syscall3_nr_last_fastcall 84 .type rustix_indirect_syscall3_nr_last_fastcall, @function 85rustix_indirect_syscall3_nr_last_fastcall: 86 .cfi_startproc 87 push ebx 88 .cfi_def_cfa_offset 8 89 .cfi_offset ebx, -8 90 mov ebx,DWORD PTR [esp+0x8] 91 mov eax,DWORD PTR [esp+0xc] 92 call DWORD PTR [esp+0x10] 93 pop ebx 94 .cfi_def_cfa_offset 4 95 ret 0xc 96 .cfi_endproc 97 .size rustix_indirect_syscall3_nr_last_fastcall, .-rustix_indirect_syscall3_nr_last_fastcall 98 99 .section .text.rustix_indirect_syscall4_nr_last_fastcall,"ax",@progbits 100 .p2align 4 101 .weak rustix_indirect_syscall4_nr_last_fastcall 102 .hidden rustix_indirect_syscall4_nr_last_fastcall 103 .type rustix_indirect_syscall4_nr_last_fastcall, @function 104rustix_indirect_syscall4_nr_last_fastcall: 105 .cfi_startproc 106 push ebx 107 .cfi_def_cfa_offset 8 108 push esi 109 .cfi_def_cfa_offset 12 110 .cfi_offset esi, -12 111 .cfi_offset ebx, -8 112 mov ebx,DWORD PTR [esp+0xc] 113 mov esi,DWORD PTR [esp+0x10] 114 mov eax,DWORD PTR [esp+0x14] 115 call DWORD PTR [esp+0x18] 116 pop esi 117 .cfi_def_cfa_offset 8 118 pop ebx 119 .cfi_def_cfa_offset 4 120 ret 0x10 121 .cfi_endproc 122 .size rustix_indirect_syscall4_nr_last_fastcall, .-rustix_indirect_syscall4_nr_last_fastcall 123 124 .section .text.rustix_indirect_syscall5_nr_last_fastcall,"ax",@progbits 125 .p2align 4 126 .weak rustix_indirect_syscall5_nr_last_fastcall 127 .hidden rustix_indirect_syscall5_nr_last_fastcall 128 .type rustix_indirect_syscall5_nr_last_fastcall, @function 129rustix_indirect_syscall5_nr_last_fastcall: 130 .cfi_startproc 131 push ebx 132 .cfi_def_cfa_offset 8 133 push esi 134 .cfi_def_cfa_offset 12 135 push edi 136 .cfi_def_cfa_offset 16 137 .cfi_offset edi, -16 138 .cfi_offset esi, -12 139 .cfi_offset ebx, -8 140 mov ebx,DWORD PTR [esp+0x10] 141 mov esi,DWORD PTR [esp+0x14] 142 mov edi,DWORD PTR [esp+0x18] 143 mov eax,DWORD PTR [esp+0x1c] 144 call DWORD PTR [esp+0x20] 145 pop edi 146 .cfi_def_cfa_offset 12 147 pop esi 148 .cfi_def_cfa_offset 8 149 pop ebx 150 .cfi_def_cfa_offset 4 151 ret 0x14 152 .cfi_endproc 153 .size rustix_indirect_syscall5_nr_last_fastcall, .-rustix_indirect_syscall5_nr_last_fastcall 154 155 .section .text.rustix_indirect_syscall6_nr_last_fastcall,"ax",@progbits 156 .p2align 4 157 .weak rustix_indirect_syscall6_nr_last_fastcall 158 .hidden rustix_indirect_syscall6_nr_last_fastcall 159 .type rustix_indirect_syscall6_nr_last_fastcall, @function 160rustix_indirect_syscall6_nr_last_fastcall: 161 .cfi_startproc 162 push ebx 163 .cfi_def_cfa_offset 8 164 push esi 165 .cfi_def_cfa_offset 12 166 push edi 167 .cfi_def_cfa_offset 16 168 push ebp 169 .cfi_def_cfa_offset 20 170 .cfi_offset ebp, -20 171 .cfi_offset edi, -16 172 .cfi_offset esi, -12 173 .cfi_offset ebx, -8 174 mov ebx,DWORD PTR [esp+0x14] 175 mov esi,DWORD PTR [esp+0x18] 176 mov edi,DWORD PTR [esp+0x1c] 177 mov ebp,DWORD PTR [esp+0x20] 178 mov eax,DWORD PTR [esp+0x24] 179 call DWORD PTR [esp+0x28] 180 pop ebp 181 .cfi_def_cfa_offset 16 182 pop edi 183 .cfi_def_cfa_offset 12 184 pop esi 185 .cfi_def_cfa_offset 8 186 pop ebx 187 .cfi_def_cfa_offset 4 188 ret 0x18 189 .cfi_endproc 190 .size rustix_indirect_syscall6_nr_last_fastcall, .-rustix_indirect_syscall6_nr_last_fastcall 191 192 .section .text.rustix_syscall0_nr_last_fastcall,"ax",@progbits 193 .p2align 4 194 .weak rustix_syscall0_nr_last_fastcall 195 .hidden rustix_syscall0_nr_last_fastcall 196 .type rustix_syscall0_nr_last_fastcall, @function 197rustix_syscall0_nr_last_fastcall: 198 .cfi_startproc 199 mov eax,ecx 200 int 0x80 201 ret 202 .cfi_endproc 203 .size rustix_syscall0_nr_last_fastcall, .-rustix_syscall0_nr_last_fastcall 204 205 .section .text.rustix_syscall1_nr_last_fastcall,"ax",@progbits 206 .p2align 4 207 .weak rustix_syscall1_nr_last_fastcall 208 .hidden rustix_syscall1_nr_last_fastcall 209 .type rustix_syscall1_nr_last_fastcall, @function 210rustix_syscall1_nr_last_fastcall: 211 .cfi_startproc 212 push ebx 213 .cfi_def_cfa_offset 8 214 .cfi_offset ebx, -8 215 mov eax,edx 216 mov ebx,ecx 217 int 0x80 218 pop ebx 219 .cfi_def_cfa_offset 4 220 ret 221 .cfi_endproc 222 .size rustix_syscall1_nr_last_fastcall, .-rustix_syscall1_nr_last_fastcall 223 224 .section .text.rustix_syscall1_noreturn_nr_last_fastcall,"ax",@progbits 225 .p2align 4 226 .weak rustix_syscall1_noreturn_nr_last_fastcall 227 .hidden rustix_syscall1_noreturn_nr_last_fastcall 228 .type rustix_syscall1_noreturn_nr_last_fastcall, @function 229rustix_syscall1_noreturn_nr_last_fastcall: 230 .cfi_startproc 231 mov eax,edx 232 mov ebx,ecx 233 int 0x80 234 ud2 235 .cfi_endproc 236 .size rustix_syscall1_noreturn_nr_last_fastcall, .-rustix_syscall1_noreturn_nr_last_fastcall 237 238 .section .text.rustix_syscall2_nr_last_fastcall,"ax",@progbits 239 .p2align 4 240 .weak rustix_syscall2_nr_last_fastcall 241 .hidden rustix_syscall2_nr_last_fastcall 242 .type rustix_syscall2_nr_last_fastcall, @function 243rustix_syscall2_nr_last_fastcall: 244 .cfi_startproc 245 push ebx 246 .cfi_def_cfa_offset 8 247 .cfi_offset ebx, -8 248 mov ebx,edx 249 mov eax,DWORD PTR [esp+0x8] 250 int 0x80 251 pop ebx 252 .cfi_def_cfa_offset 4 253 ret 0x4 254 .cfi_endproc 255 .size rustix_syscall2_nr_last_fastcall, .-rustix_syscall2_nr_last_fastcall 256 257 .section .text.rustix_syscall3_nr_last_fastcall,"ax",@progbits 258 .p2align 4 259 .weak rustix_syscall3_nr_last_fastcall 260 .hidden rustix_syscall3_nr_last_fastcall 261 .type rustix_syscall3_nr_last_fastcall, @function 262rustix_syscall3_nr_last_fastcall: 263 .cfi_startproc 264 push ebx 265 .cfi_def_cfa_offset 8 266 .cfi_offset ebx, -8 267 mov ebx,DWORD PTR [esp+0x8] 268 mov eax,DWORD PTR [esp+0xc] 269 int 0x80 270 pop ebx 271 .cfi_def_cfa_offset 4 272 ret 0x8 273 .cfi_endproc 274 .size rustix_syscall3_nr_last_fastcall, .-rustix_syscall3_nr_last_fastcall 275 276 .section .text.rustix_syscall4_nr_last_fastcall,"ax",@progbits 277 .p2align 4 278 .weak rustix_syscall4_nr_last_fastcall 279 .hidden rustix_syscall4_nr_last_fastcall 280 .type rustix_syscall4_nr_last_fastcall, @function 281rustix_syscall4_nr_last_fastcall: 282 .cfi_startproc 283 push ebx 284 .cfi_def_cfa_offset 8 285 push esi 286 .cfi_def_cfa_offset 12 287 .cfi_offset esi, -12 288 .cfi_offset ebx, -8 289 mov ebx,DWORD PTR [esp+0xc] 290 mov esi,DWORD PTR [esp+0x10] 291 mov eax,DWORD PTR [esp+0x14] 292 int 0x80 293 pop esi 294 .cfi_def_cfa_offset 8 295 pop ebx 296 .cfi_def_cfa_offset 4 297 ret 0xc 298 .cfi_endproc 299 .size rustix_syscall4_nr_last_fastcall, .-rustix_syscall4_nr_last_fastcall 300 301 .section .text.rustix_syscall5_nr_last_fastcall,"ax",@progbits 302 .p2align 4 303 .weak rustix_syscall5_nr_last_fastcall 304 .hidden rustix_syscall5_nr_last_fastcall 305 .type rustix_syscall5_nr_last_fastcall, @function 306rustix_syscall5_nr_last_fastcall: 307 .cfi_startproc 308 push ebx 309 .cfi_def_cfa_offset 8 310 push edi 311 .cfi_def_cfa_offset 12 312 push esi 313 .cfi_def_cfa_offset 16 314 .cfi_offset esi, -16 315 .cfi_offset edi, -12 316 .cfi_offset ebx, -8 317 mov ebx,DWORD PTR [esp+0x10] 318 mov esi,DWORD PTR [esp+0x14] 319 mov edi,DWORD PTR [esp+0x18] 320 mov eax,DWORD PTR [esp+0x1c] 321 int 0x80 322 pop esi 323 .cfi_def_cfa_offset 12 324 pop edi 325 .cfi_def_cfa_offset 8 326 pop ebx 327 .cfi_def_cfa_offset 4 328 ret 0x10 329 .cfi_endproc 330 .size rustix_syscall5_nr_last_fastcall, .-rustix_syscall5_nr_last_fastcall 331 332 .section .text.rustix_syscall6_nr_last_fastcall,"ax",@progbits 333 .p2align 4 334 .weak rustix_syscall6_nr_last_fastcall 335 .hidden rustix_syscall6_nr_last_fastcall 336 .type rustix_syscall6_nr_last_fastcall, @function 337rustix_syscall6_nr_last_fastcall: 338 .cfi_startproc 339 push ebp 340 .cfi_def_cfa_offset 8 341 push ebx 342 .cfi_def_cfa_offset 12 343 push edi 344 .cfi_def_cfa_offset 16 345 push esi 346 .cfi_def_cfa_offset 20 347 .cfi_offset esi, -20 348 .cfi_offset edi, -16 349 .cfi_offset ebx, -12 350 .cfi_offset ebp, -8 351 mov ebx,DWORD PTR [esp+0x14] 352 mov esi,DWORD PTR [esp+0x18] 353 mov edi,DWORD PTR [esp+0x1c] 354 mov ebp,DWORD PTR [esp+0x20] 355 mov eax,DWORD PTR [esp+0x24] 356 int 0x80 357 pop esi 358 .cfi_def_cfa_offset 16 359 pop edi 360 .cfi_def_cfa_offset 12 361 pop ebx 362 .cfi_def_cfa_offset 8 363 pop ebp 364 .cfi_def_cfa_offset 4 365 ret 0x14 366 .cfi_endproc 367 .size rustix_syscall6_nr_last_fastcall, .-rustix_syscall6_nr_last_fastcall 368 369 .section .text.rustix_int_0x80,"ax",@progbits 370 .p2align 4 371 .weak rustix_int_0x80 372 .hidden rustix_int_0x80 373 .type rustix_int_0x80, @function 374rustix_int_0x80: 375 .cfi_startproc 376 int 0x80 377 ret 378 .cfi_endproc 379 .size rustix_int_0x80, .-rustix_int_0x80 380 381 .section .note.GNU-stack,"",@progbits 382