This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug middle-end/61848] New: a previous declaration causes the section attribute to be lost
- From: "pinskia at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Sat, 19 Jul 2014 04:02:31 +0000
- Subject: [Bug middle-end/61848] New: a previous declaration causes the section attribute to be lost
- Auto-submitted: auto-generated
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61848
Bug ID: 61848
Summary: a previous declaration causes the section attribute to
be lost
Product: gcc
Version: 4.10.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: middle-end
Assignee: unassigned at gcc dot gnu.org
Reporter: pinskia at gcc dot gnu.org
Take:
void f(void);
void __attribute__ ((__section__(".init.text"))) f(void)
{
}
---- CUT ---
The section attribute is lost from the function.
at -O1, -O0, -Og we get:
.file "t.c"
.text
.globl f
.type f, @function
f:
.LFB0:
.cfi_startproc
rep; ret
.cfi_endproc
.LFE0:
.size f, .-f
.ident "GCC: (GNU) 4.10.0 20140718 (experimental)"
.section .note.GNU-stack,"",@progbits
While at -O2 and above (including -Os), we get:
.file "t.c"
.section .text.unlikely,"ax",@progbits
.LCOLDB0:
.text
.LHOTB0:
.p2align 4,,15
.globl f
.type f, @function
f:
.LFB0:
.cfi_startproc
rep; ret
.cfi_endproc
.LFE0:
.size f, .-f
.section .text.unlikely
.LCOLDE0:
.text
.LHOTE0:
.ident "GCC: (GNU) 4.10.0 20140718 (experimental)"
.section .note.GNU-stack,"",@progbits
Notice how f is no longer in the correct section.
If we comment out the declaration (prototype), we get:
.file "t.c"
.section .init.text,"ax",@progbits
.globl f
.type f, @function
f:
.LFB0:
.cfi_startproc
rep; ret
.cfi_endproc
.LFE0:
.size f, .-f
.ident "GCC: (GNU) 4.10.0 20140718 (experimental)"
.section .note.GNU-stack,"",@progbits