This is the mail archive of the
binutils@sources.redhat.com
mailing list for the binutils project.
TC_FORCE_RELOCATION_SECTION macro
- To: binutils at sourceware dot cygnus dot com
- Subject: TC_FORCE_RELOCATION_SECTION macro
- From: Alan Modra <alan at linuxcare dot com dot au>
- Date: Fri, 15 Sep 2000 01:31:00 +1100 (EST)
Hi,
I want to commit the following to have hppa-elf emit relocations for
extern or weak syms, but before I do so, I'd like to have some
feedback/comments on TC_FORCE_RELOCATION_SECTION.
It looks to me like TC_FORCE_RELOCATION_SECTION has suffered bit-rot since
Michael Meissner added it for ppc. Currently, the macro is invoked from
just one place in gas/write.c, and it happens to be where we are
subtracting two symbols. TC_FORCE_RELOCATION_SECTION is only defined
by tc-i370.h, where it seems totally bogus, and by tc-ppc.h. The tc-ppc.h
definition is where I suspect bit-rot has occurred, as it's equivalent to
TC_FORCE_RELOCATION since (FIXP)->fx_subsy is non-zero.
So.. a) Does the tc-ppc.h definition need fixing?
b) Would the macro be better named TC_FORCE_RELOCATION_SUBTRACT, so
that someone doesn't have the bright idea of using it elsewhere in
write.c and breaking my assumption in this patch that it's only
called when subtracting two symbols in the same section.
gas/ChangeLog
* config/tc-hppa.h (TC_FORCE_RELOCATION_SECTION): Allow
subtraction of two syms without emitting a relocation.
* config/tc-hppa.c (hppa_force_relocation): Force relocations for
global or weak symbols. Delete a FIXME handled a bit later.
Alan Modra
--
Linuxcare. Support for the Revolution.
Index: config/tc-hppa.c
===================================================================
RCS file: /cvs/src/src/gas/config/tc-hppa.c,v
retrieving revision 1.65
diff -u -p -r1.65 tc-hppa.c
--- tc-hppa.c 2000/09/07 01:34:02 1.65
+++ tc-hppa.c 2000/09/14 13:22:11
@@ -8416,9 +8416,15 @@ hppa_force_relocation (fixp)
return 1;
#endif
+ /* Ensure we emit a relocation for global symbols so that dynamic
+ linking works. */
+ if (fixp->fx_addsy && (S_IS_EXTERNAL (fixp->fx_addsy)
+ || S_IS_WEAK (fixp->fx_addsy)))
+ return 1;
+
/* It is necessary to force PC-relative calls/jumps to have a relocation
entry if they're going to need either a argument relocation or long
- call stub. FIXME. Can't we need the same for absolute calls? */
+ call stub. */
if (fixp->fx_pcrel && fixp->fx_addsy
&& (arg_reloc_stub_needed (symbol_arg_reloc_info (fixp->fx_addsy),
hppa_fixp->fx_arg_reloc)))
Index: config/tc-hppa.h
===================================================================
RCS file: /cvs/src/src/gas/config/tc-hppa.h,v
retrieving revision 1.11
diff -u -p -r1.11 tc-hppa.h
--- tc-hppa.h 2000/09/05 03:45:18 1.11
+++ tc-hppa.h 2000/09/14 13:22:12
@@ -124,6 +124,10 @@ int hppa_fix_adjustable PARAMS((struct f
normally appear safe to handle it completely within GAS. */
#define TC_FORCE_RELOCATION(FIXP) hppa_force_relocation (FIXP)
+/* It's OK to subtract two symbols in the same section without
+ emitting a relocation. */
+#define TC_FORCE_RELOCATION_SECTION(FIXP, SEC) 0
+
#ifdef OBJ_SOM
/* If a symbol is imported, but never used, then the symbol should
*not* end up in the symbol table. Likewise for absolute symbols