This is the mail archive of the binutils@sources.redhat.com mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: gas/ld x86 16-bit 64kb limit and ominous "unreal mode"


>   Hello Josef,
Hello Etienne

>   Even with -Os, which is a GCC option so has no influence on GAS, the
>  only 16 bits relocs in Gujin are in the assembler inserts: asm("...").
>  At some point, I wanted to remove all the 16 bits relocs to
>  be able to do a link even if the executable was non-useable
>  (>65536 offsets) to know the size of sections .code, .xcode ...

For my code it has an influence, maybe i will further study your code...

00000131 <bios_15_xxxx>:
131:   66 53                   push   %ebx
...
145:   e9 fe ff                jmp    146 <bios_15_xxxx+0x15>
		       146: R_386_PC16 bios_15_24xx

> > Yes, i think i'll try that, because the bios-code shall be extendable to
> > 500kb, best 1MB. Because the code shall be compilable without somehow
> > patched ld/gas i will try to do ld all the address relocation stuff, and
> > write a post-linker-tool, which patches the call to far calls and the
> > 32-bit addresses to segment:off ones. Hopefully the code/data references
> > can all be replaced accordingly.
>   You can't reliably find the beginning of assembly instructions in a
>  binary executable, to search for call's and ret's. You have to patch

I don't intend to patch the call's and ret's of the binary file, but use
partial linking to get an ELF object file, with all undefined funcs
resolved, and an relocation table, pointing me to all call's to be
patched.

>  a function cannot cross a segment boundary, i.e. be bigger than 64 Kbytes.
>   You will also need a GCC or GAS patch to end functions by "retl/retl n".

I am thinking about solving that by letting gcc first output gas-asm
code, using perl to patch all 'ret' to 'far ret', and then assembler
it. 

>   This system cannot be applied to data because the 80x86 does not have
>  a "load far address into register" assembler instruction, you have to
>  load first the segment, then use this segment in the "load to register"
>  assembly instruction. Please use segment %fs for that, i.e. the convention
>  that %ds = %es = %ss at all times, %gs preserved by function call, %fs
>  temporary and not preserved by function call.

Wow, i am happy to have found someone whos knows what i am talking about
;-). YES, thats also a problem. Therefore i intend to use for every data
access a special function written in assembler, which takes the linear
address, and uses %fs:offset to get/write the value.

>  please note that this is complex stuff you are looking at, not a two
>  weeks project...
I have 6 weeks to get this done!

greets
josef



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]