Data Distribution

Asked by Deepa Ballari

Hello,

I'm from Freescale and checking the feasibility of implementing data distribution in GNU linker that is mentioned here:
https://answers.launchpad.net/gcc-arm-embedded/+question/201738

With one of our target, data distribution is supported. It is a 2 pass compile/link process. In Pass1,linker generates the header file which has info on object going to particular section.
In pass2, the header file is included and the sources are re-compiled/linked.

For instance:

-------
data.h: /* This is generated by linker in Pass1 and is included in Pass2 compilation step */
-------
#pragma DATA_SEG __DEFAULT_SEG_CC__ DATA_DISTRIBUTE0 /* DATA_DISTRIBUTE0 is a data segment */
/* list of all distributed objects in data segment */
#pragma REALLOC_OBJ "DATA_DISTRIBUTE0" gint __NON_FAR_DAC__ /* gint goes to "DATA_DISTRIBUTE0" section */

The generated header file does not has info on data type of the variable.
-------
test.c:
-------

#include "data.h"
int gint = 0;
 void main() {
}

If I want to replicate the same with GNU tools then I'm stumbling with an issue in getting the data type of variable from linker.One possibility is to get from debug sections but checking if there is a way to do without it.

Let's assume GNU linker will generate the data.h in Pass1.
data.h:
gint __attribute__ ((section(".data")));
fint __attribute__ ((section(".m_data2")));

However, there is a miss to include the data type of the variable.

In Pass2, is there a way to include this header file and compile without errors OR any other workarounds which would work with data.h?

ld throws this warning:
warning: data definition has no type or storage class [enabled by default]

It works ok _only_ if gint/fint are defined as "int" data types and errors for others(checked for struct).

Thanks,
Deepa

Question information

Language:
English Edit question
Status:
Answered
For:
GNU Arm Embedded Toolchain Edit question
Assignee:
No assignee Edit question
Last query:
Last reply:
Revision history for this message
Joey Ye (jinyun-ye) said :
#1

I can't think of a good alternative to #pragma for your case. Also I don't
recommend you use debug information in linker as they might not be accurate.

Best solution is still to implement ideas like in
https://answers.launchpad.net/gcc-arm-embedded/+question/201738.

A workaround like following probably help:

--------
data.h
--------
#define DISTRIBUTE(a) __attribute__((section(DISTRIBUTE_SECTION_##a))) a
#define DISTRIBUTE_SECTION_gint ".data"
#define DISTRIBUTE_SECTION_fint ".m_data2"
-------
test.c:
-------

#include "data.h"
int DISTRIBUTE(gint) = 0;
double DISTRIBUTE(fint);
 void main() {
}

Thanks - Joey
On Mon, Aug 13, 2012 at 2:31 PM, Deepa Ballari <
<email address hidden>> wrote:

> New question #205674 on GCC ARM Embedded:
> https://answers.launchpad.net/gcc-arm-embedded/+question/205674
>
> Hello,
>
> I'm from Freescale and checking the feasibility of implementing data
> distribution in GNU linker that is mentioned here:
> https://answers.launchpad.net/gcc-arm-embedded/+question/201738
>
> With one of our target, data distribution is supported. It is a 2 pass
> compile/link process. In Pass1,linker generates the header file which has
> info on object going to particular section.
> In pass2, the header file is included and the sources are
> re-compiled/linked.
>
> For instance:
>
> -------
> data.h: /* This is generated by linker in Pass1 and is included in Pass2
> compilation step */
> -------
> #pragma DATA_SEG __DEFAULT_SEG_CC__ DATA_DISTRIBUTE0 /* DATA_DISTRIBUTE0
> is a data segment */
> /* list of all distributed objects in data segment */
> #pragma REALLOC_OBJ "DATA_DISTRIBUTE0" gint __NON_FAR_DAC__ /* gint goes
> to "DATA_DISTRIBUTE0" section */
>
> The generated header file does not has info on data type of the variable.
> -------
> test.c:
> -------
>
> #include "data.h"
> int gint = 0;
> void main() {
> }
>
> If I want to replicate the same with GNU tools then I'm stumbling with an
> issue in getting the data type of variable from linker.One possibility is
> to get from debug sections but checking if there is a way to do without it.
>
> Let's assume GNU linker will generate the data.h in Pass1.
> data.h:
> gint __attribute__ ((section(".data")));
> fint __attribute__ ((section(".m_data2")));
>
> However, there is a miss to include the data type of the variable.
>
> In Pass2, is there a way to include this header file and compile without
> errors OR any other workarounds which would work with data.h?
>
> ld throws this warning:
> warning: data definition has no type or storage class [enabled by default]
>
> It works ok _only_ if gint/fint are defined as "int" data types and errors
> for others(checked for struct).
>
> Thanks,
> Deepa
>
>
>
> --
> You received this question notification because you are an answer
> contact for GCC ARM Embedded.
>

Can you help with this problem?

Provide an answer of your own, or ask Deepa Ballari for more information if necessary.

To post a message you must log in.