[PATCH] D19024: ELF: Give automatically generated __start_* and __stop_* symbols hidden visibility.

Peter Collingbourne via llvm-commits llvm-commits at lists.llvm.org
Tue Apr 12 12:33:37 PDT 2016


pcc added a comment.

I tracked down breakage in one of Chromium's test binaries to code that was doing something like this (in both an executable and a DSO):

  __attribute__((section("foo"))) void f() { .... }
  
  void g() {
    ... __start_foo ...
  }

In this case, the definition of `__start_foo` in the executable was coming from the DSO because we only check for undefined symbols when creating the synthetic symbol. If the executable is non-PIC, we cannot relocate the reference to `__start_foo` in `g` correctly, and we end up emitting a dynamic relocation for the .text section which causes a segfault at startup.

One way we could solve that problem is by replacing shared definitions with our synthetic symbols (that would make the behavior consistent with other synthetic symbols). But separate from that, I had to ask myself why we are making these symbols default visible in the first place, and I could not see a good reason.


http://reviews.llvm.org/D19024





More information about the llvm-commits mailing list