On Sun, Jan 31, 2016 at 9:06 PM, Benedek Thaler <thalerbenedek@xxxxxxxxx> wrote: > Hi, > > I want to put some user defined data into a custom section to be read > by the application and an offline analyser at the same time. Assuming > the following sample: > > const int* get_data() > { > __attribute__((section(".custom"))) > static const int data = 123; > > return & data; > } > > inline const int* inline_get_data() > { > __attribute__((section(".custom"))) > static const int inline_data = 123; > > return & inline_data; > } > > int main() > { > (void) get_data(); > (void) inline_get_data(); > return 0; > } > > The value of data and inline_data will appear in the section .custom. > Clang compiles this example and produces the correct result, just as > MSVC does, when the __attributes__ are replaced by corresponding > pragmas. > > Unfortunately, GCC 5.2 gives the following error: > > error: inline_data causes a section type conflict with data > > The problem boils down to the fact that the two variables have > different linkage (data is in a section flagged with `a`, the section > of inline_data is flagged with `aG`). GCC 4.9 also fails the same way > if the second function is not marked as inline but is a template (GCC > 5.2 compiles that). > > GCC 5.2 also compiles fine if one section name is temporarily changed > and manually fixed in the generated assembly. > > Why is this happening? Is it expected? Is there any known workaround > for this issue? I have no control over the function signature, the > *data variables are produced by a macro provided by me, and they can > appear anywhere. > > Thanks, > Benedek > > (On SO: http://stackoverflow.com/questions/35091862/inline-data-causes-a-section-type-conflict) Is there any expert on this matter missed this message I can directly contact? Thanks, Benedek