public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] PR target/65064: Return false for COMMON symbols
@ 2015-02-15 14:19 H.J. Lu
  2015-02-18 13:18 ` H.J. Lu
  0 siblings, 1 reply; 4+ messages in thread
From: H.J. Lu @ 2015-02-15 14:19 UTC (permalink / raw)
  To: gcc-patches; +Cc: Richard Henderson

Hi,

r220674 exposed a bug in ia64_in_small_data_p.  After r220674, COMMON
symbols binds locally for executables.  But ia64_in_small_data_p returns
true for COMMON symbols which are never in small data section.  This patch
fixes it.  OK for trunk?

H.J.
----
Since COMMON symbols are never in small data section, ia64_in_small_data_p
should return false for COMMON symbols.

	PR target/65064
	* config/ia64/ia64.c (ia64_in_small_data_p): Return false for
	COMMON symbols.
---
 gcc/config/ia64/ia64.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/gcc/config/ia64/ia64.c b/gcc/config/ia64/ia64.c
index 6ef22d9..3687289 100644
--- a/gcc/config/ia64/ia64.c
+++ b/gcc/config/ia64/ia64.c
@@ -9941,6 +9941,10 @@ ia64_in_small_data_p (const_tree exp)
   if (TARGET_NO_SDATA)
     return false;
 
+  /* COMMON symbols are never small data.  */
+  if (DECL_COMMON (exp))
+    return false;
+
   /* We want to merge strings, so we never consider them small data.  */
   if (TREE_CODE (exp) == STRING_CST)
     return false;
-- 
2.1.0

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] PR target/65064: Return false for COMMON symbols
  2015-02-15 14:19 [PATCH] PR target/65064: Return false for COMMON symbols H.J. Lu
@ 2015-02-18 13:18 ` H.J. Lu
  2015-02-18 13:30   ` H.J. Lu
  2015-02-18 17:19   ` Richard Henderson
  0 siblings, 2 replies; 4+ messages in thread
From: H.J. Lu @ 2015-02-18 13:18 UTC (permalink / raw)
  To: gcc-patches, Richard Henderson

On Sun, Feb 15, 2015 at 06:19:21AM -0800, H.J. Lu wrote:
> Hi,
> 
> r220674 exposed a bug in ia64_in_small_data_p.  After r220674, COMMON
> symbols binds locally for executables.  But ia64_in_small_data_p returns
> true for COMMON symbols which are never in small data section.  This patch
> fixes it.  OK for trunk?
> 
> H.J.
> ----
> Since COMMON symbols are never in small data section, ia64_in_small_data_p
> should return false for COMMON symbols.
> 
> 	PR target/65064
> 	* config/ia64/ia64.c (ia64_in_small_data_p): Return false for
> 	COMMON symbols.


Although common symbols are defined in executables, they aren't in small
data section.  But a definition in small data section overrides a common
symbol, which still binds lcoally, and turns a reference to common symbol
to reference to small data section.  Even if ia64_in_small_data_p returns
true on common symbols, sdata_symbolic_operand must return false on common
symbols.  Common symbols are assumed to be placed in small data section,
but are accessed as if they are in normal data section so that they won't
cause any relocation overflow.

Tested by Andreas Schwab  <schwab@linux-m68k.org>. OK for trunk?

Thanks.


H.J.
---
	PR target/65064
	* config/ia64/predicates.md (sdata_symbolic_operand): Return false
	for common symbols.

diff --git a/gcc/config/ia64/predicates.md b/gcc/config/ia64/predicates.md
index cba0efe..b550882 100644
--- a/gcc/config/ia64/predicates.md
+++ b/gcc/config/ia64/predicates.md
@@ -69,7 +69,12 @@
 	     of constants here.  */
 	  t = SYMBOL_REF_DECL (op);
 	  if (DECL_P (t))
-	    t = DECL_SIZE_UNIT (t);
+	    {
+	      /* Common symbol isn't placed in small data section.  */
+	      if (DECL_COMMON (t))
+		return false;
+	      t = DECL_SIZE_UNIT (t);
+	    }
 	  else
 	    t = TYPE_SIZE_UNIT (TREE_TYPE (t));
 	  if (t && tree_fits_shwi_p (t))

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] PR target/65064: Return false for COMMON symbols
  2015-02-18 13:18 ` H.J. Lu
@ 2015-02-18 13:30   ` H.J. Lu
  2015-02-18 17:19   ` Richard Henderson
  1 sibling, 0 replies; 4+ messages in thread
From: H.J. Lu @ 2015-02-18 13:30 UTC (permalink / raw)
  To: GCC Patches, Richard Henderson

On Wed, Feb 18, 2015 at 5:18 AM, H.J. Lu <hjl.tools@gmail.com> wrote:
> On Sun, Feb 15, 2015 at 06:19:21AM -0800, H.J. Lu wrote:
>> Hi,
>>
>> r220674 exposed a bug in ia64_in_small_data_p.  After r220674, COMMON
>> symbols binds locally for executables.  But ia64_in_small_data_p returns
>> true for COMMON symbols which are never in small data section.  This patch
>> fixes it.  OK for trunk?
>>
>> H.J.
>> ----
>> Since COMMON symbols are never in small data section, ia64_in_small_data_p
>> should return false for COMMON symbols.
>>
>>       PR target/65064
>>       * config/ia64/ia64.c (ia64_in_small_data_p): Return false for
>>       COMMON symbols.
>
>
> Although common symbols are defined in executables, they aren't in small
> data section.  But a definition in small data section overrides a common
> symbol, which still binds lcoally, and turns a reference to common symbol
> to reference to small data section.  Even if ia64_in_small_data_p returns
> true on common symbols, sdata_symbolic_operand must return false on common

                         ^^^^^^ It should be true.
> symbols.  Common symbols are assumed to be placed in small data section,
> but are accessed as if they are in normal data section so that they won't
> cause any relocation overflow.
>
> Tested by Andreas Schwab  <schwab@linux-m68k.org>. OK for trunk?
>
> Thanks.
>
>
> H.J.
> ---
>         PR target/65064
>         * config/ia64/predicates.md (sdata_symbolic_operand): Return false
>         for common symbols.
>
> diff --git a/gcc/config/ia64/predicates.md b/gcc/config/ia64/predicates.md
> index cba0efe..b550882 100644
> --- a/gcc/config/ia64/predicates.md
> +++ b/gcc/config/ia64/predicates.md
> @@ -69,7 +69,12 @@
>              of constants here.  */
>           t = SYMBOL_REF_DECL (op);
>           if (DECL_P (t))
> -           t = DECL_SIZE_UNIT (t);
> +           {
> +             /* Common symbol isn't placed in small data section.  */
> +             if (DECL_COMMON (t))
> +               return false;
> +             t = DECL_SIZE_UNIT (t);
> +           }
>           else
>             t = TYPE_SIZE_UNIT (TREE_TYPE (t));
>           if (t && tree_fits_shwi_p (t))



-- 
H.J.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] PR target/65064: Return false for COMMON symbols
  2015-02-18 13:18 ` H.J. Lu
  2015-02-18 13:30   ` H.J. Lu
@ 2015-02-18 17:19   ` Richard Henderson
  1 sibling, 0 replies; 4+ messages in thread
From: Richard Henderson @ 2015-02-18 17:19 UTC (permalink / raw)
  To: H.J. Lu, gcc-patches

On 02/18/2015 05:18 AM, H.J. Lu wrote:
> 	PR target/65064
> 	* config/ia64/predicates.md (sdata_symbolic_operand): Return false
> 	for common symbols.

Ok.


r~

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2015-02-18 17:19 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-02-15 14:19 [PATCH] PR target/65064: Return false for COMMON symbols H.J. Lu
2015-02-18 13:18 ` H.J. Lu
2015-02-18 13:30   ` H.J. Lu
2015-02-18 17:19   ` Richard Henderson

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).