public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
From: David Brown <david.brown@hesbynett.no>
To: Werthmann Luca <Luca.Werthmann@preh.de>,
	"gcc-help@gcc.gnu.org" <gcc-help@gcc.gnu.org>
Subject: Re: section placement - grouping __attribute__((section (“NAME”))) statements
Date: Fri, 20 Aug 2021 20:55:54 +0200	[thread overview]
Message-ID: <f9cdd74c-70f2-5cd7-8129-1c360e87aaaa@hesbynett.no> (raw)
In-Reply-To: <f325630920ce472cb2895743f8f188ca@preh.de>

On 20/08/2021 10:22, Werthmann Luca via Gcc-help wrote:
> Hello,
> 
> I am writing to ask if there is a chance with the GNU GCC Compiler to group __attribute__((section (“NAME”))) statements.
> 
> IAR Supports for example the following commands:
> 
> # pragma default_function_attributes = @ ".MY_FUNC"                 /* start placing following functions in section .MY_FUNC */
> # pragma default_function_attributes =                                              /* stop placing functions in section*/
> 
> # pragma default_variable_attributes = @ ".MY_DATA"                  /* start placing following variables in section .MY_DATA */
> # pragma default_variable_attributes =                                               /* stop placing functions in section*/
> 
> An example how to use these pragma directives is attached. <pragma_section_group_iar.c>
> 
> If I compile this *.c code I got some warnings that the GNU GCC does not support these statements.
> After some research I found that the corresponding statement for GNU GCC is __attribute__((section (“.MY_FUNC”)))
> I tried compiling it with these and it worked. <pragma_section_group_gcc.c>
> 
> I have more than 5k lines in my code and need to replace the IAR statements for the corresponding GCC Commands.
> Is there a chance to group these statements like IAR supports or do I need to add __attribute__((section (“NAME”))) in each line
> 
> I look forward to hearing from you soon.
> 
> Best regards,
> 
 To the best of my knowledge, there is no way to do this in gcc - you
have to put the section attribute on each function.  (You can use a
macro to reduce the typing!)

If you are versed in linker files, it is possible to have a modified
linker setup to put the code or data from a specific file into
non-standard output sections.

I too would like to see this as a feature in gcc - it is one of the few
features that are common to most embedded compilers but missing from gcc.

David

  reply	other threads:[~2021-08-20 18:56 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-08-20  8:22 Werthmann Luca
2021-08-20 18:55 ` David Brown [this message]
2021-08-20 21:02   ` Segher Boessenkool
2021-08-21 18:56     ` David Brown

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=f9cdd74c-70f2-5cd7-8129-1c360e87aaaa@hesbynett.no \
    --to=david.brown@hesbynett.no \
    --cc=Luca.Werthmann@preh.de \
    --cc=gcc-help@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).