This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Re: [PATCH] MIPS: microMIPS ASE support
- From: "Joseph S. Myers" <joseph at codesourcery dot com>
- To: "Maciej W. Rozycki" <macro at codesourcery dot com>
- Cc: Richard Sandiford <rdsandiford at googlemail dot com>, Ilie Garbacea <ilie at mips dot com>, binutils at sourceware dot org, Chao-ying Fu <fu at mips dot com>, Rich Fuhler <rich at mips dot com>, David Lau <davidlau at mips dot com>, Kevin Mills <kevinm at mips dot com>, Catherine Moore <clm at codesourcery dot com>, Nathan Sidwell <nathan at codesourcery dot com>, Nathan Froyd <froydnj at codesourcery dot com>
- Date: Tue, 14 Dec 2010 17:05:01 +0000 (UTC)
- Subject: Re: [PATCH] MIPS: microMIPS ASE support
- References: <alpine.DEB.1.10.1005181806590.4023@tp.orcam.me.uk> <87y6fa9u3t.fsf@firetop.home> <alpine.DEB.1.10.1007112325020.2824@tp.orcam.me.uk> <876302kqvu.fsf@firetop.home> <alpine.DEB.1.10.1012061924490.5345@tp.orcam.me.uk> <871v5n9m7e.fsf@firetop.home> <alpine.DEB.1.10.1012131400320.4142@tp.orcam.me.uk>
On Tue, 14 Dec 2010, Maciej W. Rozycki wrote:
> > > /* Calls from 16-bit code to 32-bit code and vice versa require the
> > > - mode change. */
> > > - *cross_mode_jump_p = !info->relocatable
> > > - && ((r_type == R_MIPS16_26 && !target_is_16_bit_code_p)
> > > - || ((r_type == R_MIPS_26 || r_type == R_MIPS_JALR)
> > > - && target_is_16_bit_code_p));
> > > + mode change. This is not required for calls to undefined weak
> > > + symbols, which should never be executed at runtime. */
> >
> > But why do we need to go out of our way to check for them? I'm sure
> > there's a good reason, but the comment doesn't give much clue what it is.
>
> Undefined weak symbols are, well, undefined, so they have resolved to nil
> and are meant never to be jumped to, so we don't want to error out on them
> just because they do not have the ISA bit set and a JALX therefore
> required could not be used for some reason, like the invocation being a
> sibling call or because it would not satisfy the fixed delay slot
> dependency.
>
> So we decide never to make a cross-mode jump in this situation and leave
> the original jump instruction (i.e. JAL, JALS or JR) in place. If the
> instruction is indeed reached, then 1 will be written to the PC rather
> than 0 that would "canonically" be required here, but the outcome will be
> the same (assuming the zeroth page is unmapped), i.e. a segfault will
> happen.
>
> Joseph, I reckon you were involved with this piece -- did I get all the
> context right here?
Yes. A call to an undefined weak function is equally valid at compile and
link time and invalid at execution time if executed whether or not the
code is compiled in such a way as to support cross-mode jumps. Such a
call is a call to an undefined function, never a call to an other-mode
function, and so the linker should never give errors for cases such as
JALS where it cannot convert to a cross-mode jump. The original observed
problem case was statically linking sln with a call to
__nptl_deallocate_tsd that never gets executed in single-threaded
programs.
--
Joseph S. Myers
joseph@codesourcery.com