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

            Bug ID: 65262
           Summary: Link time optimization breaks use
                    __attribute__((section("..."))) in templates
           Product: gcc
           Version: 4.8.3
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: lto
          Assignee: unassigned at gcc dot gnu.org
          Reporter: goswin-v-b at web dot de
                CC: goswin-v-b at web dot de

Created attachment 34911
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=34911&action=edit
Simple testcase

I'm trying to put a template member functions of a class into a different
section. Without -flto this works but with -flto the function reverts to the
.text section.

g++ -O2 -W -Wall -fvisibility=hidden -fno-inline -Tlink.ld -c -o main.o main.cc
g++ -O2 -W -Wall -fvisibility=hidden -fno-inline -Tlink.ld -o main main.o
g++ -O2 -W -Wall -fvisibility=hidden -fno-inline -Tlink.ld -flto -c -o
main.lto.o main.cc
g++ -O2 -W -Wall -fvisibility=hidden -fno-inline -Tlink.ld -flto -o main.lto
main.lto.o
Without link time optimization:
0000000000000200 l    d  .text.foo      0000000000000000              .text.foo
0000000000000210 g     F .text.foo      0000000000000006              .hidden
foo()
0000000000000200  w    F .text.foo      0000000000000006              .hidden
int foobar<int>()

With link time optimization:
0000000000000820 l    d  .text.foo      0000000000000000              .text.foo
0000000000000100 l     F .text  0000000000000006              int foobar<int>()
0000000000000820 l     F .text.foo      0000000000000006              foo()

Reply via email to