[Bug target/93492] Broken code with -fpatchable-function-entry and -fcf-protection=full

i at maskray dot me gcc-bugzilla@gcc.gnu.org
Sun Feb 2 23:34:00 GMT 2020


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=93492

--- Comment #11 from Fangrui Song <i at maskray dot me> ---
(In reply to H.J. Lu from comment #8)
> Created attachment 47762 [details]
> A patch to handle targetm.asm_out.post_cfi_startproc

I don't work on GCC, so I am hoping other x86 maintainers can review. (I know
close to zero about its build system. "How to work on GCC" is not well
documented. I can play with stage1-gcc/xgcc -B stage1-gcc -fsyntax-only
/tmp/c/a.c  but I don't even know how to build stage1 only)


For tests, I think at least 3 configurations should be tested.

-fpatchable-function-entry=0 -fcf-protection=branch
-fpatchable-function-entry=1 -fcf-protection=branch
-fpatchable-function-entry=2,1 -fcf-protection=branch

I am a bit concerned about the introduction of cfi_startproc_emitted

My idea is that NOPs after the function entry label should really be a arch
specific feature. It should be implemented like a pass beside
make_pass_insert_endbranch. We build the function body, then prepend NOPs, then
prepend endbr64. That may be cleaner.


More information about the Gcc-bugs mailing list