diff options
author | Jakub Jelinek <jakub@redhat.com> | 2002-11-14 08:56:54 +0100 |
---|---|---|
committer | Jakub Jelinek <jakub@gcc.gnu.org> | 2002-11-14 08:56:54 +0100 |
commit | 7eca317a0fc20ba4032dc77daad321700a855f82 (patch) | |
tree | 93129dfbe6218445158cf46b67c5590976b31681 /gcc/varasm.c | |
parent | 57751dd6cb0e941b9181e54edef85a795c108b8a (diff) | |
download | gcc-7eca317a0fc20ba4032dc77daad321700a855f82.zip gcc-7eca317a0fc20ba4032dc77daad321700a855f82.tar.gz gcc-7eca317a0fc20ba4032dc77daad321700a855f82.tar.bz2 |
varasm.c (output_addressed_constants): Clear reloc if both operands contain local relocations.
* varasm.c (output_addressed_constants) [MINUS_EXPR]: Clear reloc if
both operands contain local relocations.
(categorize_decl_for_section): Don't use mergeable sections if
initializer has any relocations.
* gcc.dg/20021029-1.c: New test.
* gcc.dg/20021029-2.c: New test.
From-SVN: r59097
Diffstat (limited to 'gcc/varasm.c')
-rw-r--r-- | gcc/varasm.c | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/gcc/varasm.c b/gcc/varasm.c index d498b8f..b158b92 100644 --- a/gcc/varasm.c +++ b/gcc/varasm.c @@ -3679,7 +3679,7 @@ static int output_addressed_constants (exp) tree exp; { - int reloc = 0; + int reloc = 0, reloc2; tree tem; /* Give the front-end a chance to convert VALUE to something that @@ -3708,11 +3708,20 @@ output_addressed_constants (exp) break; case PLUS_EXPR: - case MINUS_EXPR: reloc = output_addressed_constants (TREE_OPERAND (exp, 0)); reloc |= output_addressed_constants (TREE_OPERAND (exp, 1)); break; + case MINUS_EXPR: + reloc = output_addressed_constants (TREE_OPERAND (exp, 0)); + reloc2 = output_addressed_constants (TREE_OPERAND (exp, 1)); + /* The difference of two local labels is computable at link time. */ + if (reloc == 1 && reloc2 == 1) + reloc = 0; + else + reloc |= reloc2; + break; + case NOP_EXPR: case CONVERT_EXPR: case NON_LVALUE_EXPR: @@ -5076,7 +5085,7 @@ categorize_decl_for_section (decl, reloc, shlib) ret = SECCAT_DATA_REL_RO; else if (shlib && reloc) ret = SECCAT_DATA_REL_RO_LOCAL; - else if (flag_merge_constants < 2) + else if (reloc || flag_merge_constants < 2) /* C and C++ don't allow different variables to share the same location. -fmerge-all-constants allows even that (at the expense of not conforming). */ |