OSDN Git Service

* pa/pa.c (reloc_needed): New function.
authorlaw <law@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 4 Jun 1996 18:58:08 +0000 (18:58 +0000)
committerlaw <law@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 4 Jun 1996 18:58:08 +0000 (18:58 +0000)
        * pa/pa.h (TEXT_SPACE_P): Variables/constants with initializers
        requiring relocs never live in the text space.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@12156 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/config/pa/pa.c
gcc/config/pa/pa.h

index 52375af..f2dca71 100644 (file)
@@ -1182,6 +1182,47 @@ emit_move_sequence (operands, mode, scratch_reg)
   return 0;
 }
 
+/* Examine EXP and return nonzero if it contains an ADDR_EXPR (meaning
+   it will need a link/runtime reloc.  */
+
+int
+reloc_needed (exp)
+     tree exp;
+{
+  int reloc = 0;
+
+  switch (TREE_CODE (exp))
+    {
+    case ADDR_EXPR:
+      return 1;
+
+    case PLUS_EXPR:
+    case MINUS_EXPR:
+      reloc = reloc_needed (TREE_OPERAND (exp, 0));
+      reloc |= reloc_needed (TREE_OPERAND (exp, 1));
+      break;
+
+    case NOP_EXPR:
+    case CONVERT_EXPR:
+    case NON_LVALUE_EXPR:
+      reloc = reloc_needed (TREE_OPERAND (exp, 0));
+      break;
+
+    case CONSTRUCTOR:
+      {
+       register tree link;
+       for (link = CONSTRUCTOR_ELTS (exp); link; link = TREE_CHAIN (link))
+         if (TREE_VALUE (link) != 0)
+           reloc |= reloc_needed (TREE_VALUE (link));
+      }
+      break;
+
+    case ERROR_MARK:
+      break;
+    }
+  return reloc;
+}
+
 /* Does operand (which is a symbolic_operand) live in text space? If
    so SYMBOL_REF_FLAG, which is set by ENCODE_SECTION_INFO, will be true.  */
 
index 1f0af0e..c1c082b 100644 (file)
@@ -1530,8 +1530,10 @@ extern struct rtx_def *hppa_legitimize_address ();
   (TREE_CODE (DECL) == FUNCTION_DECL                                   \
    || (TREE_CODE (DECL) == VAR_DECL                                    \
        && TREE_READONLY (DECL) && ! TREE_SIDE_EFFECTS (DECL)           \
+       && (! DECL_INITIAL (DECL) || ! reloc_needed (DECL_INITIAL (DECL))) \
        && !flag_pic)                                                   \
    || (*tree_code_type[(int) TREE_CODE (DECL)] == 'c'                  \
+       && (! DECL_INITIAL (DECL) || ! reloc_needed (DECL_INITIAL (DECL))) \
        && !(TREE_CODE (DECL) == STRING_CST && flag_writable_strings)))
 
 #define FUNCTION_NAME_P(NAME) \