Message ID | 20180415110617.GA27586@intel.com |
---|---|
State | New |
Headers | show |
Series | x86/cet: Properly output labels in property note section | expand |
> -----Original Message----- > From: Lu, Hongjiu > Sent: Sunday, April 15, 2018 1:06 PM > To: gcc-patches@gcc.gnu.org; Uros Bizjak <ubizjak@gmail.com>; Tsimbalist, > Igor V <igor.v.tsimbalist@intel.com> > Subject: [PATCH] x86/cet: Properly output labels in property note section > > Replace ASM_OUTPUT_LABEL with fprintf so that internal labels in property > note section are unchanged -fleading-underscore. > > OK for trunk? OK. Igor > H.J. > --- > gcc/ > > PR target/85404 > * config/i386/cet.c (file_end_indicate_exec_stack_and_cet): > Replace ASM_OUTPUT_LABEL with fprintf. > > gcc/testsuite/ > > PR target/85404 > * gcc.target/i386/pr85404.c: New test. > --- > gcc/config/i386/cet.c | 10 +++++----- > gcc/testsuite/gcc.target/i386/pr85404.c | 6 ++++++ > 2 files changed, 11 insertions(+), 5 deletions(-) > create mode 100644 gcc/testsuite/gcc.target/i386/pr85404.c > > diff --git a/gcc/config/i386/cet.c b/gcc/config/i386/cet.c > index 4a1e013fdde..d5bbe8b7fe8 100644 > --- a/gcc/config/i386/cet.c > +++ b/gcc/config/i386/cet.c > @@ -57,20 +57,20 @@ file_end_indicate_exec_stack_and_cet (void) > fprintf (asm_out_file, ASM_LONG " 4f - 1f\n"); > /* note type: NT_GNU_PROPERTY_TYPE_0. */ > fprintf (asm_out_file, ASM_LONG " 5\n"); > - ASM_OUTPUT_LABEL (asm_out_file, "0"); > + fprintf (asm_out_file, "0:\n"); > /* vendor name: "GNU". */ > fprintf (asm_out_file, STRING_ASM_OP " \"GNU\"\n"); > - ASM_OUTPUT_LABEL (asm_out_file, "1"); > + fprintf (asm_out_file, "1:\n"); > ASM_OUTPUT_ALIGN (asm_out_file, p2align); > /* pr_type: GNU_PROPERTY_X86_FEATURE_1_AND. */ > fprintf (asm_out_file, ASM_LONG " 0xc0000002\n"); > /* pr_datasz. */\ > fprintf (asm_out_file, ASM_LONG " 3f - 2f\n"); > - ASM_OUTPUT_LABEL (asm_out_file, "2"); > + fprintf (asm_out_file, "2:\n"); > /* GNU_PROPERTY_X86_FEATURE_1_XXX. */ > fprintf (asm_out_file, ASM_LONG " 0x%x\n", feature_1); > - ASM_OUTPUT_LABEL (asm_out_file, "3"); > + fprintf (asm_out_file, "3:\n"); > ASM_OUTPUT_ALIGN (asm_out_file, p2align); > - ASM_OUTPUT_LABEL (asm_out_file, "4"); > + fprintf (asm_out_file, "4:\n"); > } > } > diff --git a/gcc/testsuite/gcc.target/i386/pr85404.c > b/gcc/testsuite/gcc.target/i386/pr85404.c > new file mode 100644 > index 00000000000..bbf456ec024 > --- /dev/null > +++ b/gcc/testsuite/gcc.target/i386/pr85404.c > @@ -0,0 +1,6 @@ > +/* { dg-do assemble } */ > +/* { dg-options "-fleading-underscore -mcet -fcf-protection" } */ > + > +void func(void) __asm("_func"); > +void _func(int x) {} > +void func(void) {} > -- > 2.14.3
"H.J. Lu" <hongjiu.lu@intel.com> writes: > Replace ASM_OUTPUT_LABEL with fprintf so that internal labels in property > note section are unchanged -fleading-underscore. > > OK for trunk? > > H.J. > --- > gcc/ > > PR target/85404 > * config/i386/cet.c (file_end_indicate_exec_stack_and_cet): > Replace ASM_OUTPUT_LABEL with fprintf. > > gcc/testsuite/ > > PR target/85404 > * gcc.target/i386/pr85404.c: New test. The testcase FAILs on Solaris/x86 with /bin/as: FAIL: gcc.target/i386/pr85404.c (test for excess errors) Excess errors: Assembler: pr85404.c "/var/tmp//cc_MI..a.s", line 6 : Illegal mnemonic Near line: " endbr32" "/var/tmp//cc_MI..a.s", line 6 : Syntax error Near line: " endbr32" "/var/tmp//cc_MI..a.s", line 13 : Illegal mnemonic Near line: " endbr32" "/var/tmp//cc_MI..a.s", line 13 : Syntax error Near line: " endbr32" There are also FAILs on gcc-testresults for i686-pc-linux-gnu, x86_64-unknown-linux-gnu, and i586-unknown-freebsd10.4 (probably older versions of gas). It either needs a dg-require-effective-target cet or be demoted to a compile test, depending on intent. Rainer
On Thu, Apr 19, 2018 at 11:56 AM, Rainer Orth <ro@cebitec.uni-bielefeld.de> wrote: > "H.J. Lu" <hongjiu.lu@intel.com> writes: > >> Replace ASM_OUTPUT_LABEL with fprintf so that internal labels in property >> note section are unchanged -fleading-underscore. >> >> OK for trunk? >> >> H.J. >> --- >> gcc/ >> >> PR target/85404 >> * config/i386/cet.c (file_end_indicate_exec_stack_and_cet): >> Replace ASM_OUTPUT_LABEL with fprintf. >> >> gcc/testsuite/ >> >> PR target/85404 >> * gcc.target/i386/pr85404.c: New test. > > The testcase FAILs on Solaris/x86 with /bin/as: > > FAIL: gcc.target/i386/pr85404.c (test for excess errors) > > Excess errors: > Assembler: pr85404.c > "/var/tmp//cc_MI..a.s", line 6 : Illegal mnemonic > Near line: " endbr32" > "/var/tmp//cc_MI..a.s", line 6 : Syntax error > Near line: " endbr32" > "/var/tmp//cc_MI..a.s", line 13 : Illegal mnemonic > Near line: " endbr32" > "/var/tmp//cc_MI..a.s", line 13 : Syntax error > Near line: " endbr32" > > There are also FAILs on gcc-testresults for i686-pc-linux-gnu, > x86_64-unknown-linux-gnu, and i586-unknown-freebsd10.4 (probably older > versions of gas). > > It either needs a dg-require-effective-target cet or be demoted to a > compile test, depending on intent. > I am checking in this.
diff --git a/gcc/config/i386/cet.c b/gcc/config/i386/cet.c index 4a1e013fdde..d5bbe8b7fe8 100644 --- a/gcc/config/i386/cet.c +++ b/gcc/config/i386/cet.c @@ -57,20 +57,20 @@ file_end_indicate_exec_stack_and_cet (void) fprintf (asm_out_file, ASM_LONG " 4f - 1f\n"); /* note type: NT_GNU_PROPERTY_TYPE_0. */ fprintf (asm_out_file, ASM_LONG " 5\n"); - ASM_OUTPUT_LABEL (asm_out_file, "0"); + fprintf (asm_out_file, "0:\n"); /* vendor name: "GNU". */ fprintf (asm_out_file, STRING_ASM_OP " \"GNU\"\n"); - ASM_OUTPUT_LABEL (asm_out_file, "1"); + fprintf (asm_out_file, "1:\n"); ASM_OUTPUT_ALIGN (asm_out_file, p2align); /* pr_type: GNU_PROPERTY_X86_FEATURE_1_AND. */ fprintf (asm_out_file, ASM_LONG " 0xc0000002\n"); /* pr_datasz. */\ fprintf (asm_out_file, ASM_LONG " 3f - 2f\n"); - ASM_OUTPUT_LABEL (asm_out_file, "2"); + fprintf (asm_out_file, "2:\n"); /* GNU_PROPERTY_X86_FEATURE_1_XXX. */ fprintf (asm_out_file, ASM_LONG " 0x%x\n", feature_1); - ASM_OUTPUT_LABEL (asm_out_file, "3"); + fprintf (asm_out_file, "3:\n"); ASM_OUTPUT_ALIGN (asm_out_file, p2align); - ASM_OUTPUT_LABEL (asm_out_file, "4"); + fprintf (asm_out_file, "4:\n"); } } diff --git a/gcc/testsuite/gcc.target/i386/pr85404.c b/gcc/testsuite/gcc.target/i386/pr85404.c new file mode 100644 index 00000000000..bbf456ec024 --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/pr85404.c @@ -0,0 +1,6 @@ +/* { dg-do assemble } */ +/* { dg-options "-fleading-underscore -mcet -fcf-protection" } */ + +void func(void) __asm("_func"); +void _func(int x) {} +void func(void) {}