This is the mail archive of the
mailing list for the binutils project.
Re: [RFC] COMDAT Safe Module Level Multi versioning
- From: Cary Coutant <ccoutant at gmail dot com>
- To: Sriraman Tallam <tmsriram at google dot com>
- Cc: Xinliang David Li <davidxl at google dot com>, Richard Biener <richard dot guenther at gmail dot com>, "H.J. Lu" <hjl dot tools at gmail dot com>, GCC Patches <gcc-patches at gcc dot gnu dot org>, binutils <binutils at sourceware dot org>, Yury Gribov <y dot gribov at samsung dot com>
- Date: Tue, 18 Aug 2015 14:14:14 -0700
- Subject: Re: [RFC] COMDAT Safe Module Level Multi versioning
- Authentication-results: sourceware.org; auth=none
- References: <CAAs8HmyB5jZS_zfHKeX9HEK3Eo59nVhuB4yfoGTy5hXV41YZYA at mail dot gmail dot com> <CAFiYyc1b++CR5FJBG4cFTZ2ec+dWgxXgoYWP72GWHtQ8BPruLg at mail dot gmail dot com> <CAAkRFZK3kgRbtCVTU7z04ugxSSCqmm_BA+Y=fW=MqnjNcV21Tg at mail dot gmail dot com> <CAAs8HmzY-YPt2bE6ce7S68Uh42KvfOZfLyMzT-N8JTFMbu9yPg at mail dot gmail dot com> <CAAs8HmwfrRfVuSU4iorW7ETscxxf4WqGx1qr+9+VeZ0Fe7xQKQ at mail dot gmail dot com> <CAAs8HmyoUAawcggMC7NU-LO4186vM2D4KL+xkA81PWdO32BXPg at mail dot gmail dot com> <CAAs8HmyVjF+cG10euUFNMZoLP6nV4V8nvqmCbNwSMgJr926C-Q at mail dot gmail dot com>
>>>> Based on Richard's suggestion, I have a patch to localize comdat
>>>> functions which seems like a very effective solution to this problem.
>>>> The text size increase is limited to the extra comdat copies generated
>>>> for the specialized modules (modules with unsafe options) which is
>>>> usually only a few. Since -fweak does something similar for
>>>> functions, I have called the new option -fweak-comdat-functions.
>>>> This does not apply to virtual comdat functions as their addresses can
>>>> always be leaked via the vtable. Using this flag with virtual
>>>> functions generates a warning.
+C++ Var(flag_weak_comdat_functions) Init(1)
+Specific to comdat functions(-fno-weak-comdat-functions : Localize
+With -fno-weak-comdat-functions, virtual comdat functions are still linked as
+weak functions. With -fno-weak-comdat-functions, the address of the comdat
+functions that are localized will be unique and this can cause unintended
+behavior when addresses of comdat functions are used.
Is one of those "With -fno-weak-comdat-functions" supposed to be "With
-fweak-comdat-functions"? This description doesn't really say what the
flag (without the "no") does, and doesn't explain what "localize"
+Do not use weak symbol support for comdat non-virtual functions, even if it
+is provided by the linker. By default, G++ uses weak symbols if they are
+available. This option is useful when comdat functions generated in certain
+compilation units need to be kept local to the respective units and not exposed
+globally. This does not apply to virtual comdat functions as their pointers
+may be taken via virtual tables. This can cause unintended behavior if
+the addresses of comdat functions are used.
It's not really the "weak" that is causing the problem -- it's the
"comdat". What the option really is doing is making the functions
static rather than comdat. (It's all gated under flag_weak because
weak symbols are the fall-back to link-once and comdat symbols.) I'd
suggest phrasing this more in terms of static vs. comdat.
This looks like the right way to go, though.