.code16gcc, i386, and loop/jcc/jmp data-size overrides
No Name
no_mayl@hotmail.com
Sat Apr 8 16:01:00 GMT 2006
Would it be ok for gas to generate extra size prefixes when compiling with
code16gcc?
Like that the produced object with 16bit code could run with an EIP >
0xffff.
It would seem that the spirit of code16gcc is to be 32bit allover anyway.
The attached patch is probably incomplete, "jcxz" should be tweaked also.
And maybe the "loop/jcxz" handling is trickier due to suffixes manipulating
addr-sizes instead of the data-sizes.
* code
.L19:
movl -8(%ebp), %eax
addl 8(%ebp), %eax
cmpb $0, (%eax)
jne .L21
!!>> jmp .L20 <<!!
.L21:
* original gnu assembler
After reloc to 0x40000, executing the jmp cause eip to be truncated to 16bit
(data size).
67 66 8b 45 f8 addr32 mov 0xfffffff8(%ebp),%eax
67 66 03 45 08 addr32 add 0x8(%ebp),%eax
67 80 38 00 addr32 cmpb $0x0,(%eax)
75 03 jne 40250 <printf+0x2f>
!!>> e9 68 01 jmp 3b8 <SEL_GDT_USER3+0x328> <<!!
67 66 8b 45 f8 addr32 mov 0xfffffff8(%ebp),%eax
67 66 03 45 08 addr32 add 0x8(%ebp),%eax
* with the attached binutils 1.16 patch
67 66 8b 45 f8 addr32 mov 0xfffffff8(%ebp),%eax
67 66 03 45 08 addr32 add 0x8(%ebp),%eax
67 80 38 00 addr32 cmpb $0x0,(%eax)
66 data32
75 06 jne 40262 <printf+0x33>
!!>> 66 e9 8a 01 00 00 jmpl 403ec <printf+0x1bd> <<!!
67 66 8b 45 f8 addr32 mov 0xfffffff8(%ebp),%eax
67 66 03 45 08 addr32 add 0x8(%ebp),%eax
--
jpa
-------------- next part --------------
A non-text attachment was scrubbed...
Name: binutils-2.16.gasPatch.forCode16gccFix.200604071624.patch
Type: text/x-diff
Size: 8276 bytes
Desc: not available
URL: <https://sourceware.org/pipermail/binutils/attachments/20060408/a14dd559/attachment.bin>
More information about the Binutils
mailing list