[PATCH] D55682: [ELF] Support defining __start/__stop symbols as hidden

Fangrui Song via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Dec 19 12:36:29 PST 2018


MaskRay added a comment.

> In D55682#1332033 <https://reviews.llvm.org/D55682#1332033>, @pcc wrote:
> 
>> I don't think you need to introduce an option for this. You can give the `__start_` and `__stop_` symbols hidden visibility in any object file, and the symbols in the final output file will be hidden because the linker will choose the most restrictive visibility that it sees for the visibility of the symbols in the final output file.
> 
> 
> Yes that works, but it has to be done explicitly for each such symbol. We cannot change these symbols to be hidden by default for existing platforms as described above, but we would like to make them hidden by default in Fuchsia since we don't have any legacy code (yet) that would depend on the existing behavior. Introducing new option allows us to set it in the driver like we already do e.g. for `-z rodynamic` <https://github.com/llvm-mirror/clang/blob/master/lib/Driver/ToolChains/Fuchsia.cpp#L50> which is a similar case.

Does that mean there is a visibility mismatch between source code and linker-defined symbol? e.g.

  //extern char __start_f __attribute__((visibility("hidden")));
  extern char __start_f; // Fuchsia wants to write code like this, but its visibility is set to hidden due to -z hidden-start-stop-symbols
  
  __attribute__((section("f"))) char *foo() {
    return &__start_f;
  }

Please correct me but if my understanding is correct, I think the explicit visibility attribute in source code would be clearer.


Repository:
  rLLD LLVM Linker

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D55682/new/

https://reviews.llvm.org/D55682





More information about the llvm-commits mailing list