public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Sriraman Tallam <tmsriram@google.com>
To: Cary Coutant <ccoutant@gmail.com>
Cc: Xinliang David Li <davidxl@google.com>,
	Richard Biener <richard.guenther@gmail.com>,
		"H.J. Lu" <hjl.tools@gmail.com>,
	GCC Patches <gcc-patches@gcc.gnu.org>,
		binutils <binutils@sourceware.org>,
	Yury Gribov <y.gribov@samsung.com>
Subject: Re: [RFC] COMDAT Safe Module Level Multi versioning
Date: Tue, 18 Aug 2015 21:44:00 -0000	[thread overview]
Message-ID: <CAAs8HmwE5hBCv2H6g-o0QyBNSqS6c3Mhr=JCS+iNFMV=Q7=8bA@mail.gmail.com> (raw)
In-Reply-To: <CAJimCsGMs5B0ZbFRYo5Ju5OrBxxvUz74Xwp51-VmUCWXpobLmA@mail.gmail.com>

On Tue, Aug 18, 2015 at 2:14 PM, Cary Coutant <ccoutant@gmail.com> wrote:
>>>>> 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.
>
> +fweak-comdat-functions
> +C++ Var(flag_weak_comdat_functions) Init(1)
> +Specific to comdat functions(-fno-weak-comdat-functions : Localize
> Comdat Functions).
> +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"
> means.
>
> +@item -fno-weak-comdat-functions
> +@opindex fno-weak-comdat-functions
> +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.

Thanks, will make those changes.  Do you recommend a different name
for this flag like -fmake-comdat-functions-static?

Sri

>
> This looks like the right way to go, though.
>
> -cary

  parent reply	other threads:[~2015-08-18 21:33 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-05-19  6:30 Sriraman Tallam
2015-05-19  9:39 ` Richard Biener
2015-05-19 16:12   ` Xinliang David Li
2015-06-17  2:18     ` Sriraman Tallam
2015-08-04 18:43       ` Sriraman Tallam
2015-08-13  6:17         ` Sriraman Tallam
2015-08-18 18:46           ` Sriraman Tallam
2015-08-18 21:19             ` Cary Coutant
2015-08-18 21:25               ` Cary Coutant
2015-08-18 21:44               ` Sriraman Tallam [this message]
2015-08-19  4:53                 ` Cary Coutant
2015-09-03  0:51                   ` Sriraman Tallam
2015-09-09 23:27                     ` Sriraman Tallam
2015-10-05 21:58                       ` Sriraman Tallam
2016-09-12 19:30                         ` Sriraman Tallam
2015-05-19 17:22   ` Sriraman Tallam
2015-05-19 17:28 ` Yury Gribov
2015-05-19 18:18   ` Sriraman Tallam

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAAs8HmwE5hBCv2H6g-o0QyBNSqS6c3Mhr=JCS+iNFMV=Q7=8bA@mail.gmail.com' \
    --to=tmsriram@google.com \
    --cc=binutils@sourceware.org \
    --cc=ccoutant@gmail.com \
    --cc=davidxl@google.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=hjl.tools@gmail.com \
    --cc=richard.guenther@gmail.com \
    --cc=y.gribov@samsung.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).