This is the mail archive of the
binutils@sources.redhat.com
mailing list for the binutils project.
[PATCH]: Fix weak symbols for 68HC11 as
- To: binutils at sources dot redhat dot com
- Subject: [PATCH]: Fix weak symbols for 68HC11 as
- From: Stephane Carrez <Stephane dot Carrez at worldnet dot fr>
- Date: Thu, 11 Jan 2001 19:44:42 +0100
Hi!
In the 68HC11/68HC12 gas, when a function was defined "weak", and when
a call was made to that function in the same object file,
a relaxation of the call is made. If the function is re-defined
non-weak in other place, the final link looses because it
lost the call information (because it was relaxed).
To solve that pb, I've followed the 68K assembler which
avoids the relaxation of the symbol if it is marked as weak.
Stephane
2001-01-11 Stephane Carrez <Stephane.Carrez@worldnet.fr>
* config/tc-m68hc11.c (md_estimate_size_before_relax):Don't
relax weak symbols.
(relaxable_symbol): New function.
Index: config/tc-m68hc11.c
===================================================================
RCS file: /cvs/src/src/gas/config/tc-m68hc11.c,v
retrieving revision 1.9
diff -p -r1.9 tc-m68hc11.c
*** tc-m68hc11.c 2000/12/03 06:49:22 1.9
--- tc-m68hc11.c 2001/01/11 19:36:15
***************
*** 1,5 ****
/* tc-m68hc11.c -- Assembler code for the Motorola 68HC11 & 68HC12.
! Copyright (C) 1999, 2000 Free Software Foundation.
Written by Stephane Carrez (stcarrez@worldnet.fr)
This file is part of GAS, the GNU Assembler.
--- 1,5 ----
/* tc-m68hc11.c -- Assembler code for the Motorola 68HC11 & 68HC12.
! Copyright (C) 1999, 2000, 2001 Free Software Foundation.
Written by Stephane Carrez (stcarrez@worldnet.fr)
This file is part of GAS, the GNU Assembler.
*************** md_convert_frag (abfd, sec, fragP)
*** 2527,2532 ****
--- 2527,2542 ----
}
}
+ /* On an ELF system, we can't relax an externally visible symbol,
+ as well as a weak symbol. The weak symbol can be overriden
+ at final link time by a non weak symbol. */
+ static int
+ relaxable_symbol (symbol)
+ symbolS* symbol;
+ {
+ return ! S_IS_EXTERNAL (symbol) && ! S_IS_WEAK (symbol);
+ }
+
/* Force truly undefined symbols to their maximum size, and generally set up
the frag list to be relaxed. */
int
*************** md_estimate_size_before_relax (fragP, se
*** 2549,2555 ****
|| IS_OPCODE (fragP->fr_opcode[0], M6812_BSR));
/* A relaxable case. */
! if (S_GET_SEGMENT (fragP->fr_symbol) == segment)
{
fragP->fr_subtype = ENCODE_RELAX (STATE_PC_RELATIVE, STATE_BYTE);
}
--- 2559,2566 ----
|| IS_OPCODE (fragP->fr_opcode[0], M6812_BSR));
/* A relaxable case. */
! if (S_GET_SEGMENT (fragP->fr_symbol) == segment
! && relaxable_symbol (fragP->fr_symbol))
{
fragP->fr_subtype = ENCODE_RELAX (STATE_PC_RELATIVE, STATE_BYTE);
}
*************** md_estimate_size_before_relax (fragP, se
*** 2575,2581 ****
case ENCODE_RELAX (STATE_CONDITIONAL_BRANCH, STATE_UNDF):
assert (current_architecture & cpu6811);
! if (S_GET_SEGMENT (fragP->fr_symbol) == segment)
{
fragP->fr_subtype = ENCODE_RELAX (STATE_CONDITIONAL_BRANCH,
STATE_BYTE);
--- 2586,2593 ----
case ENCODE_RELAX (STATE_CONDITIONAL_BRANCH, STATE_UNDF):
assert (current_architecture & cpu6811);
! if (S_GET_SEGMENT (fragP->fr_symbol) == segment
! && relaxable_symbol (fragP->fr_symbol))
{
fragP->fr_subtype = ENCODE_RELAX (STATE_CONDITIONAL_BRANCH,
STATE_BYTE);
*************** md_estimate_size_before_relax (fragP, se
*** 2600,2606 ****
case ENCODE_RELAX (STATE_INDEXED_OFFSET, STATE_UNDF):
assert (current_architecture & cpu6812);
! if (S_GET_SEGMENT (fragP->fr_symbol) == segment)
{
fragP->fr_subtype = ENCODE_RELAX (STATE_INDEXED_OFFSET,
STATE_BITS5);
--- 2612,2619 ----
case ENCODE_RELAX (STATE_INDEXED_OFFSET, STATE_UNDF):
assert (current_architecture & cpu6812);
! if (S_GET_SEGMENT (fragP->fr_symbol) == segment
! && relaxable_symbol (fragP->fr_symbol))
{
fragP->fr_subtype = ENCODE_RELAX (STATE_INDEXED_OFFSET,
STATE_BITS5);
*************** md_estimate_size_before_relax (fragP, se
*** 2622,2628 ****
case ENCODE_RELAX (STATE_XBCC_BRANCH, STATE_UNDF):
assert (current_architecture & cpu6812);
! if (S_GET_SEGMENT (fragP->fr_symbol) == segment)
{
fragP->fr_subtype = ENCODE_RELAX (STATE_XBCC_BRANCH, STATE_BYTE);
}
--- 2635,2642 ----
case ENCODE_RELAX (STATE_XBCC_BRANCH, STATE_UNDF):
assert (current_architecture & cpu6812);
! if (S_GET_SEGMENT (fragP->fr_symbol) == segment
! && relaxable_symbol (fragP->fr_symbol))
{
fragP->fr_subtype = ENCODE_RELAX (STATE_XBCC_BRANCH, STATE_BYTE);
}
*************** md_estimate_size_before_relax (fragP, se
*** 2646,2652 ****
case ENCODE_RELAX (STATE_CONDITIONAL_BRANCH_6812, STATE_UNDF):
assert (current_architecture & cpu6812);
! if (S_GET_SEGMENT (fragP->fr_symbol) == segment)
{
fragP->fr_subtype = ENCODE_RELAX (STATE_CONDITIONAL_BRANCH_6812,
STATE_BYTE);
--- 2660,2667 ----
case ENCODE_RELAX (STATE_CONDITIONAL_BRANCH_6812, STATE_UNDF):
assert (current_architecture & cpu6812);
! if (S_GET_SEGMENT (fragP->fr_symbol) == segment
! && relaxable_symbol (fragP->fr_symbol))
{
fragP->fr_subtype = ENCODE_RELAX (STATE_CONDITIONAL_BRANCH_6812,
STATE_BYTE);