[PATCH] D65893: [llvm-objcopy] Allow the visibility of the start, end and size symbols created by --binary to be specified with --binary-symbol-visibility

Chris Jackson via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Aug 14 06:35:08 PDT 2019


chrisjackson added a comment.
Herald added a subscriber: seiya.

In D65893#1624154 <https://reviews.llvm.org/D65893#1624154>, @MaskRay wrote:

> In D65893#1623201 <https://reviews.llvm.org/D65893#1623201>, @chrisjackson wrote:
>
> > - For our use cases it is more convenient to change the symbol's visibility with an option than to have users alter their source code.
>
>
> I accepted D65891 <https://reviews.llvm.org/D65891> because:
>
> - It deals with an existing option: `--add-symbol`. `protected` is a natural extension to the existing `default`/`hidden` visibility. Nobody will get puzzled by this addition.
> - According to Changes to symbol visibility between RVCT v3.1 for µVision and RVCT v4.0 <http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.dui0593a/BEHEHEFC.html> for µVision you linked, there are some use cases. I guess it is used for preventing inadvertent preemption in static linking.
>
>   The first bullet is sufficient for me to accept it, but I hope you can elaborate more on the second bullet. How do you use STV_PROTECTED in object files and shared objects? What semantics do you expected when linking STV_DEFAULT/STV_PROTECTED undefined/defined together?
>
> > For our use cases it is more convenient to change the symbol's visibility with an option than to have users alter their source code.
>
> `--binary-symbol-visibility` can cause confusion. As suggested by rupprecht, it should be generalized to `--redefine-visibility=` if we do want the option.


I agree that the generalized version is useful and I have been looking at a patch for this. However, in this specific case the symbol names are automatically generated based on the path of the binary, so it makes it difficult to specify these specific symbol names on the command line.

With regards to the expected semantics, we anticipate standard ELF semantics when combining different visibilities. Our toolchain operates using a default visibility of STV_HIDDEN for definitions unless explicitly exported, in which case they are STV_PROTECTED. This means that declarations need not be explicitly marked with a visibility in order to be exported or not. The new switch allows the replication of the compiler's -fvisibility=hidden switch in llvm-objcopy. As an alternative to the name --binary-symbol-visibility, how about --symbol-visibility?  This would affect the visibility of all the new symbols generated by llvm-objcopy, not just those symbols added for binary input.


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

https://reviews.llvm.org/D65893





More information about the llvm-commits mailing list