From c77c286a724a0aef1c008516d840953a02700274 Mon Sep 17 00:00:00 2001 From: Jeff Law Date: Tue, 4 Jun 1996 12:58:08 -0600 Subject: [PATCH] pa.c (reloc_needed): New function. * pa/pa.c (reloc_needed): New function. * pa/pa.h (TEXT_SPACE_P): Variables/constants with initializers requiring relocs never live in the text space. From-SVN: r12156 --- gcc/config/pa/pa.c | 41 +++++++++++++++++++++++++++++++++++++++++ gcc/config/pa/pa.h | 2 ++ 2 files changed, 43 insertions(+) diff --git a/gcc/config/pa/pa.c b/gcc/config/pa/pa.c index 52375af161d..f2dca71dcee 100644 --- a/gcc/config/pa/pa.c +++ b/gcc/config/pa/pa.c @@ -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. */ diff --git a/gcc/config/pa/pa.h b/gcc/config/pa/pa.h index 1f0af0ef9b8..c1c082be34f 100644 --- a/gcc/config/pa/pa.h +++ b/gcc/config/pa/pa.h @@ -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) \ -- 2.30.2