On Wed, May 4, 2022 at 3:31 PM Martin Liška <mli...@suse.cz> wrote: > > On 5/4/22 15:10, Alexander Monakov wrote: > > On Wed, 4 May 2022, Martin Liška wrote: > > > >> On 5/4/22 14:32, Alexander Monakov wrote: > >>> On Wed, 4 May 2022, Martin Liška wrote: > >>> > >>>> The patch is a follow-up of the discussion we've got in: > >>>> https://gcc.gnu.org/pipermail/gcc-patches/2022-May/593901.html > >>>> > >>>> Mold linker would appreciate knowing in advance if get_symbols_v3 is > >>>> supported > >>>> by a GCC plug-in or not. > > > > Out of curiousity, I looked at mold, and I don't understand what problem > > this > > detection is solving, nor why this is the best way to solve that. Was there > > some discussion with mold author I should check out? > > Sure, please take a look at this issue: > https://github.com/rui314/mold/issues/454#issuecomment-1116849458 > > > > > Note that mold takes this not only as 'v3 API is supported', but, more > > importantly, as 'v2 entrypoint will not be called'. > > Yes, if they register get_symbols_v3, then it will be called. That's how the > plug-in works.
I think they should simply try to not register LDPT_GET_SYMBOLS or LDPT_GET_SYMBOLS_V2 with the plugin in the onload hook and if that fails they will know the plugin doesn't support V3 only. I suppose it should work to call onload() multiple times (when only increasing the set of supported functions) until it returns LDPS_OK without intermediately dlclosing it (maybe call cleanup_handler inbertween). This should work for old plugin versions. That said, a better API extension compared to adding some random symbol like you propose is to enhance the return value from onload(), maybe returning an alternate transfer vector specifying symbol entries that will not be used (or return a transfer vector that will be used). We've been mostly versioning the symbol related hooks here. That said, I do not like at all this proposed add of a special symbol to flag exclusive v3 use. That's a hack and not extensible at all. Richard. > Martin > > > > > Alexander >