Transport Line 运输线路
联系我们 CONTACT US
- 手机:
- 13988889999
- 电话:
- 0898-88889999
- 邮箱:
- admin@youweb.com
- 地址:
- 海南省海口市
新闻动态NEWS
当前位置: 首页 > 新闻动态
你知道自修改代码(Self-Modified Code, SMC)在哪些场景有应用?
发布时间:2025-06-28 00:30:16 点击量:432
<
Linux kernel 在启动时如果发现 CPU 只有一个核,会把所有 LOCK 前缀都修改为 NOP。
为了高效实现修改,代码里做了一个很骚的操作来把所有 LOCK 前缀的位置保存下来: #define LOCK_PREFIX_HERE \ ".pushsection .smp_locks,\"a\" " \ ".balign 4 " \ ".long 671f - . " /* offset */ \ ".popsection " \ "671:" #define LOCK_PREFIX LOCK_PREFIX_HERE " \tlock "(以上代码见 arch/x86/include/asm/alternativ…。