* Psossible problem with gas on MIPS
@ 2000-06-08 0:11 Koundinya.K
2000-06-08 1:59 ` Possible " Ulf Carlsson
2000-06-08 8:44 ` Psossible " Maciej W. Rozycki
0 siblings, 2 replies; 7+ messages in thread
From: Koundinya.K @ 2000-06-08 0:11 UTC (permalink / raw)
To: binutils
Hi,
Here is a a small test case that I could derive out of the large piece of
assembler code that assembling
$ cat li.s
..set noreorder
li $2,7
beqz $7, noerror
nop
assembling the above with the native assembler
$ /usr/bin/as -EB -KPIC li.s -o li.o
$ objdump -r li.o
li.o: file format elf32-tradbigmips
RELOCATION RECORDS FOR [.text]:
OFFSET TYPE VALUE
00000004 R_MIPS_PC16 noerror
Assembling the same using gas
$as -KPIC li.s -o li_gas.o
li.s: Assembler messages:
li.s:3: Error: Can not represent BFD_RELOC_16_PCREL_S2 relocation in this
object file format
Could this be a possible bug in gas ?. I am looking at the source too. Could
someone having access to MIPS boxes try this test case and verify ?
Thanks
koundinya
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Possible problem with gas on MIPS
2000-06-08 0:11 Psossible problem with gas on MIPS Koundinya.K
@ 2000-06-08 1:59 ` Ulf Carlsson
2000-06-08 3:06 ` Koundinya.K
2000-06-08 8:44 ` Psossible " Maciej W. Rozycki
1 sibling, 1 reply; 7+ messages in thread
From: Ulf Carlsson @ 2000-06-08 1:59 UTC (permalink / raw)
To: Koundinya.K; +Cc: binutils
> RELOCATION RECORDS FOR [.text]:
> OFFSET TYPE VALUE
> 00000004 R_MIPS_PC16 noerror
How is this supposed to work? R_MIPS_PC16 doesn't shift out the lower two
bits of the offset, so the branch instructions can not possibly use this
relocation type. However can do this with the R_MIPS_GNU_REL16_S2 relocation
which is a Cygnus extension.
> li.s: Assembler messages:
> li.s:3: Error: Can not represent BFD_RELOC_16_PCREL_S2 relocation in this
> object file format
I tried it and it goes through the assembler if you use -membedded-pic. I
have not tested it any further though.
Ulf
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Possible problem with gas on MIPS
2000-06-08 1:59 ` Possible " Ulf Carlsson
@ 2000-06-08 3:06 ` Koundinya.K
2000-06-08 3:51 ` Ulf Carlsson
0 siblings, 1 reply; 7+ messages in thread
From: Koundinya.K @ 2000-06-08 3:06 UTC (permalink / raw)
To: Ulf Carlsson; +Cc: binutils
Hi,
On the tons of assembler code I have I can see that R_MIPS_PC16 type of
relocation is used by objects modules to contain external references from
branch opcodes.
I would suspect that the shift for R_MIPS_PC16 has not been documented in
the ABI or elsewhere and has just been missed out.
Can't R_MIPS_PC16 be used for BFD_RELOC_16_PCREL_S2 relocations?
This should solve the problem which would also allow object modules to
contain external references from branch opcodes. Also there is not that much
heavy use of R_MIPS_PC16.
koundinya
-> > RELOCATION RECORDS FOR [.text]:
-> > OFFSET TYPE VALUE
-> > 00000004 R_MIPS_PC16 noerror
->
-> How is this supposed to work? R_MIPS_PC16 doesn't shift out the lower two
-> bits of the offset, so the branch instructions can not possibly use this
-> relocation type. However can do this with the R_MIPS_GNU_REL16_S2 relocation
-> which is a Cygnus extension.
->
-> > li.s: Assembler messages:
-> > li.s:3: Error: Can not represent BFD_RELOC_16_PCREL_S2 relocation in this
-> > object file format
->
-> I tried it and it goes through the assembler if you use -membedded-pic. I
-> have not tested it any further though.
->
-> Ulf
->
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Possible problem with gas on MIPS
2000-06-08 3:06 ` Koundinya.K
@ 2000-06-08 3:51 ` Ulf Carlsson
2000-06-08 4:45 ` Koundinya.K
0 siblings, 1 reply; 7+ messages in thread
From: Ulf Carlsson @ 2000-06-08 3:51 UTC (permalink / raw)
To: Koundinya.K; +Cc: binutils
> I would suspect that the shift for R_MIPS_PC16 has not been documented in
> the ABI or elsewhere and has just been missed out.
Yes, you're actually right. It has been missed out. We do shift the offsets
right by 2 when we link objects including R_MIPS_PC16 with gld. This is
however nothing we want to generate with gas. IRIX as is actually reluctant
to assemble branches to symbols as well. I think IRIX ld pukes on R_MIPS_PC16
whenever it gets the chance.
Ulf
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Possible problem with gas on MIPS
2000-06-08 3:51 ` Ulf Carlsson
@ 2000-06-08 4:45 ` Koundinya.K
2000-06-08 10:22 ` Ian Lance Taylor
0 siblings, 1 reply; 7+ messages in thread
From: Koundinya.K @ 2000-06-08 4:45 UTC (permalink / raw)
To: Ulf Carlsson; +Cc: binutils
O.K, here is a tiny patch that I applied to get my assembler stuff compiling
for the same issue.
Index: elf32-mips.c
===================================================================
RCS file: /gnu/cvsroot/binutils-000213/bfd/elf32-mips.c,v
retrieving revision 1.2
diff -u -p -b -r1.2 elf32-mips.c
--- elf32-mips.c 2000/06/08 08:23:45 1.2
+++ elf32-mips.c 2000/06/08 10:13:49
@@ -1843,6 +1843,7 @@ static CONST struct elf_reloc_map mips_r
{ BFD_RELOC_MIPS_LITERAL, R_MIPS_LITERAL },
{ BFD_RELOC_MIPS_GOT16, R_MIPS_GOT16 },
{ BFD_RELOC_16_PCREL, R_MIPS_PC16 },
+ { BFD_RELOC_16_PCREL_S2, R_MIPS_PC16 },
{ BFD_RELOC_MIPS_CALL16, R_MIPS_CALL16 },
{ BFD_RELOC_MIPS_GPREL32, R_MIPS_GPREL32 },
{ BFD_RELOC_MIPS_GOT_HI16, R_MIPS_GOT_HI16 },
koundinya
-> > I would suspect that the shift for R_MIPS_PC16 has not been documented in
-> > the ABI or elsewhere and has just been missed out.
->
-> Yes, you're actually right. It has been missed out. We do shift the offsets
-> right by 2 when we link objects including R_MIPS_PC16 with gld. This is
-> however nothing we want to generate with gas. IRIX as is actually reluctant
-> to assemble branches to symbols as well. I think IRIX ld pukes on R_MIPS_PC16
-> whenever it gets the chance.
->
-> Ulf
->
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Psossible problem with gas on MIPS
2000-06-08 0:11 Psossible problem with gas on MIPS Koundinya.K
2000-06-08 1:59 ` Possible " Ulf Carlsson
@ 2000-06-08 8:44 ` Maciej W. Rozycki
1 sibling, 0 replies; 7+ messages in thread
From: Maciej W. Rozycki @ 2000-06-08 8:44 UTC (permalink / raw)
To: Koundinya.K; +Cc: binutils
On Thu, 8 Jun 2000, Koundinya.K wrote:
> li.s: Assembler messages:
> li.s:3: Error: Can not represent BFD_RELOC_16_PCREL_S2 relocation in this
> object file format
>
> Could this be a possible bug in gas ?. I am looking at the source too. Could
> someone having access to MIPS boxes try this test case and verify ?
I recall myself discussing this issue here back in October. The
conclusion was that due to a limited range and thus a questionable
usefulness relocations for branches are not defined by the MIPS ELF ABI.
I prepared a patch to map BFD_RELOC_16_PCREL_S2 to R_MIPS_PC16 then but it
got rejected as not being ABI-compliant.
A R_MIPS_PC16 relocation that the vendor-supplied as generates in not
appropriate for branches. That's beacuse R_MIPS_PC16 is defined as a
simple difference between two addresses in the ABI while for branches you
need a shifted left by two difference.
--
+ Maciej W. Rozycki, Technical University of Gdansk, Poland +
+--------------------------------------------------------------+
+ e-mail: macro@ds2.pg.gda.pl, PGP key available +
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Possible problem with gas on MIPS
2000-06-08 4:45 ` Koundinya.K
@ 2000-06-08 10:22 ` Ian Lance Taylor
0 siblings, 0 replies; 7+ messages in thread
From: Ian Lance Taylor @ 2000-06-08 10:22 UTC (permalink / raw)
To: kk; +Cc: ulfc, binutils
Date: Thu, 08 Jun 2000 17:21:14 +0530
From: "Koundinya.K" <kk@ddeorg.soft.net>
O.K, here is a tiny patch that I applied to get my assembler stuff compiling
for the same issue.
Index: elf32-mips.c
===================================================================
RCS file: /gnu/cvsroot/binutils-000213/bfd/elf32-mips.c,v
retrieving revision 1.2
diff -u -p -b -r1.2 elf32-mips.c
--- elf32-mips.c 2000/06/08 08:23:45 1.2
+++ elf32-mips.c 2000/06/08 10:13:49
@@ -1843,6 +1843,7 @@ static CONST struct elf_reloc_map mips_r
{ BFD_RELOC_MIPS_LITERAL, R_MIPS_LITERAL },
{ BFD_RELOC_MIPS_GOT16, R_MIPS_GOT16 },
{ BFD_RELOC_16_PCREL, R_MIPS_PC16 },
+ { BFD_RELOC_16_PCREL_S2, R_MIPS_PC16 },
{ BFD_RELOC_MIPS_CALL16, R_MIPS_CALL16 },
{ BFD_RELOC_MIPS_GPREL32, R_MIPS_GPREL32 },
{ BFD_RELOC_MIPS_GOT_HI16, R_MIPS_GOT_HI16 },
Well, this patch can't be right. Either BFD_RELOC_16_PCREL or
BFD_RELOC_16_PCREL_S2 can be translated to R_MIPS_PC16, but not both.
The two BFD relocations are significantly different; we can't possibly
translate them to the same R_MIPS relocation.
Which one is correct depends upon the definition of R_MIPS_PC16.
Ian
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2000-06-08 10:22 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2000-06-08 0:11 Psossible problem with gas on MIPS Koundinya.K
2000-06-08 1:59 ` Possible " Ulf Carlsson
2000-06-08 3:06 ` Koundinya.K
2000-06-08 3:51 ` Ulf Carlsson
2000-06-08 4:45 ` Koundinya.K
2000-06-08 10:22 ` Ian Lance Taylor
2000-06-08 8:44 ` Psossible " Maciej W. Rozycki
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).