This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
[Xtensa] change relaxation of calls to weak symbols
- From: Bob Wilson <bwilson at tensilica dot com>
- To: binutils at sources dot redhat dot com
- Date: Wed, 12 Dec 2007 13:25:54 -0800
- Subject: [Xtensa] change relaxation of calls to weak symbols
I noticed yesterday that the Xtensa port of GAS has been relaxing all calls to
weak symbols, even when the --longcalls option is disabled. This seems wrong to
me. The assembler doesn't know the final address of a weak symbol, but that is
no different than a call to a different section. This patch changes GAS to
handle both of those cases (weak symbol and different section) in the same way.
Tested with an xtensa-elf build and committed.
2007-12-12 Bob Wilson <bob.wilson@acm.org>
* config/tc-xtensa.c (xg_symbolic_immeds_fit): Do not relax calls to
weak symbols if longcalls are disabled.
Index: config/tc-xtensa.c
===================================================================
RCS file: /cvs/src/src/gas/config/tc-xtensa.c,v
retrieving revision 1.93
diff -u -p -r1.93 tc-xtensa.c
--- config/tc-xtensa.c 11 Dec 2007 21:52:39 -0000 1.93
+++ config/tc-xtensa.c 12 Dec 2007 20:19:46 -0000
@@ -3235,23 +3235,19 @@ xg_symbolic_immeds_fit (const TInsn *ins
|| xtensa_operand_is_PCrelative (isa, insn->opcode, i) == 0)
return FALSE;
- /* If it is a weak symbol, then assume it won't reach. */
- if (S_IS_WEAK (expr->X_add_symbol))
- return FALSE;
-
- if (is_direct_call_opcode (insn->opcode)
- && ! pc_frag->tc_frag_data.use_longcalls)
- {
- /* If callee is undefined or in a different segment, be
- optimistic and assume it will be in range. */
- if (S_GET_SEGMENT (expr->X_add_symbol) != pc_seg)
+ /* If it is a weak symbol or a symbol in a different section,
+ it cannot be known to fit at assembly time. */
+ if (S_IS_WEAK (expr->X_add_symbol)
+ || S_GET_SEGMENT (expr->X_add_symbol) != pc_seg)
+ {
+ /* For a direct call with --no-longcalls, be optimistic and
+ assume it will be in range. */
+ if (is_direct_call_opcode (insn->opcode)
+ && ! pc_frag->tc_frag_data.use_longcalls)
return TRUE;
- }
- /* Only references within a segment can be known to fit in the
- operands at assembly time. */
- if (S_GET_SEGMENT (expr->X_add_symbol) != pc_seg)
- return FALSE;
+ return FALSE;
+ }
symbolP = expr->X_add_symbol;
sym_frag = symbol_get_frag (symbolP);