From: Richard Sandiford <rdsandiford@googlemail.com>
To: "Maciej W. Rozycki" <macro@codesourcery.com>
Cc: Joel Brobecker <brobecker@adacore.com>,
Catherine Moore <clm@codesourcery.com>,
<binutils@sourceware.org>, <gdb-patches@sourceware.org>
Subject: Re: [PATCH 1/2] MIPS: Compressed PLT/stubs support
Date: Sat, 08 Jun 2013 16:04:00 -0000 [thread overview]
Message-ID: <8761xo981a.fsf@talisman.default> (raw)
In-Reply-To: <alpine.DEB.1.10.1306071534070.16287@tp.orcam.me.uk> (Maciej W. Rozycki's message of "Fri, 7 Jun 2013 22:09:24 +0100")
"Maciej W. Rozycki" <macro@codesourcery.com> writes:
>> Maybe something like:
>>
>> /* If compressed PLT entries are available, make sure that we use them
>> for MIPS16 and microMIPS calls. */
>> else if ((r_type == R_MIPS16_26 || r_type == R_MICROMIPS_26_S1)
>> && h != NULL
>> && h->use_plt
>> && h->root.plt.plist->comp_offset != MINUS_ONE)
>> {
>> sec = htab->splt;
>> symbol = (sec->output_section->vma
>> + sec->output_offset
>> + htab->plt_header_size
>> + htab->plt_mips_offset
>> + h->root.plt.plist->comp_offset
>> + 1);
>> target_is_16_bit_code_p = !MICROMIPS_P (abfd);
>> target_is_micromips_code_p = MICROMIPS_P (abfd);
>> }
>>
>> at the end of the:
>>
>> /* If this is a reference to a 16-bit function with a stub, we need
>> to redirect the relocation to the stub unless:
>>
>> chain of ifs.
>
> More or less, though I've decided to push it ahead of the chain so that
> it sees the state consistent regardless of whether any PLT entry processed
> has been duplicated for dual-mode support. This probably does not really
> matter right now (fn_stub/need_fn_stub cases will override any symbol
> value to use for the relocation and likewise the mode setting anyway,
> call_stub/call_fp_stub cases will only ever have a standard MIPS PLT entry
> due to the arrangement in _bfd_mips_elf_adjust_dynamic_symbol and
> la25_stub cases will never have a PLT entry as these must resolve
> locally), but I feel a bit uneasy about this half-cooked state. Let me
> know if you disagree (and why).
The changes made by the block beginning:
/* If this is a reference to a 16-bit function with a stub, we need
to redirect the relocation to the stub unless:
are mutually-exclusive with each other and with the new PLT transformation.
We should only ever perform one. And the transformation:
/* If this is a MIPS16 call with a stub, that is made through the PLT or
to a standard MIPS function, we need to redirect the call to the stub.
Note that we specifically exclude R_MIPS16_CALL16 from this behavior;
indirect calls should use an indirect stub instead. */
else if (r_type == R_MIPS16_26 && !info->relocatable
&& ((h != NULL && (h->call_stub != NULL || h->call_fp_stub != NULL))
|| (local_p
&& mips_elf_tdata (input_bfd)->local_call_stubs != NULL
&& mips_elf_tdata (input_bfd)->local_call_stubs[r_symndx] != NULL))
&& ((h != NULL && h->use_plt_entry) || !target_is_16_bit_code_p))
logically trumps the PLT one.
That's why I think all four transformations should be in a single if chain,
and why the PLT one should come last.
You said yourself about the addition of (h != NULL && h->use_plt_entry):
The current code flow is a bit subtle, this piece works because as a side
effect of the PLT being standard MIPS code the call is qualified as a
cross-mode jump. However this is not really the reason the call needs to
be redirected for -- the redirection would have to be done regardless
even if we did decide to emit the PLT entry as MIPS16 code for some
reason.
That is, if we (redundantly) created both standard and MIPS16 PLT
entries for functions with stubs, and if the "if" statement as you had
it redirected the call from a standard PLT entry to a MIPS16 PLT entry,
this code must explicitly ignore that transformation. So why do it?
Making a point of doing it ahead of the if-else block, only to explicitly
ignore it in the if-else block, just makes the code more confusing IMO.
Richard
next prev parent reply other threads:[~2013-06-08 11:06 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-02-19 20:44 Maciej W. Rozycki
2013-02-19 20:45 ` [PATCH 2/2] MIPS: Compressed PLT/stubs support test cases Maciej W. Rozycki
2013-02-20 21:53 ` [PATCH 1/2] MIPS: Compressed PLT/stubs support Richard Sandiford
2013-03-09 4:04 ` Maciej W. Rozycki
2013-03-09 9:58 ` Richard Sandiford
2013-06-08 0:22 ` Maciej W. Rozycki
2013-06-08 16:04 ` Richard Sandiford [this message]
2013-06-10 17:13 ` Maciej W. Rozycki
2013-06-10 18:08 ` Richard Sandiford
2013-06-10 19:34 ` Maciej W. Rozycki
2013-06-25 0:40 ` Maciej W. Rozycki
2013-03-11 13:53 ` Joel Brobecker
2013-06-26 15:02 ` Maciej W. Rozycki
2013-02-21 21:06 ` Tom Tromey
2013-02-22 0:58 ` Alan Modra
2013-02-22 6:06 ` Alan Modra
2013-02-22 20:09 ` Tom Tromey
2013-03-09 4:06 ` Maciej W. Rozycki
2013-06-20 16:20 ` [PING^2][PATCH] in_plt_section: support alternate stub section names (was: [PATCH 1/2] MIPS: Compressed PLT/stubs support) Maciej W. Rozycki
2013-06-20 16:50 ` [PING^2][PATCH] in_plt_section: support alternate stub section names Pedro Alves
2013-06-21 11:43 ` Maciej W. Rozycki
2013-06-21 15:34 ` Pedro Alves
2013-06-22 2:24 ` Maciej W. Rozycki
2013-06-24 12:40 ` Pedro Alves
2013-06-24 23:34 ` Maciej W. Rozycki
2013-06-25 9:57 ` Pedro Alves
2013-06-07 13:25 ` [PATCH] in_plt_section: support alternate stub section names (was: [PATCH 1/2] MIPS: Compressed PLT/stubs support) Maciej W. Rozycki
2013-06-13 12:43 ` [PING][PATCH] " Maciej W. Rozycki
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=8761xo981a.fsf@talisman.default \
--to=rdsandiford@googlemail.com \
--cc=binutils@sourceware.org \
--cc=brobecker@adacore.com \
--cc=clm@codesourcery.com \
--cc=gdb-patches@sourceware.org \
--cc=macro@codesourcery.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox