[arm-gnu] Static template member in assigned section -- section type conflict
Carlos O'Donell
carlos_odonell at mentor.com
Thu Jan 26 17:01:33 UTC 2012
On 1/22/2012 8:36 PM, Gene Smith wrote:
> //@! test: g++ bad2.cpp
> // bad2.cpp:18:25: error: priv causes a section type conflict
>
> template<class t1, class t2>
> class outer
> {
> public:
> t1 a;
> static t2 b;
> };
>
> template<class t1, class t2>
> t2 outer<t1, t2>::b
> __attribute__((section(".s1")));
>
> int main (void)
> {
> static outer<int, int> priv __attribute__((section(".s1")));
You can't place common data and non-common data in the same section.
The conflict is as follows:
* The variable t2 in outer->t2 is static and therefore common data,
there must only be one instance of t2 at all times.
* Moving t2 into .s1 causes section .s1 to be marked as common data,
this is a flag that the linker must honour and it will bind other
references to t2 to the common location in .s1 (that's how static
is implemented in this case).
* In main you say you want to store the *entire* contents of the
instantiated template into .s1, but .s1 is common data, and the
object is not common data, and that is a conflict.
> priv.a = 10;
> priv.b = 10;
> }
> //@! end of file
The solution is to place priv into some *other* section.
You will never have *all* of priv in the same place because
the `static' clause makes that impossible for > 1 instances
of the object (given the current implementation for static).
Cheers,
Carlos.
--
Carlos O'Donell
Mentor Graphics / CodeSourcery
carlos at codesourcery.com
+1 (613) 963 1026
More information about the arm-gnu
mailing list