From: "Maciej W. Rozycki" <macro@mips.com>
To: Daniel Jacobowitz <drow@false.org>, Thiemo Seufer <ths@mips.com>
Cc: gdb-patches@sourceware.org, "Maciej W. Rozycki" <macro@linux-mips.org>
Subject: Re: MIPS: Handle manual calls of MIPS16 functions with a call stub
Date: Fri, 01 Feb 2008 15:34:00 -0000 [thread overview]
Message-ID: <Pine.LNX.4.61.0802011446300.14889@perivale.mips.com> (raw)
In-Reply-To: <20080201141838.GB28371@caradoc.them.org>
On Fri, 1 Feb 2008, Daniel Jacobowitz wrote:
> > The other way round -- the minimal symbol points to the actual entry
> > point, but the stub precedes it and is included in the DWARF-2 block
> > together with the MIPS16 function body. Here's an example that triggers a
> > failure in the test suite (generated from gdb.base/call-ar-st.c by GCC
> > 4.2.2):
>
> Then why aren't we calling the instruction at the start of the block,
> i.e. the stub? In which case not using the MIPS16 convention is
> correct. I don't see why you'd want to call
> __fn_stub_print_ten_doubles as a MIPS16 function.
Well, GDB does not ever seem to call the stub. I have not written code
responsible for this, but I can see two possible reasons:
1. Simplicity -- depending on the callers of the function in question
there may be no stub. If there are no standard MIPS callers, then the
stub is stripped out by the linker.
2. Performance -- the stub is a couple of additional instructions to
execute which buy you nothing when called from GDB as it may load the
correct argument registers according to the ABI in the first place.
And as I wrote the block associated with print_ten_doubles() does not span
__fn_stub_print_ten_doubles() -- I may have not been clear enough about
this being the case for the DWARF-2 record.
This is what GDB has to say about the function (with the fix applied):
(gdb) print print_ten_doubles
$1 = {void (double, double, double, double, double, double, double, double,
double, double)} 0x80020a91 <print_ten_doubles>
(gdb) print __fn_stub_print_ten_doubles
$2 = {<text variable, no debug info>} 0x800283d0 <__fn_stub_print_ten_doubles>
And this is what the relevant DWARF-2 record holds:
<1><de6>: Abbrev Number: 16 (DW_TAG_subprogram)
<de7> DW_AT_external : 1
<de8> DW_AT_name : print_ten_doubles
<dfa> DW_AT_decl_file : 1
<dfb> DW_AT_decl_line : 664
<dfd> DW_AT_low_pc : 0x80020a90
<e01> DW_AT_high_pc : 0x80020b00
<e05> DW_AT_frame_base : 0x306 (location list)
<e09> DW_AT_sibling : <e9d>
I have done a little more research of this matter now and it looks like
the reason this is happening is a likely bug somewhere in GAS. For
comparison, here are the unrelocated DWARF-2 records for
print_ten_doubles() and a nearby function that has no stub:
<1><bab>: Abbrev Number: 16 (DW_TAG_subprogram)
<bac> DW_AT_external : 1
<bad> DW_AT_name : init_small_structs
<bc0> DW_AT_decl_file : 1
<bc1> DW_AT_decl_line : 613
<bc3> DW_AT_low_pc : 0x790
<bc7> DW_AT_high_pc : 0x900
<bcb> DW_AT_frame_base : 0x2db (location list)
<bcf> DW_AT_sibling : <0xcaf>
<1><caf>: Abbrev Number: 16 (DW_TAG_subprogram)
<cb0> DW_AT_external : 1
<cb1> DW_AT_name : print_ten_doubles
<cc3> DW_AT_decl_file : 1
<cc4> DW_AT_decl_line : 664
<cc6> DW_AT_low_pc : 0x900
<cca> DW_AT_high_pc : 0x97c
<cce> DW_AT_frame_base : 0x306 (location list)
<cd2> DW_AT_sibling : <0xd66>
And here are the relevant relocation records:
00000bc3 00003c02 R_MIPS_32 00000790 .LFB23
00000bc7 00000202 R_MIPS_32 00000000 .text
00000cc6 00000202 R_MIPS_32 00000000 .text
00000cca 00000202 R_MIPS_32 00000000 .text
Notice that the DWARF-2 record at 0xbc3 is relocated against .LFB23 and
one at 0xcc6 -- against .text, rather than .LFB20 as it should be. I
presume this is because of the section switch happening inbetween. Or
could it be because of ".set nomips16" actually preceding the section
switch? Thiemo, can you perhaps make any comments about this?
I do not know how long this bug has been there in GAS, but it may still
be worth handling broken binaries people may have. Then again -- maybe
not. But we have no fix for GAS as yet. Regardless I have not made a
strong opinion either way.
Maciej
next prev parent reply other threads:[~2008-02-01 15:34 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-01-31 18:14 Maciej W. Rozycki
2008-01-31 22:08 ` Daniel Jacobowitz
2008-02-01 10:27 ` Maciej W. Rozycki
2008-02-01 14:19 ` Daniel Jacobowitz
2008-02-01 15:34 ` Maciej W. Rozycki [this message]
2008-02-01 16:58 ` Daniel Jacobowitz
2008-02-01 17:07 ` Maciej W. Rozycki
2008-02-01 17:15 ` Daniel Jacobowitz
2008-02-04 16:14 ` Maciej W. Rozycki
2008-02-04 16:39 ` Daniel Jacobowitz
2008-02-08 14:23 ` Maciej W. Rozycki
2008-02-08 14:57 ` Daniel Jacobowitz
2008-02-08 18:06 ` Jim Blandy
2008-02-08 18:08 ` Jim Blandy
2008-02-13 18:28 ` Maciej W. Rozycki
2008-02-13 20:54 ` Jim Blandy
2008-02-15 11:36 ` Maciej W. Rozycki
2008-02-18 13:32 ` Nigel Stephens
2008-02-18 16:28 ` Maciej W. Rozycki
2008-02-19 19:48 ` Michael Snyder
2008-02-22 16:38 ` Jim Blandy
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=Pine.LNX.4.61.0802011446300.14889@perivale.mips.com \
--to=macro@mips.com \
--cc=drow@false.org \
--cc=gdb-patches@sourceware.org \
--cc=macro@linux-mips.org \
--cc=ths@mips.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