public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug ipa/64963] New: IPA Cloning/Splitting does not copy function section attributes resulting in kernel miscompilation
@ 2015-02-06 17:52 jgreenhalgh at gcc dot gnu.org
  2015-02-06 17:54 ` [Bug ipa/64963] " jgreenhalgh at gcc dot gnu.org
                   ` (14 more replies)
  0 siblings, 15 replies; 16+ messages in thread
From: jgreenhalgh at gcc dot gnu.org @ 2015-02-06 17:52 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 64963
           Summary: IPA Cloning/Splitting does not copy function section
                    attributes resulting in kernel miscompilation
           Product: gcc
           Version: 5.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: ipa
          Assignee: unassigned at gcc dot gnu.org
          Reporter: jgreenhalgh at gcc dot gnu.org
                CC: hubicka at gcc dot gnu.org, jamborm at gcc dot gnu.org
              Host: x86_64-unknown-linux-gnu
            Target: aarch64-none-elf

Created attachment 34688
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=34688&action=edit
Cloning fails to maintain section attributes on foo

When we create a clone for constant propagation, or in ipa-split,
we don't clone the section attribute for that function. For kernel
builds this can result in code ending up in the wrong section, resulting
in all sorts of carnage.

The testcase attached shows the issue for cloning (it is much harder
to engineer one for splitting, but the problem is analogous).

You can reproduce the bug with -O3. For AArch64 this gives:

    .cpu generic+fp+simd
    .file    "ipa-clone-1.c"
    .text
    .align    2
    .p2align 3,,7
    .type    foo.constprop.0, %function
foo.constprop.0:
    mov    w0, 35
    ret
    .size    foo.constprop.0, .-foo.constprop.0
    .align    2
    .p2align 3,,7
    .global    bar
    .type    bar, %function
bar:
    b    foo.constprop.0
    .size    bar, .-bar
    .ident    "GCC: (unknown) 5.0.0 20150205 (experimental)"

Note that foo.constprop.0 is in the text section, while foo was declared with:

static int __attribute__ ((noinline section ("test_section")))
foo (int arg)

I would have expected to see:

    .arch armv8-a+fp+simd
    .file    "ipa-clone-1.c"
    .section    test_section,"ax",%progbits
    .align    2
    .p2align 3,,7
    .type    foo.constprop.0, %function
foo.constprop.0:
    mov    w0, 35
    ret
    .size    foo.constprop.0, .-foo.constprop.0
    .text
    .align    2
    .p2align 3,,7
    .global    bar
    .type    bar, %function
bar:
    b    foo.constprop.0
    .size    bar, .-bar
    .ident    "GCC: (unknown) 5.0.0 20150205 (experimental)"


^ permalink raw reply	[flat|nested] 16+ messages in thread

end of thread, other threads:[~2015-02-18 11:38 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-02-06 17:52 [Bug ipa/64963] New: IPA Cloning/Splitting does not copy function section attributes resulting in kernel miscompilation jgreenhalgh at gcc dot gnu.org
2015-02-06 17:54 ` [Bug ipa/64963] " jgreenhalgh at gcc dot gnu.org
2015-02-10 10:40 ` jgreenhalgh at gcc dot gnu.org
2015-02-10 11:19 ` jakub at gcc dot gnu.org
2015-02-10 11:50 ` jgreenhalgh at gcc dot gnu.org
2015-02-10 13:17 ` rguenth at gcc dot gnu.org
2015-02-10 15:38 ` andi-gcc at firstfloor dot org
2015-02-10 15:50 ` [Bug ipa/64963] [5 Regression] " jakub at gcc dot gnu.org
2015-02-10 16:52 ` hubicka at gcc dot gnu.org
2015-02-10 17:07 ` jakub at gcc dot gnu.org
2015-02-10 19:06 ` andi-gcc at firstfloor dot org
2015-02-10 20:10 ` hubicka at ucw dot cz
2015-02-14  9:40 ` jakub at gcc dot gnu.org
2015-02-16 13:33 ` jakub at gcc dot gnu.org
2015-02-16 19:23 ` jakub at gcc dot gnu.org
2015-02-18 11:38 ` jakub at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).