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:
> > > 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
>
> No, the size is the same or less:
> sizeof (CALL far imm16:imm16) <= sizeof (CALL near imm32)
>
> again: gas generates 16-bit code when the ".code16gcc" pseudo-opcode is
> used by just using the 0x66-prefix. So the by gcc used near-calls with 32-bit
> offsets (and prefix) should offer enough space for a far-call with
> 16-bit offset. Correct me if i am wrong.
I have no idea whether you are right or wrong. But that sounds
simpler. You will just need a magic relocation which can turn the
whole call sequence into what you need.
Ian