public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/39456] New: Functions of a file in different named sections
@ 2009-03-13 14:03 etienne_lorrain at yahoo dot fr
2009-03-19 16:33 ` [Bug c/39456] " etienne_lorrain at yahoo dot fr
` (2 more replies)
0 siblings, 3 replies; 6+ messages in thread
From: etienne_lorrain at yahoo dot fr @ 2009-03-13 14:03 UTC (permalink / raw)
To: gcc-bugs
Just that I need to set each functions in a C file into different sections,
with section names I can link in different segments.
That can be done with:
__attribute__ ((section ("sect1_fct1"))) void fct1 (void) {}
__attribute__ ((section ("sect1_fct2"))) void fct2 (void) {}
But cannot unfortunately be done in a macro like:
__attribute__ ((section ("sect1_" __FUNCTION__ ))) void fct1 (void) {}
It would be nice to have some way to do that, like:
__attribute__ ((section_prepend ("sect1_"))) void fct1 (void) {}
so that a bad cut&paste somewhere do not create problems because
a function is in the wrong section (by forgeting to change the
concat'ed string).
--
Summary: Functions of a file in different named sections
Product: gcc
Version: unknown
Status: UNCONFIRMED
Severity: enhancement
Priority: P3
Component: c
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: etienne_lorrain at yahoo dot fr
GCC build triplet: all-all-all
GCC host triplet: all-all-all
GCC target triplet: all-all-all
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=39456
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug c/39456] Functions of a file in different named sections
2009-03-13 14:03 [Bug c/39456] New: Functions of a file in different named sections etienne_lorrain at yahoo dot fr
@ 2009-03-19 16:33 ` etienne_lorrain at yahoo dot fr
2009-04-16 20:51 ` [Bug middle-end/39456] " pinskia at gcc dot gnu dot org
2009-05-12 14:51 ` [Bug middle-end/39456] Functions/variables " pinskia at gcc dot gnu dot org
2 siblings, 0 replies; 6+ messages in thread
From: etienne_lorrain at yahoo dot fr @ 2009-03-19 16:33 UTC (permalink / raw)
To: gcc-bugs
------- Comment #1 from etienne_lorrain at yahoo dot fr 2009-03-19 16:33 -------
Also, you cannot put function in another section and then
use -ffunction-sections, i.e.:
etienne@gujin:~$ gcc --version
gcc (Debian 4.3.3-3) 4.3.3
Copyright (C) 2008 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
etienne@gujin:~$ cat tmp.c
__attribute__((section(".extracode"))) int fct1 (void) {
return 1;
}
__attribute__((section(".extracode"))) int fct2 (void) {
return 2;
}
etienne@gujin:~$ gcc -Os -fomit-frame-pointer -ffunction-sections -S tmp.c -o
tmp.s
etienne@gujin:~$ cat tmp.s
.file "tmp.c"
.section .extracode,"ax",@progbits
.globl fct1
.type fct1, @function
fct1:
movl $1, %eax
ret
.size fct1, .-fct1
.globl fct2
.type fct2, @function
fct2:
movl $2, %eax
ret
.size fct2, .-fct2
.ident "GCC: (Debian 4.3.3-3) 4.3.3"
.section .note.GNU-stack,"",@progbits
etienne@gujin:~$
So you cannot use garbage collection in the linker...
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=39456
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug middle-end/39456] Functions of a file in different named sections
2009-03-13 14:03 [Bug c/39456] New: Functions of a file in different named sections etienne_lorrain at yahoo dot fr
2009-03-19 16:33 ` [Bug c/39456] " etienne_lorrain at yahoo dot fr
@ 2009-04-16 20:51 ` pinskia at gcc dot gnu dot org
2009-05-12 14:51 ` [Bug middle-end/39456] Functions/variables " pinskia at gcc dot gnu dot org
2 siblings, 0 replies; 6+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2009-04-16 20:51 UTC (permalink / raw)
To: gcc-bugs
--
pinskia at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |NEW
Component|c |middle-end
Ever Confirmed|0 |1
Last reconfirmed|0000-00-00 00:00:00 |2009-04-16 20:51:34
date| |
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=39456
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug middle-end/39456] Functions/variables of a file in different named sections
2009-03-13 14:03 [Bug c/39456] New: Functions of a file in different named sections etienne_lorrain at yahoo dot fr
2009-03-19 16:33 ` [Bug c/39456] " etienne_lorrain at yahoo dot fr
2009-04-16 20:51 ` [Bug middle-end/39456] " pinskia at gcc dot gnu dot org
@ 2009-05-12 14:51 ` pinskia at gcc dot gnu dot org
2 siblings, 0 replies; 6+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2009-05-12 14:51 UTC (permalink / raw)
To: gcc-bugs
------- Comment #2 from pinskia at gcc dot gnu dot org 2009-05-12 14:51 -------
*** Bug 40113 has been marked as a duplicate of this bug. ***
--
pinskia at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |sb-sf at users dot
| |sourceforge dot net
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=39456
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug middle-end/39456] Functions/variables of a file in different named sections
[not found] <bug-39456-4@http.gcc.gnu.org/bugzilla/>
2012-01-02 4:25 ` pinskia at gcc dot gnu.org
@ 2012-01-03 9:54 ` etienne_lorrain at yahoo dot fr
1 sibling, 0 replies; 6+ messages in thread
From: etienne_lorrain at yahoo dot fr @ 2012-01-03 9:54 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=39456
--- Comment #4 from etienne_lorrain at yahoo dot fr 2012-01-03 09:53:59 UTC ---
Thanks for looking at my reports and happy new year!
I think the problem I had was the quoting and string concat, you need:
void fct2 (void) __attribute__((__section__("sect1_fct2"))) { return; }
The solution you give generates:
void fct1 (void) __attribute__((__section__(basesectfct1))) { return; }
You cannot give the compiler:
void fct2 (void) __attribute__((__section__("sect1_" "fct2"))) { return; }
because it would not concat the strings in this case (I did not re-check).
And:
#define function_def(base_section, funname, RET, ARGS) \
RET funname ARGS __attribute__((__section__(# base_section##funname)))
#define basesect sect1_
function_def(basesect, fct1, void, (void)) { return; }
will stringify #base_section before applying the ##
That was my problem...
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug middle-end/39456] Functions/variables of a file in different named sections
[not found] <bug-39456-4@http.gcc.gnu.org/bugzilla/>
@ 2012-01-02 4:25 ` pinskia at gcc dot gnu.org
2012-01-03 9:54 ` etienne_lorrain at yahoo dot fr
1 sibling, 0 replies; 6+ messages in thread
From: pinskia at gcc dot gnu.org @ 2012-01-02 4:25 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=39456
--- Comment #3 from Andrew Pinski <pinskia at gcc dot gnu.org> 2012-01-02 04:25:03 UTC ---
What about doing something like:
#define function_def(base_section, funname, RET, ARGS)
__attribute__((__section__(base_section ##funname))) RET funname ARGS
#define basesect "sect1_"
function_def(basesect, fct1, void, (void));
So you won't have a copy and paste error at all and it works without any real
changes to the compiler.
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2012-01-03 9:54 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-03-13 14:03 [Bug c/39456] New: Functions of a file in different named sections etienne_lorrain at yahoo dot fr
2009-03-19 16:33 ` [Bug c/39456] " etienne_lorrain at yahoo dot fr
2009-04-16 20:51 ` [Bug middle-end/39456] " pinskia at gcc dot gnu dot org
2009-05-12 14:51 ` [Bug middle-end/39456] Functions/variables " pinskia at gcc dot gnu dot org
[not found] <bug-39456-4@http.gcc.gnu.org/bugzilla/>
2012-01-02 4:25 ` pinskia at gcc dot gnu.org
2012-01-03 9:54 ` etienne_lorrain at yahoo dot fr
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).