Re: Inline static data causes a section type conflict

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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.




[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux