Section pragmas

Richard Biener richard.guenther@gmail.com
Wed Apr 15 06:15:27 GMT 2020


On Wed, Apr 15, 2020 at 1:22 AM Yousef via Gcc <gcc@gcc.gnu.org> wrote:
>
> Hi
>
> I am very shocked to find out that GCC GNU does not support section
> pragams. I have to declare an attribute for every single variable and
> function for hundreds of files where I can just use few pragmas on other
> compilers.
>
> I do not understand why would GNU discourage the use of pragmas where they
> can be so useful. I understand that I can use linked scripts but that
> requires organization of object files and for a lot of cases it is much
> more effective to do that in the codebase. I am really really shocked!!
>
> I hope future releases will change this attitude against pragmas. Very
> disappointing!
>
> Is there any way that I can use the attribution section for multiple lines
> of code rather than doing it for every line? (No I will not do it in a
> linker script)

Please don't cross-post.

You can use a macro to make the repetition shorter/nicer:

#define SEC_FOO __attribute__((section("foo")))

void SEC_FOO bar() {}
...

GCC is a community effort and any help is welcome - if you're in the
need of a feature feel free to contribute!

Richard.

> Thanks!



More information about the Gcc-help mailing list