GCC Jump Table initialization code generating movsxd and add?
问题 When I compile a switch statement with optimization in GCC, it sets up a jump table like this, (fcn) sym.foo 148 sym.foo (unsigned int arg1); ; arg unsigned int arg1 @ rdi 0x000006e0 83ff06 cmp edi, 6 ; arg1 0x000006e3 0f87a7000000 ja case.default.0x790 0x000006e9 488d156c0100. lea rdx, [0x0000085c] 0x000006f0 89ff mov edi, edi 0x000006f2 4883ec08 sub rsp, 8 0x000006f6 486304ba movsxd rax, dword [rdx + rdi*4] 0x000006fa 4801d0 add rax, rdx ; '(' ;-- switch.0x000006fd: 0x000006fd ffe0 jmp rax