以下是三个不同 .s 文件的一部分。.c 文件已使用三个不同的选项进行编译:
- -fno-inline -fstack-protector-strong,
- -fno-inline -fsanitize=地址,
- -fno-inline -fno-stack-protector -zexecstack。
以下是 .s 文件的内容:
handle_read:
.LFB20:
.cfi_startproc
pushq %r12
.cfi_def_cfa_offset 16
.cfi_offset 12, -16
pushq %rbp
.cfi_def_cfa_offset 24
.cfi_offset 6, -24
movq %rsi, %r12
pushq %rbx
.cfi_def_cfa_offset 32
.cfi_offset 3, -32
movq 8(%rdi), %rbx
movq %rdi, %rbp
movq 160(%rbx), %rsi
movq 152(%rbx), %rdx
cmpq %rdx, %rsi
jb .L394
cmpq $5000, %rdx
jbe .L421
handle_read:
.LASANPC20:
.LFB20:
.cfi_startproc
pushq %r15
.cfi_def_cfa_offset 16
.cfi_offset 15, -16
pushq %r14
.cfi_def_cfa_offset 24
.cfi_offset 14, -24
pushq %r13
.cfi_def_cfa_offset 32
.cfi_offset 13, -32
pushq %r12
.cfi_def_cfa_offset 40
.cfi_offset 12, -40
pushq %rbp
.cfi_def_cfa_offset 48
.cfi_offset 6, -48
movq %rdi, %rbp
addq $8, %rdi
pushq %rbx
.cfi_def_cfa_offset 56
.cfi_offset 3, -56
movq %rdi, %rax
shrq $3, %rax
subq $24, %rsp
.cfi_def_cfa_offset 80
cmpb $0, 2147450880(%rax)
jne .L1170
movq 8(%rbp), %rbx
leaq 160(%rbx), %r13
movq %r13, %r15
shrq $3, %r15
cmpb $0, 2147450880(%r15)
jne .L1171
leaq 152(%rbx), %r14
movq %rsi, %r12
movq 160(%rbx), %rsi
movq %r14, %rax
shrq $3, %rax
cmpb $0, 2147450880(%rax)
jne .L1172
movq 152(%rbx), %rdx
leaq 144(%rbx), %rcx
cmpq %rdx, %rsi
jb .L1054
cmpq $5000, %rdx
jbe .L1055
movl $httpd_err400form, %eax
shrq $3, %rax
cmpb $0, 2147450880(%rax)
jne .L1173
movl $httpd_err400title, %eax
movq httpd_err400form(%rip), %r8
shrq $3, %rax
cmpb $0, 2147450880(%rax)
jne .L1174
handle_read:
.LFB20:
.cfi_startproc
pushq %r12
.cfi_def_cfa_offset 16
.cfi_offset 12, -16
pushq %rbp
.cfi_def_cfa_offset 24
.cfi_offset 6, -24
movq %rsi, %r12
pushq %rbx
.cfi_def_cfa_offset 32
.cfi_offset 3, -32
movq 8(%rdi), %rbx
movq %rdi, %rbp
movq 160(%rbx), %rsi
movq 152(%rbx), %rdx
cmpq %rdx, %rsi
jb .L384
cmpq $5000, %rdx
jbe .L411
谁能告诉我这些代码如何防止缓冲区溢出?