Inline static data causes a section type conflict
Bernd Edlinger
bernd.edlinger@hotmail.de
Sun Feb 21 11:05:00 GMT 2016
Hi,
Maybe something like that works for you?
cat test.cc
#define _str(x) #x
#define str(x) _str(x)
#define PLACE_HERE(section,data) \
asm(".pushsection " str(section) "\n\t" \
".quad 999f \n\t" \
".long " str(__LINE__) "\n\t" \
".long " str(data) "\n\t" \
".section .rodata\n\t" \
"999: .string \"" __FILE__ "\"\n\t" \
".popsection")
const int* get_data()
{
PLACE_HERE(.custom,123);
static const int data = 123;
return & data;
}
inline const int* inline_get_data()
{
PLACE_HERE(.custom,123);
static const int inline_data = 123;
return & inline_data;
}
int main()
{
(void) get_data();
(void) inline_get_data();
return 0;
}
Regards
Bernd.
More information about the Gcc-help
mailing list