This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: relocation truncated to fit BRADDR text
- To: Jeff Garzik <jgarzik at mandrakesoft dot com>
- Subject: Re: relocation truncated to fit BRADDR text
- From: Richard Henderson <rth at redhat dot com>
- Date: Thu, 8 Nov 2001 14:41:25 -0800
- Cc: gcc at gcc dot gnu dot org, gcc-patches at gcc dot gnu dot org
- References: <3BE95769.E80ACFFF@mandrakesoft.com>
On Wed, Nov 07, 2001 at 10:46:49AM -0500, Jeff Garzik wrote:
> command.o: In function `ResizeCommand::~ResizeCommand(void)':
> command.o(.gnu.linkonce.t._$_13ResizeCommand+0x2c): relocation truncated
> to fit: BRADDR text
Hmm. Try this.
r~
* config/alpha/alpha.c (in_text_section): New.
(current_file_function_operand): Use it.
(alpha_encode_section_info, alpha_end_function): Likewise.
Index: config/alpha/alpha.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/alpha/alpha.c,v
retrieving revision 1.201
diff -c -p -d -r1.201 alpha.c
*** alpha.c 2001/11/04 02:51:22 1.201
--- alpha.c 2001/11/08 22:39:08
*************** int alpha_this_literal_sequence_number;
*** 114,119 ****
--- 114,121 ----
int alpha_this_gpdisp_sequence_number;
/* Declarations of static functions. */
+ static bool in_text_section
+ PARAMS ((tree));
static bool local_symbol_p
PARAMS ((rtx));
static void alpha_set_memflags_1
*************** input_operand (op, mode)
*** 832,838 ****
}
/* Return 1 if OP is a SYMBOL_REF for a function known to be in this
! file. */
int
current_file_function_operand (op, mode)
--- 834,840 ----
}
/* Return 1 if OP is a SYMBOL_REF for a function known to be in this
! file, and in the same section as the current function. */
int
current_file_function_operand (op, mode)
*************** current_file_function_operand (op, mode)
*** 842,852 ****
if (GET_CODE (op) != SYMBOL_REF)
return 0;
! if (! SYMBOL_REF_FLAG (op)
! && op != XEXP (DECL_RTL (current_function_decl), 0))
! return 0;
! return 1;
}
/* Return 1 if OP is a SYMBOL_REF for which we can make a call via bsr. */
--- 844,861 ----
if (GET_CODE (op) != SYMBOL_REF)
return 0;
! /* Easy test for recursion. */
! if (op == XEXP (DECL_RTL (current_function_decl), 0))
! return 1;
! /* Otherwise, we need the DECL for the SYMBOL_REF, which we can't get.
! So SYMBOL_REF_FLAG has been declared to imply that the function is
! in the default text section. So we must also check that the current
! function is also in the text section. */
! if (SYMBOL_REF_FLAG (op) && in_text_section (current_function_decl))
! return 1;
!
! return 0;
}
/* Return 1 if OP is a SYMBOL_REF for which we can make a call via bsr. */
*************** alpha_tablejump_best_label (insn)
*** 1392,1397 ****
--- 1401,1422 ----
return best_label ? best_label : const0_rtx;
}
+ /* Return true if the function DECL will be placed in the default text
+ section. */
+ /* ??? Ideally we'd be able to always move from a SYMBOL_REF back to the
+ decl, as that would allow us to determine if two functions are in the
+ same section, which is what we really want to know. */
+
+ static bool
+ in_text_section (decl)
+ tree decl;
+ {
+ return (DECL_SECTION_NAME (decl) == NULL_TREE
+ && ! (flag_function_sections
+ || (targetm.have_named_sections
+ && DECL_ONE_ONLY (decl))));
+ }
+
/* If we are referencing a function that is static, make the SYMBOL_REF
special. We use this to see indicate we can branch to this function
without setting PV or restoring GP.
*************** alpha_encode_section_info (decl)
*** 1409,1416 ****
if (TREE_CODE (decl) == FUNCTION_DECL)
{
! if (! TREE_PUBLIC (decl))
! SYMBOL_REF_FLAG (XEXP (DECL_RTL (decl), 0)) = 1;
return;
}
--- 1434,1449 ----
if (TREE_CODE (decl) == FUNCTION_DECL)
{
! /* We mark public functions once they are emitted; otherwise we
! don't know that they exist in this unit of translation. */
! if (TREE_PUBLIC (decl))
! return;
! /* Do not mark functions that are not in .text; otherwise we
! don't know that they are near enough for a direct branch. */
! if (! in_text_section (decl))
! return;
!
! SYMBOL_REF_FLAG (XEXP (DECL_RTL (decl), 0)) = 1;
return;
}
*************** alpha_end_function (file, fnname, decl)
*** 6673,6682 ****
Don't do this for global functions in object files destined for a
shared library because the function may be overridden by the application
! or other libraries. Similarly, don't do this for weak functions. */
if (!DECL_WEAK (current_function_decl)
! && (!flag_pic || !TREE_PUBLIC (current_function_decl)))
SYMBOL_REF_FLAG (XEXP (DECL_RTL (current_function_decl), 0)) = 1;
/* Output jump tables and the static subroutine information block. */
--- 6706,6720 ----
Don't do this for global functions in object files destined for a
shared library because the function may be overridden by the application
! or other libraries. Similarly, don't do this for weak functions.
+ Don't do this for functions not defined in the .text section, as
+ otherwise it's not unlikely that the destination is out of range
+ for a direct branch. */
+
if (!DECL_WEAK (current_function_decl)
! && (!flag_pic || !TREE_PUBLIC (current_function_decl))
! && in_text_section (current_function_decl))
SYMBOL_REF_FLAG (XEXP (DECL_RTL (current_function_decl), 0)) = 1;
/* Output jump tables and the static subroutine information block. */