[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
Sun Aug 18 20:35:29 PDT 2019


MaskRay added a comment.

> We are in the process of transitioning to the ELF visibility scheme away from a different private implementation. The old implementation required the use of __declspec(dllexport) to export. This meant that exporting was an opt-in process on the part of the exporter, whereas the normal ELF process is an opt-out process on the part of the exporter.



> Since exporting was always opt-in, GNU objcopy's behaviour (and up to this point of transition llvm-objcopy's too) resulted in the new symbols not being exported.

I'm rather confused. If your GNU objcopy isn't pached, how can it result in the new symbols not being exported? It doesn't have a flag to control the visibility of `_binary_a_start`.

> Note that the producers of an object may not always be the same as the consumers of that object, so the behaviour really needs to be on the producer's end.

I don't follow the causality here. The visibility is the most restricted one among the producer (definition) and consumers (references).

Actually I think the undefined reference (`extern const char _binary_a_start[];`) should really have a visibility attribute to annotate that the linked component should have the reference resolved within the same component (executable or DSO). It cannot be left undefined but interposed at runtime by another DSO.

> Otherwise an updated build of the object will require a change in the consumer's source code - or their linked output will contain exported symbols without them expecting it.

If you migrate to something like `-fvisibility=hidden`, you'll need visibility attributes to mark exported functions/objects.

> I've taken a brief look at the Kiel/μVision docs and I see that the behaviour they have is somewhat similar to what we require, namely that symbols are STV_HIDDEN by default, so it looks like we aren't the only people for whom this behaviour would be useful.

The link you gave to me is a Kiel/μVision link, so I thought you were a Kiel/μVision developer/user. Then you said you are not those people... Sorry if I misunderstood your affiliation but I don't find why this option can be justified by their non-standard behaviors...


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

https://reviews.llvm.org/D65893





More information about the llvm-commits mailing list