-fpatchable-function-entry: leverage multi-byte NOP on x86
Martin Liška
mliska@suse.cz
Mon Jan 6 09:34:00 GMT 2020
On 1/4/20 9:48 PM, Fangrui Song wrote:
> -fpatchable-function-entry is used by Linux kernel arm64/parisc. The
> feature works for x86, but does not leverage multi-byte NOP.
>
> % cat a.c
> int foo() { return 0; }
> % gcc -fpatchable-function-entry=5,0 -c a.c
> % objdump -d a.o
> ...
> 0000000000000000 <foo>:
> Â Â 0:Â Â 90Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â nop
> Â Â 1:Â Â 90Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â nop
> Â Â 2:Â Â 90Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â nop
> Â Â 3:Â Â 90Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â nop
> Â Â 4:Â Â 90Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â nop
>   5:  55                     push  %rbp
>   6:  48 89 e5               mov   %rsp,%rbp
>   9:  b8 00 00 00 00         mov   $0x0,%eax
>   e:  5d                     pop   %rbp
> Â Â f:Â Â c3Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â retq
>
>
> (I am not sure who should be notified. I CCed x86-64-port maintainer
> (Jan Hubicka <hubicka@ucw.cz>), as listed on gcc/MAINTAINERS.)
Hello.
You are right, we do not leverage multi-byte NOPs. Note that the support depends
on a CPU model (-march) and the similar code is quite complex in binutils:
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;a=blob;f=gas/config/tc-i386.c;h=d0b8f2624a1885d83d2595474bfd78ae844f48f2;hb=HEAD#l1441
I'm not sure how worthy would it be to implement that?
Thanks,
Martin
More information about the Gcc
mailing list