<html>
    <head>
      <base href="https://llvm.org/bugs/" />
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW --- - lld + LTO: symbol __start_($SECTION_NAME) is missing type"
   href="https://llvm.org/bugs/show_bug.cgi?id=30680">30680</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>lld + LTO: symbol __start_($SECTION_NAME) is missing type
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>lld
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>unspecified
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>PC
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>Linux
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>normal
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>ELF
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>unassignedbugs@nondot.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>krasin@google.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org
          </td>
        </tr>

        <tr>
          <th>Classification</th>
          <td>Unclassified
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Created <span class=""><a href="attachment.cgi?id=17429" name="attach_17429" title="the reproducer">attachment 17429</a> <a href="attachment.cgi?id=17429&action=edit" title="the reproducer">[details]</a></span>
the reproducer

Consider the following shared object (the full reproducer is attached):

bar.cc:

__attribute((visibility("default"))) __attribute__ ((section("play_go")))
void* get_start();

extern "C" char __start_play_go[] __attribute__((weak));

void* get_start() {
  return reinterpret_cast<void*>(__start_play_go);
}

Basically, we put get_start function into play_go section and also use
__start_play_go symbol to keep it there.

Then we try to use this symbol from main.cc

#include <stdio.h>

extern "C" char __start_play_go[] __attribute__((weak));

int main(void) {
  printf("__start_play_go: %p\n", __start_play_go);
}

Building:

$ clang++ -shared -o libbar.so bar.cc
$ clang++ -c main.cc -flto
$ clang++ -o sections main.o libbar.so -flto -fuse-ld=lld
symbol __start_play_go is missing type
clang-3.9: error: linker command failed with exit code 1 (use -v to see
invocation)

I observe that while building Chromium, as tcmalloc uses this dark magic of
sections for hooks.</pre>
        </div>
      </p>
      <hr>
      <span>You are receiving this mail because:</span>
      
      <ul>
          <li>You are on the CC list for the bug.</li>
      </ul>
    </body>
</html>