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

Fangrui Song via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Aug 19 04:44:34 PDT 2019


MaskRay added a comment.

In D65893#1634958 <https://reviews.llvm.org/D65893#1634958>, @jhenderson wrote:

> @chrisjackson and I work in the same team for Sony on the PlayStation toolchain, but our required semantics looks to be similar to the published ones in the Kiel documentation he mentioned.
>
> Regardless, I realised something on Friday that means that a switch is essentially a requirement. You cannot be guaranteed to have references to all three symbols in your source code. A typical usage might look something like this:


Agreed. There is no way to make the unrefenced symbol hidden in an object file.

Thanks for providing more background.

Have done some --export-dynamic and isPreemptible lld work recently, I think I favor the idea to use STV_PROTECTED to mark symbols as non-interposable in a shared object. In ELF, it is unfortunate that a STV_DEFAULT symbol in a shared object is by default interposable. Another unfortunate thing is that toolchains don't annotate STV_DEFAULT symbols properly when some symbols are actually non-interposable:

- -Bsymbolic -Bsymbolic-functions: all relevant symbols are non-interposable.
- --dynamic-list family (other --dynamic-list-* options are mostly unused nowadays): they do a fine control what symbols are interposable.

For those exported non-interposable STV_DEFAULT symbols, annotating them as STV_PROTECTED is a great use of symbol visibility.

> ... As a result, I think a --symbol-visibility switch as described above in llvm-objcopy would be very useful. A --redefine-visibility switch could also be useful potentially, but is a little trickier to use, since it would require potentially being specified two or three times, whereas a --symbol-visibility switch would only need specifying once (and could also be used to change the default visibility of --add-symbol specified symbols, simplifying users' command-lines).

I think `--symbol-visibility` is better than `--binary-symbol-visibility`, but it may still be a bit confusing. How about `--new-symbol-visibility`? It currently should affect `--add-symbol` and `-I binary`.

I also think `--redefine-visibility` may be niche. We can add it when it is needed.


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

https://reviews.llvm.org/D65893





More information about the llvm-commits mailing list