Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

confusion with: __attribute__((section (".mysegment")))

984 views
Skip to first unread message

Dan Miller

unread,
Dec 14, 2011, 12:45:35 PM12/14/11
to
I'm working on an embedded project here, using STR912 (an ARM9 device), building with Yagarto toolchain (GCC 4.2.2). We are in the process of moving most of the code and data up to Bank1 on the chip, so we can implement runtime firmware updates.

To move the code to the new segment .highseg, I use:

static void setPacketAddress (uint value) __attribute__((section (".highseg"))) ;
static void setPacketAddress (uint value)

This works fine. Furthermore, I can use exactly the same declaration for every function, and they all get moved with no problems.

Now, I'm trying to move data up there as well, but this is more problematic.
I tried:

static const cmd user_cmd_set[] __attribute__((section (".hirodata"))) = {...} ;

and it was relocated fine. However, when I try to move another data block up there:

static cmd special_cmd_set[] __attribute__((section (".hirodata")))
I get an error:
cmd_svc.c:1157: error: special_cmd_set causes a section type conflict

I solved this by changing special_cmd_set[] to section .hirodata2,
and putting:
.highseg :
{
*(.highseg) /* remaining code */
*(.hirodata) /* remaining code */
*(.hirodata*) /* new declaration to pick up all sections */
} >IntCodeBank1

This works, but that means I have to create a new section name for every variable, which is going to be a maintenance headache as I move large numbers of data elements, and have to modify them in the future.

My question: How come I can use the same segment name for multiple functions (.highseg), but I cannot do so for multiple data elements (.hirodata) ??
Is there some way I can avoid this issue?






Andrew Haley

unread,
Dec 14, 2011, 1:16:17 PM12/14/11
to
Dan Miller <dan.mil...@gmail.com> wrote:

> I'm working on an embedded project here, using STR912 (an ARM9
> device), building with Yagarto toolchain (GCC 4.2.2). We are in the
> process of moving most of the code and data up to Bank1 on the chip,
> so we can implement runtime firmware updates....
>
> My question: How come I can use the same segment name for multiple
> functions (.highseg), but I cannot do so for multiple data elements
> (.hirodata) ??

> Is there some way I can avoid this issue?

I don't understand why you're having this problem. If no-one answers
here, the people on the binutils at sourceware dot org list may be
your best bet.

Andrew.

Dan Miller

unread,
Dec 14, 2011, 4:06:36 PM12/14/11
to
> I don't understand why you're having this problem. If no-one answers
> here, the people on the binutils at sourceware dot org list may be
> your best bet.

So you're saying that the handling of __attribute__((section (".secname")))
is *not* handled by gcc, it's handled by some other utility in binutils??

Alan Curry

unread,
Dec 14, 2011, 4:35:29 PM12/14/11
to
In article <2645024.652.1323884735027.JavaMail.geo-discussion-forums@yqkb10>,
Dan Miller <gnu.gc...@googlegroups.com> wrote:
>
>Now, I'm trying to move data up there as well, but this is more problematic.
>I tried:
>
>static const cmd user_cmd_set[] __attribute__((section (".hirodata"))) = {...} ;
>
>and it was relocated fine. However, when I try to move another data
>block up there:
>
>static cmd special_cmd_set[] __attribute__((section (".hirodata")))
>I get an error:
>cmd_svc.c:1157: error: special_cmd_set causes a section type conflict

You have a const on one of them and not on the other. It seems like gcc is
deciding that the section should be readonly (and whoever picked the name
"hirodata" was thinking that too) then it gets surprised by your attempt to
put modifiable data there.

--
Alan Curry

Dan Miller

unread,
Dec 14, 2011, 4:55:29 PM12/14/11
to
HA!!!!!!!!!!!!!!!
Thank you, Alan... duh, I should know better than that.
Yes, once I make them both const, I only need one section declaration.
Actually, I'll need two data segments; one hirodata and one hirwdata.
I need to make sure *all* of our global data ends up in hirwdata, because anything that's in Bank0 can never get updated...

Thank you again! This group is a life-saver!!!

Dan Miller

unread,
Dec 14, 2011, 2:14:25 PM12/14/11
to
Oh...
So gcc is *not* the actual application which is processing the
__attribute__((section)) attribute? Or are you saying that I *should* be able to use multiple
static const structname varname[] __attribute__((section (".hirodata")))
declarations?

Dan

Dan Miller

unread,
Dec 14, 2011, 6:43:33 PM12/14/11
to
(Bah, disregard the final post, I keep reposting without allowing enough time for first post to work through the system)

Dan Miller

Andrew Haley

unread,
Dec 15, 2011, 5:38:50 AM12/15/11
to
Your problem has now been solved, but just FYI: all gcc does with a
section attribute is pass it through to the assembler; it's up to the
assembler and linker to decide what to do with the information.

Andrew.
0 new messages