* linux and bfd_gas
@ 1994-09-07 1:06 Rick Sladkey
1994-09-07 9:54 ` Ian Lance Taylor
1994-09-07 16:39 ` Ken Raeburn
0 siblings, 2 replies; 3+ messages in thread
From: Rick Sladkey @ 1994-09-07 1:06 UTC (permalink / raw)
To: gas2
Recently using bfd for gas on linux was made preferred in the
configuration. This doesn't work for a.out because the relocations
for PC-relative function calls (e.g.) don't come out right.
For example:
$ cat main.s
.file "main.c"
gcc2_compiled.:
___gnu_compiled_c:
.text
.align 4
.globl _main
_main:
pushl %ebp
movl %esp,%ebp
call ___main
call _sync
L1:
movl %ebp,%esp
popl %ebp
ret
$ as-940906 main.s -o main.o # The stock 0906 gas.
$ objdump --disassemble main.o
main.o: file format a.out-i386-linux
Disassembly of section .text:
00000000 <_main> pushl %ebp
00000001 <_main+1> movl %esp,%ebp
00000003 <_main+3> call 00000004 <_main+4> # Here is the problem.
00000008 <_main+8> call 00000009 <_main+9> # Here is the problem.
0000000d <_main+d> movl %ebp,%esp
0000000f <_main+f> popl %ebp
00000010 <_main+10> ret
...
Disassembly of section .data:
$ as main.s -o main.o # My fixed version.
$ objdump --disassemble main.o
test/as/main.o.good: file format a.out-i386-linux
Disassembly of section .text:
00000000 <_main> pushl %ebp
00000001 <_main+1> movl %esp,%ebp
00000003 <_main+3> call 00000000 <_main> # Here it is correct.
00000008 <_main+8> call 00000000 <_main> # Here it is correct.
0000000d <_main+d> movl %ebp,%esp
0000000f <_main+f> popl %ebp
...
Disassembly of section .data:
$
The problem is that DISP32 relocations on i386-aout are relative to
the instruction and not to the section.
Here is a patch that fixes the problem for me but I am not positive
that it is correct for all targets.
-----
Wed Sep 7 03:59:18 1994 Rick Sladkey (jrs@world.std.com)
* write.c (write_relocs): Subtract the address from the relocation
addend for pc_relative relocations that aren't pcrel_offset.
*** gas-940906/gas/write.c-dist Fri Aug 26 17:52:45 1994
--- gas-940906/gas/write.c Wed Sep 7 03:37:49 1994
***************
*** 702,707 ****
--- 702,715 ----
/* bfd_perform_relocation screws this up */
reloc->addend += reloc->address;
}
+
+ if (reloc->howto->pcrel_offset == false
+ && reloc->howto->pc_relative == true)
+ {
+ /* Targets like i386-aout use the addend instead of pcrel_offset. */
+ reloc->addend -= reloc->address;
+ }
+
/* Pass bogus address so that when bfd_perform_relocation adds
`reloc->address' back in, it'll come up with `data', which is where
we want it to operate. We can't just do it by fudging reloc->address,
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: linux and bfd_gas
1994-09-07 1:06 linux and bfd_gas Rick Sladkey
@ 1994-09-07 9:54 ` Ian Lance Taylor
1994-09-07 16:39 ` Ken Raeburn
1 sibling, 0 replies; 3+ messages in thread
From: Ian Lance Taylor @ 1994-09-07 9:54 UTC (permalink / raw)
To: jrs; +Cc: gas2
From: jrs@world.std.com (Rick Sladkey)
Date: Wed, 7 Sep 1994 04:05:09 EDT
Recently using bfd for gas on linux was made preferred in the
configuration. This doesn't work for a.out because the relocations
for PC-relative function calls (e.g.) don't come out right.
Actually, this just broke on September 1 due to a change to make the
linux targeted gas default to defining BFD_ASSEMBLER. When
BFD_ASSEMBLER is defined, gas reloc handling is basically broken, in
that making any particular target work requires a lot of senseless
twiddling. This twiddling has not been done for the i386-aout target.
You can make it work by using the --disable-bfd-assembler argument
when you configure gas (this won't work for a cross compiler without a
patch I just made to configure, but it should work for native).
If you want to fix up the i386-aout target for BFD_ASSEMBLER, the
places to change are md_apply_fix and tc_gen_reloc in tc-i386.c. Your
proposed patch to write.c will break other a.out targets.
Ian
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: linux and bfd_gas
1994-09-07 1:06 linux and bfd_gas Rick Sladkey
1994-09-07 9:54 ` Ian Lance Taylor
@ 1994-09-07 16:39 ` Ken Raeburn
1 sibling, 0 replies; 3+ messages in thread
From: Ken Raeburn @ 1994-09-07 16:39 UTC (permalink / raw)
To: Rick Sladkey; +Cc: gas2
I will switch the linux a.out configuration back, so that it doesn't
set bfd_gas. I had done it because the non-bfd version silently
ignored "@PLT" and the like in the input file, where the bfd version
would complain about not being able to generate the relocations.
Generating correct results for correct input files is obviously more
important than warning about code the assembler shouldn't be getting
fed anyways.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~1994-09-07 16:39 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1994-09-07 1:06 linux and bfd_gas Rick Sladkey
1994-09-07 9:54 ` Ian Lance Taylor
1994-09-07 16:39 ` Ken Raeburn
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).