binutils 20040312-1 : problem linking 16bit x86 code with ld
Brice VIDDEAU
brice.videau@free.fr
Mon May 17 23:33:00 GMT 2004
when I link 16bit code with ld, strangely enough linking is not doing
correctly : some symbols are off by two byte when I make a call.
here is an example : one coded with .code16, the other without.
Tested on a debian it works fine.
first one : working, 32bit mode (ld script is home made), putc (home
made too) is linked correctly. results obtained with objdump.
(sorry it is quite long...)
test2.exe: file format pei-i386
Disassembly of section .text:
00007c00 <end>:
7c00: 66 31 c0 xor %ax,%ax
7c03: 8e d0 mov %eax,%ss
7c05: 66 8b 25 00 7c 00 00 mov 0x7c00,%sp
7c0c: 66 89 e6 mov %sp,%si
7c0f: 66 50 push %ax
7c11: 07 pop %es
7c12: 66 50 push %ax
7c14: 1f pop %ds
7c15: 6a 46 push $0x46
7c17: e8 54 00 00 00 call 7c70 <putc>
7c1c: 66 83 c4 02 add $0x2,%sp
7c20: 6a 6c push $0x6c
7c22: e8 49 00 00 00 call 7c70 <putc>
7c27: 66 83 c4 02 add $0x2,%sp
7c2b: 6a 72 push $0x72
7c2d: e8 3e 00 00 00 call 7c70 <putc>
7c32: 66 83 c4 02 add $0x2,%sp
7c36: 6a 65 push $0x65
7c38: e8 33 00 00 00 call 7c70 <putc>
7c3d: 66 83 c4 02 add $0x2,%sp
7c41: 6a 6e push $0x6e
7c43: e8 28 00 00 00 call 7c70 <putc>
7c48: 66 83 c4 02 add $0x2,%sp
7c4c: 6a 63 push $0x63
7c4e: e8 1d 00 00 00 call 7c70 <putc>
7c53: 66 83 c4 02 add $0x2,%sp
7c57: 6a 65 push $0x65
7c59: e8 12 00 00 00 call 7c70 <putc>
7c5e: 66 83 c4 02 add $0x2,%sp
00007c62 <_loop>:
7c62: eb fe jmp 7c62 <_loop>
7c64: 90 nop
7c65: 90 nop
7c66: 90 nop
7c67: 90 nop
7c68: 90 nop
7c69: 90 nop
7c6a: 90 nop
7c6b: 90 nop
7c6c: 90 nop
7c6d: 90 nop
7c6e: 90 nop
7c6f: 90 nop
00007c70 <putc>:
7c70: 66 55 push %bp
7c72: 66 89 e5 mov %sp,%bp
7c75: 66 83 ec 02 sub $0x2,%sp
7c79: 66 50 push %ax
7c7b: 66 53 push %bx
7c7d: 66 56 push %si
7c7f: 8a 45 08 mov 0x8(%ebp),%al
7c82: b4 0e mov $0xe,%ah
7c84: 66 bb 07 00 mov $0x7,%bx
7c88: cd 10 int $0x10
7c8a: 66 5e pop %si
7c8c: 66 5b pop %bx
7c8e: 66 58 pop %ax
7c90: c9 leave
7c91: c3 ret
7c92: 90 nop
7c93: 90 nop
second one same program but in 16bit mode :
notice the _loop+8 instead of the putc : linkage is off two bytes 7c4e
instead of 7c50
test2.exe: file format pei-i386
Disassembly of section .text:
00007c00 <end>:
7c00: 31 c0 xor %ax,%ax
7c02: 8e d0 mov %ax,%ss
7c04: 8b 26 00 7c mov 31744,%sp
7c08: 89 e6 mov %sp,%si
7c0a: 50 push %ax
7c0b: 07 pop %es
7c0c: 50 push %ax
7c0d: 1f pop %ds
7c0e: 6a 46 push $0x46
7c10: e8 3b 00 call 7c4e <_loop+0x8>
7c13: 83 c4 02 add $0x2,%sp
7c16: 6a 6c push $0x6c
7c18: e8 33 00 call 7c4e <_loop+0x8>
7c1b: 83 c4 02 add $0x2,%sp
7c1e: 6a 72 push $0x72
7c20: e8 2b 00 call 7c4e <_loop+0x8>
7c23: 83 c4 02 add $0x2,%sp
7c26: 6a 65 push $0x65
7c28: e8 23 00 call 7c4e <_loop+0x8>
7c2b: 83 c4 02 add $0x2,%sp
7c2e: 6a 6e push $0x6e
7c30: e8 1b 00 call 7c4e <_loop+0x8>
7c33: 83 c4 02 add $0x2,%sp
7c36: 6a 63 push $0x63
7c38: e8 13 00 call 7c4e <_loop+0x8>
7c3b: 83 c4 02 add $0x2,%sp
7c3e: 6a 65 push $0x65
7c40: e8 0b 00 call 7c4e <_loop+0x8>
7c43: 83 c4 02 add $0x2,%sp
00007c46 <_loop>:
7c46: eb fe jmp 7c46 <_loop>
7c48: 90 nop
7c49: 90 nop
7c4a: 90 nop
7c4b: 90 nop
7c4c: 90 nop
7c4d: 90 nop
7c4e: 90 nop
7c4f: 90 nop
00007c50 <putc>:
7c50: 55 push %bp
7c51: 89 e5 mov %sp,%bp
7c53: 83 ec 02 sub $0x2,%sp
7c56: 50 push %ax
7c57: 53 push %bx
7c58: 56 push %si
7c59: 8a 46 04 mov 4(%bp),%al
7c5c: b4 0e mov $0xe,%ah
7c5e: bb 07 00 mov $0x7,%bx
7c61: cd 10 int $0x10
7c63: 5e pop %si
7c64: 5b pop %bx
7c65: 58 pop %ax
7c66: c9 leave
7c67: c3 ret
7c68: 90 nop
thank you for reading so far.
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: cygcheck.out
URL: <http://cygwin.com/pipermail/cygwin/attachments/20040517/a98612be/attachment.ksh>
-------------- next part --------------
--
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple
Problem reports: http://cygwin.com/problems.html
Documentation: http://cygwin.com/docs.html
FAQ: http://cygwin.com/faq/
More information about the Cygwin
mailing list