tech-kern archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: patch: MFSv3 support (libsa) for boot2 (i386)

On Thu, Jan 12, 2012 at 10:43 PM, David Laight <> 
> On Thu, Jan 12, 2012 at 09:25:04PM +0400, Evgeniy Ivanov wrote:
>> Magic too :-) I fall into trouble with it. In generated listing (mbr.S):
>>  518 00f1 E9FE7B                jmp     BOOTADDR
>> In obj file:
>>  f1:   e9 fe 7b 5a 8a          jmp    8a5a7cf4 <bss_end+0x8a5a76e4>
>> In mbr (i.e. after linking):
>> 00000f0  5a e9 0c f3 5a 8a 74 01
>>                         ^^^^ Address has changed.
>> I'm porting mbr to MINIX and address isn't changed there. What does
>> happen in NetBSD on linking stage?
> The code is linked to an address other than 0x7c00, the first thing
> it does is copy itself to that address.
> Are you sure you are disassembling it correctly ?
> It looks like you haven't told objdump? it is 16bit code.

Yes, I was handling that output by hands. Thanks for the proper command.

> That jmp instruction needs to goto address 7c00, the opcode contains
> the pc-next relative value, the 7bfe value is just a parameter to
> the relocation.
> In the final image you have f30c+3+f1-7c00 is 0x7800 which is ok
> if the code is expected to relocate itself to 0x7800.

Why do you refer 0x7800, how it's related to the LOADADDR (0x8800)?
With --adjust-vma=0x8800 I get the thing I understand:
88f1:       e9 0c f3                jmp    0x7c00
0x88f1 + 3 - 3316 (0xf30c) = 0x7c00

And I still miss the meaning of relocation value 7bfe.
In object file it is
131:   e9 fe 7b                jmp    0x7d32
7d32 = 7c00 + 0x132 (i.e. number of bytes before this command).

And then when link how do we get e9 0c f3? That's the thing I dream to
know :-) Because in MINIX I get in final image
88f1:       e9 fe 7b                jmp    0x4f2

While preprocessed sources are the same on both systems and compiled
with same options.

> You can get a correct disassembly with:
>    objdump -bbinary -D -mi8086 --adjust-vma=0x7800 mbr
> The actual value for LOADADDR can be seen at the top of the output.
> Note that the bootselect code uses a big chunk (probably 0x400 bytes)
> of 'bss', so 0x7800 is a bad choice of relocation address!
>        David
> --
> David Laight:


Home | Main Index | Thread Index | Old Index