source code like this: ----------------------------------------------------------------------------------------------------- .section ".reset", "ax", %progbits .code16 .globl _start _start: .byte 0xe9 .int _start16bit - ( . + 2 ) /* Note: The above jump is hand coded to work around bugs in binutils. * 5 byte are used for a 3 byte instruction. This works because x86 * is little endian and allows us to use supported 32bit relocations * instead of the weird 16 bit relocations that binutils does not * handle consistently between versions because they are used so rarely. */ .previous
-----------------------------------------------------------------------------------------------------
I tried to modify the code and passed test (use qemu test). My code like this: ----------------------------------------------------------------------------------------------------- .section ".reset", "ax", %progbits .code16 .globl _start _start: jmp _start16bit .previous
-----------------------------------------------------------------------------------------------------
What is the meaning of hand coding? In 16-bit mode, the last two bytes are ignored.
------------------
王翔
安全研究员
广州市腾御安信息科技有限公司
广州市天河区珠江新城华穗路406号保利克洛维二期中景A座1020-1024
2017-08-16 5:03 GMT+02:00 王翔 merle@tya.email:
What is the meaning of hand coding? In 16-bit mode, the last two bytes
are ignored. This is _very_ old code. Back in the day, before we started to strongly encourage people to use our compiler, we had to deal with tons of different versions of the toolchain. As the comment to the code indicates, 16bit relocations worked for some and failed for others. Therefore we went for the safe route and manually created a 32bit relocation. We could probably clean up this part of the code now, but since so few people are ever concerned with it (because it does exactly what it's supposed to), there was no pressing need yet.
Regards, Patrick