[PATCH] modutils: fix config options dependency (2)
Kang-Che Sung
explorer09 at gmail.com
Tue Feb 7 16:52:53 UTC 2017
On Tue, Feb 7, 2017 at 11:40 PM, Denys Vlasenko
<vda.linux at googlemail.com> wrote:
> On Tue, Feb 7, 2017 at 4:38 PM, Kang-Che Sung <explorer09 at gmail.com> wrote:
>> On Tue, Feb 7, 2017 at 11:21 PM, Denys Vlasenko
>> <vda.linux at googlemail.com> wrote:
>>>
>>> How about this?
>>>
>>> - if (is_depmod || is_modprobe) {
>>> + if ((MOD_APPLET_CNT == 2 && ENABLE_MODPROBE && ENABLE_DEPMOD)
>>> + || is_depmod || is_modprobe
>>> + ) {
>>
>> You can imagine how it will evaluate for this configuration:
>>
>> #define ENABLE_DEPMOD 1
>> #define ENABLE_MODPROBE 1
>> #define ENABLE_INSMOD 1
>> /* ENABLE_RMMOD is not set */
>>
>> MOD_APPLET_CNT==3
>>
>> (MOD_APPLET_CNT == 2) evaluates to false (0)
>> is_depmod expands to (applet_name[0]=='d')
>> is_modprobe expands to (applet_name[0]=='m')
>>
>> So the whole expression becomes
>> (applet_name[0]=='d' || applet_name[0]=='m')
>>
>> I would prefer the smaller comparison: (applet_name[0] != 'i')
>> Or the equal sized one: (applet_name[0] & '\4')
>>
>> This is the MOD_APPLET_CNT==3 case that I've thought of.
>
> The difference would be +1 2-byte asm instruction on x86.
No, actually it's +2 2-byte asm instructions, one for "cmp" and one for "je".
I just tried compiling it in gcc-6.3.0, and disassembled to read which
instructions are added. And so I'm sure this is the result.
Attaching part of my "objdump -d -r modprobe-small.o" output
Disassembly of section .text.modprobe_main:
[---truncated---]
34: 48 8b 05 00 00 00 00 mov 0x0(%rip),%rax # 3b
<modprobe_main+0x3b>
37: R_X86_64_PC32 applet_name-0x4
3b: 8a 00 mov (%rax),%al
3d: 3c 64 cmp $0x64,%al
3f: 74 04 je 45 <modprobe_main+0x45>
41: 3c 6d cmp $0x6d,%al
43: 75 14 jne 59 <modprobe_main+0x59>
45: bf 00 00 00 00 mov $0x0,%edi
46: R_X86_64_32 .rodata.modprobe_main.str1.1 #
CONFIG_DEFAULT_MODULES_DIR
4a: e8 00 00 00 00 callq 4f <modprobe_main+0x4f>
4b: R_X86_64_PC32 xchdir-0x4
More information about the busybox
mailing list