This is the mail archive of the
binutils@sources.redhat.com
mailing list for the binutils project.
Re: [PATCH/RFA] sh-elf: Unnecessary relocations
Hans-Peter Nilsson <hp@bitrange.com> wrote:
> On Fri, 27 Sep 2002, kaz Kojima wrote:
>> Hans-Peter Nilsson <hp@bitrange.com> wrote:
>>> I think the point is that those relocations are for
>>> *immediately* nearby addresses; they can't reach more than
>>> something like 1 << 8 or 1 << 12 bytes. It'd be a gcc bug to
>>> generate them for global symbols that can be overridden. I
>>> think the patch should be corrected to check for R_SH_DIR8WPL
>>> and R_SH_IND12W (or really, the BFD names) since there
>>> supposedly exists other PC-relative relocations that should be
>>> generated for global symbols in the same object. That includes
>>> the 32-bit pcrel reloc (whatever the SH ELF name; I think the
>>> BFD name is BFD_RELOC_32_PCREL). Right?
>>
>> Ah, yes. My patch might be overkill. It seems that the old
>> tc-sh.c handles the following 6 relocations as such relocations:
>>
>> BFD_RELOC_SH_PCDISP12BY2
>> BFD_RELOC_SH_PCRELIMM8BY2
>> BFD_RELOC_SH_PCRELIMM8BY4
>> BFD_RELOC_8_PCREL
>> BFD_RELOC_SH_SWITCH16
>> BFD_RELOC_SH_SWITCH32
>>
>> I'll make a revised patch with checking these relocations.
>
> Thanks. I'm unsure whether you refer to relocations that should
> or should not make it to the output. Anyway, the 32-bit one
> should be an output-relocation. I dunno about the others,
> though they don't look like they should be in an -fpic object.
> Either way, if ld.so can handle them (or whatever they turn into
> in a DSO) in a DT_TEXTREL (sp?) DSO, they should make it to the
> output.
Yes, ld.so can't handle them.
Here is a revised patch. I've missed one more such relocation
BFD_RELOC_SH_PCDISP8BY2. Regression tested on sh-unknown-linux-gnu.
Thanks,
kaz
--
2002-09-27 Kaz Kojima <kkojima@rr.iij4u.or.jp>
* config/tc-sh.c (sh_force_relocation): Return 0 for
some PC relative relocations when not relaxing.
--- ORIG/src/gas/config/tc-sh.c Sun Sep 15 07:09:09 2002
+++ TMP/src/gas/config/tc-sh.c Fri Sep 27 08:46:24 2002
@@ -3219,6 +3219,16 @@ int
sh_force_relocation (fix)
fixS *fix;
{
+ if (! sh_relax
+ && (fix->fx_r_type == BFD_RELOC_SH_PCDISP8BY2
+ || fix->fx_r_type == BFD_RELOC_SH_PCDISP12BY2
+ || fix->fx_r_type == BFD_RELOC_SH_PCRELIMM8BY2
+ || fix->fx_r_type == BFD_RELOC_SH_PCRELIMM8BY4
+ || fix->fx_r_type == BFD_RELOC_8_PCREL
+ || fix->fx_r_type == BFD_RELOC_SH_SWITCH16
+ || fix->fx_r_type == BFD_RELOC_SH_SWITCH32))
+ return 0;
+
if (fix->fx_r_type == BFD_RELOC_VTABLE_INHERIT
|| fix->fx_r_type == BFD_RELOC_VTABLE_ENTRY
|| fix->fx_r_type == BFD_RELOC_SH_LOOP_START