From: "Alexander Voropay" <alec@artcoms.ru>
To: "Kishore K" <hellokishore@gmail.com>
Cc: <linux-mips@linux-mips.org>
Subject: Re: bal instruction in gcc 3.x
Date: Wed, 20 Jul 2005 16:39:31 +0400 [thread overview]
Message-ID: <010901c58d28$15e2a3b0$6cf9a8c0@ALEC> (raw)
In-Reply-To: f07e6e05072002197b529b72@mail.gmail.com
<hellokishore@gmail.com> wrote:
>>> However, if I compile the code with gcc3, it exits with the
>>>error "Cannot branch to unknown symbol".
> On the other hand, if I replace
>
> bal jump_to_label
>
> by
>
> la t9, jump_to_label
> jalr t9
>
> I don't see any warning. What could be the reason ?
1) With "jal label " you'll have a MIPS_26 RELOC type in the ELF obj file:
jal lablel
00000000 <.text>:
0: 0c000000 jal 0x0
4: 00000000 nop
RELOCATION RECORDS FOR [.text]:
OFFSET TYPE VALUE
00000000 R_MIPS_26 label
2) The "la r,label" is a syntetic inctruction wich expanded into two:
"lui r,%hi label ; addui r,%lo label". It gives you two RELOCs:
la t0, label
jalr t0
00000000 <.text>:
0: 3c080000 lui t0,0x0
4: 25080000 addiu t0,t0,0
8: 0100f809 jalr t0
c: 00000000 nop
RELOCATION RECORDS FOR [.text]:
OFFSET TYPE VALUE
00000000 R_MIPS_HI16 label
00000004 R_MIPS_LO16 label
3) AFAIK (correct me), there is no MIPS-specific RELOC type for
the "branch" instruction format in the BFD, so "bal" to the *external*
symbols is impossible.
May be, old gas generates something like RELOC_PCREL
for "bal external" ?
--
-=AV=-
WARNING: multiple messages have this Message-ID (diff)
From: "Alexander Voropay" <alec@artcoms.ru>
To: Kishore K <hellokishore@gmail.com>
Cc: linux-mips@linux-mips.org
Subject: Re: bal instruction in gcc 3.x
Date: Wed, 20 Jul 2005 16:39:31 +0400 [thread overview]
Message-ID: <010901c58d28$15e2a3b0$6cf9a8c0@ALEC> (raw)
Message-ID: <20050720123931.WK5-QGAisTiWZK7xF7lETlD0z1YUgeEQIAhZeuogeOU@z> (raw)
In-Reply-To: f07e6e05072002197b529b72@mail.gmail.com
<hellokishore@gmail.com> wrote:
>>> However, if I compile the code with gcc3, it exits with the
>>>error "Cannot branch to unknown symbol".
> On the other hand, if I replace
>
> bal jump_to_label
>
> by
>
> la t9, jump_to_label
> jalr t9
>
> I don't see any warning. What could be the reason ?
1) With "jal label " you'll have a MIPS_26 RELOC type in the ELF obj file:
jal lablel
00000000 <.text>:
0: 0c000000 jal 0x0
4: 00000000 nop
RELOCATION RECORDS FOR [.text]:
OFFSET TYPE VALUE
00000000 R_MIPS_26 label
2) The "la r,label" is a syntetic inctruction wich expanded into two:
"lui r,%hi label ; addui r,%lo label". It gives you two RELOCs:
la t0, label
jalr t0
00000000 <.text>:
0: 3c080000 lui t0,0x0
4: 25080000 addiu t0,t0,0
8: 0100f809 jalr t0
c: 00000000 nop
RELOCATION RECORDS FOR [.text]:
OFFSET TYPE VALUE
00000000 R_MIPS_HI16 label
00000004 R_MIPS_LO16 label
3) AFAIK (correct me), there is no MIPS-specific RELOC type for
the "branch" instruction format in the BFD, so "bal" to the *external*
symbols is impossible.
May be, old gas generates something like RELOC_PCREL
for "bal external" ?
--
-=AV=-
next prev parent reply other threads:[~2005-07-20 12:38 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-07-19 16:30 bal instruction in gcc 3.x Kishore K
2005-07-19 16:44 ` Ralf Baechle
2005-07-19 17:19 ` Kishore K
2005-07-19 19:53 ` Pete Popov
2005-07-20 8:59 ` Maciej W. Rozycki
2005-07-20 9:17 ` Thiemo Seufer
2005-07-20 9:47 ` Maciej W. Rozycki
2005-07-20 9:19 ` Kishore K
2005-07-20 9:52 ` Maciej W. Rozycki
2005-07-20 12:39 ` Alexander Voropay [this message]
2005-07-20 12:39 ` Alexander Voropay
2005-07-20 12:54 ` Maciej W. Rozycki
2005-07-20 13:24 ` Alexander Voropay
2005-07-20 13:24 ` Alexander Voropay
2005-07-20 13:25 ` Thiemo Seufer
2005-07-20 12:54 ` Thiemo Seufer
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='010901c58d28$15e2a3b0$6cf9a8c0@ALEC' \
--to=alec@artcoms.ru \
--cc=hellokishore@gmail.com \
--cc=linux-mips@linux-mips.org \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.