https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70435

Khalil <kammce at google dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |kammce at google dot com

--- Comment #5 from Khalil <kammce at google dot com> ---
Having similiar issues with ARM Embedded and Linux GCC. 
Having trouble finding a work around for this.
Here is an example code that demonstrates the issue in our particular use case:

===============================================================
// g++ -std=c++17 static.cpp -o static.exe
//
// objdump -t static.exe | grep thing
//     0000000000000740  u  O .rodata  0000000000000064
_ZZ5test0ILi5EEvvE5thing
//
// clang -std=c++14 static.cpp -o static.exe
// objdump -t static.exe  | grep thing
//     00000000004005d3 w O .log_entry 0000000000000064
_ZZ5test0ILi5EEvvE5thing

#include <cstdio>

#if __APPLE__
#define PUT_IN_SECTION(name) __attribute__((section("__text," name), used))
#else
#define PUT_IN_SECTION(name) __attribute__((section(name), used))
#endif

struct ThingType
{
  constexpr ThingType(const char * str): data{}
  {
    for(int i = 0; str[i] != '\0' && i < sizeof(data); i++)
    {
      data[i] = str[i];
    }
  }
  char data[100];
};

template <int dummy_template_parameter = 5>
void test0()
{
  PUT_IN_SECTION(".log_entry")
  static const ThingType thing("Goodbye!");
  printf("Hello, World!\n");
}

int main()
{
  test0();
  return 0;
}
===============================================================

Comment the test0 template line out, and the entry will appear in the 
appropriate section.

Reply via email to