linux中g s在文件中的使用方法,Linux 内核中的.S文件 | 灵犀志趣

$ find . -name "*.S" | wc -l

1235

可以看到在Linux kernel 3.1的内核中,有上千个.S文件。

这些文件多数分布在arch/下各个体系结构中。

如下是X86的.S文件:

./arch/x86/power/hibernate_asm_64.S

./arch/x86/power/hibernate_asm_32.S

./arch/x86/boot/compressed/head_32.S

./arch/x86/boot/compressed/vmlinux.lds.S

./arch/x86/boot/compressed/head_64.S

./arch/x86/boot/bioscall.S

./arch/x86/boot/header.S

./arch/x86/boot/pmjump.S

./arch/x86/boot/copy.S

./arch/x86/net/bpf_jit.S

./arch/x86/vdso/vdso-layout.lds.S

./arch/x86/vdso/vdso.S

./arch/x86/vdso/vdso32.S

./arch/x86/vdso/vdso.lds.S

./arch/x86/vdso/vdso-note.S

./arch/x86/vdso/vdso32/syscall.S

./arch/x86/vdso/vdso32/note.S

./arch/x86/vdso/vdso32/sysenter.S

./arch/x86/vdso/vdso32/sigreturn.S

./arch/x86/vdso/vdso32/vdso32.lds.S

./arch/x86/vdso/vdso32/int80.S

./arch/x86/math-emu/div_small.S

./arch/x86/math-emu/reg_u_mul.S

./arch/x86/math-emu/reg_u_sub.S

./arch/x86/math-emu/wm_sqrt.S

./arch/x86/math-emu/div_Xsig.S

./arch/x86/math-emu/shr_Xsig.S

./arch/x86/math-emu/polynom_Xsig.S

./arch/x86/math-emu/round_Xsig.S

./arch/x86/math-emu/reg_round.S

./arch/x86/math-emu/reg_u_add.S

./arch/x86/math-emu/mul_Xsig.S

./arch/x86/math-emu/reg_u_div.S

./arch/x86/math-emu/reg_norm.S

./arch/x86/math-emu/wm_shrx.S

./arch/x86/xen/xen-asm_32.S

./arch/x86/xen/xen-head.S

./arch/x86/xen/xen-asm.S

./arch/x86/xen/xen-asm_64.S

./arch/x86/lguest/i386_head.S

./arch/x86/crypto/aesni-intel_asm.S

./arch/x86/crypto/aes-i586-asm_32.S

./arch/x86/crypto/ghash-clmulni-intel_asm.S

./arch/x86/crypto/salsa20-x86_64-asm_64.S

./arch/x86/crypto/aes-x86_64-asm_64.S

./arch/x86/crypto/salsa20-i586-asm_32.S

./arch/x86/crypto/twofish-x86_64-asm_64.S

./arch/x86/crypto/twofish-i586-asm_32.S

./arch/x86/kernel/relocate_kernel_32.S

./arch/x86/kernel/head_32.S

./arch/x86/kernel/relocate_kernel_64.S

./arch/x86/kernel/reboot_32.S

./arch/x86/kernel/syscall_table_32.S

./arch/x86/kernel/vmlinux.lds.S

./arch/x86/kernel/trampoline_32.S

./arch/x86/kernel/trampoline_64.S

./arch/x86/kernel/entry_64.S

./arch/x86/kernel/vsyscall_emu_64.S

./arch/x86/kernel/head_64.S

./arch/x86/kernel/verify_cpu.S

./arch/x86/kernel/entry_32.S

./arch/x86/kernel/acpi/realmode/wakeup.lds.S

./arch/x86/kernel/acpi/realmode/bioscall.S

./arch/x86/kernel/acpi/realmode/wakeup.S

./arch/x86/kernel/acpi/realmode/copy.S

./arch/x86/kernel/acpi/wakeup_32.S

./arch/x86/kernel/acpi/wakeup_rm.S

./arch/x86/kernel/acpi/wakeup_64.S

./arch/x86/platform/olpc/xo1-wakeup.S

./arch/x86/platform/efi/efi_stub_32.S

./arch/x86/platform/efi/efi_stub_64.S

./arch/x86/lib/memcpy_64.S

./arch/x86/lib/cmpxchg8b_emu.S

./arch/x86/lib/rwlock.S

./arch/x86/lib/iomap_copy_64.S

./arch/x86/lib/atomic64_386_32.S

./arch/x86/lib/copy_page_64.S

./arch/x86/lib/memmove_64.S

./arch/x86/lib/thunk_32.S

./arch/x86/lib/copy_user_nocache_64.S

./arch/x86/lib/rwsem.S

./arch/x86/lib/cmpxchg16b_emu.S

./arch/x86/lib/clear_page_64.S

./arch/x86/lib/memset_64.S

./arch/x86/lib/msr-reg.S

./arch/x86/lib/atomic64_cx8_32.S

./arch/x86/lib/getuser.S

./arch/x86/lib/csum-copy_64.S

./arch/x86/lib/thunk_64.S

./arch/x86/lib/putuser.S

./arch/x86/lib/copy_user_64.S

./arch/x86/lib/checksum_32.S

./arch/x86/ia32/ia32entry.S

可以发现休眠、启动、数学运算、虚拟机支持、加密、锁机制、系统调用有关。

这些功能之所以使用汇编而非普通C语言,有两方面的原因

实现特权控制

加速

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值