https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70435
Bug ID: 70435
Summary: section attribute of a function template is not
honored.
Product: gcc
Version: 5.3.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: kukyakya at gmail dot com
Target Milestone: ---
namespace /* anonymous */
{
[[gnu::section(".mysection")]]
void regular_func() { }
template <class T>
[[gnu::section(".mysection")]]
void template_func() { }
} // namespace /* anonymous */
void (*ptr1)() = ®ular_func;
void (*ptr2)() = &template_func<int>;
In the code above the section attribute is given to both of the regular
function and the function template, but the templated function is not placed in
.mysection but .text.
$ g++ -std=c++14 a.cpp -c && objdump -t a.o | grep -E "regular|template"
0000000000000000 l F .mysection 0000000000000007
_ZN12_GLOBAL__N_112regular_funcEv
0000000000000000 l F .text 0000000000000007
_ZN12_GLOBAL__N_113template_funcIiEEvv
~/temp/c++/function_template_section $
I also tried it with clang and clang put the function into .mysection as I
expected.
$ clang++ -std=c++14 a.cpp -c && objdump -t a.o | grep -E "regular|template"
0000000000000000 l F .mysection 0000000000000006
_ZN12_GLOBAL__N_112regular_funcEv
0000000000000010 l F .mysection 0000000000000006
_ZN12_GLOBAL__N_113template_funcIiEEvv