This is the mail archive of the
binutils@sources.redhat.com
mailing list for the binutils project.
Re: about writing a ld-extension to support linking 16-bit-gas code
Josef Angermeier <sijoange@cip.informatik.uni-erlangen.de> writes:
> Hello again
>
> First, thanks for replying :-)
> > I recommend investigating the existing i386 relocation types first;
> > they might already exist. Adding new ones is the hard part. If they
> > exist, supporting them better is pretty easy.
>
> I don't know if we are talking about the same thing. My problem is, that
> ld does just relocation in a 64kb address space (see example below,
> "16-bit"-gas produced R_386_PC16 relocation type, meaning just a 16-bit
> offset is relocated), but i need a linker to patch at the relocation
> entry not only the 16-bit offset BUT patch the opcode from "call/jmp
> near 32-bit offset" to "call/jmp FAR 16-bit seg + 16-bit offset" and put
> the according segment and offset (both 16-bit) behind.
>
> short: gas doesn't support 16-bit segment/offset relocation type, so
> theres R_386_PC16, and i would like to override this relocation type
> handling by inserting a opcode+seg+off fixup.
That sounds like you need the linker to change the instructions to
instructions of a different size. That is possible but quite
complex. An example of code which does it can be found in
sh_relax_section in bfd/coff-sh.c.
Ian