Skip to content

Commit

Permalink
Fixed the format of hrb_format.md
Browse files Browse the repository at this point in the history
  • Loading branch information
jeffreyc2017 committed Jul 26, 2024
1 parent 5efbd4a commit b737977
Showing 1 changed file with 13 additions and 11 deletions.
24 changes: 13 additions & 11 deletions docs/hrb_format.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,15 @@ $ hexdump hello4.hrb
000007f
```

0x0000: 0400 0000 - Size of the data segment requested by the OS (4 bytes)
0x0004: 6148 6972 - Signature “Hari” (4 bytes, hexadecimal 0x69726148)
0x0008: 0000 0000 - Size of the pre-allocated space in the data segment (4 bytes)
0x000c: 0000 0031 - Initial value of ESP & transfer destination address (4 bytes)
0x0010: 000e 0000 - Size of the data segment in the .hrb file (4 bytes)
0x0014: 0071 0000 - Starting point of the data segment in the .hrb file (4 bytes)
0x0018: e900 0010 - Constant 0xe9000000 (4 bytes)
0x001c: 0000 0000 - Entry address of the application - 0x20 (4 bytes), value is 0x00000010
0x0020: 0000 0000 - Starting address of the malloc space (4 bytes)
- 0x0000: 0400 0000 - Size of the data segment requested by the OS (4 bytes)
- 0x0004: 6148 6972 - Signature “Hari” (4 bytes, hexadecimal 0x69726148)
- 0x0008: 0000 0000 - Size of the pre-allocated space in the data segment (4 bytes)
- 0x000c: 0000 0031 - Initial value of ESP & transfer destination address (4 bytes)
- 0x0010: 000e 0000 - Size of the data segment in the .hrb file (4 bytes)
- 0x0014: 0071 0000 - Starting point of the data segment in the .hrb file (4 bytes)
- 0x0018: e900 0010 - Constant 0xe9000000 (4 bytes)
- 0x001c: 0000 0000 - Entry address of the application - 0x20 (4 bytes), value is 0x00000010
- 0x0020: 0000 0000 - Starting address of the malloc space (4 bytes)

The .text segment starts from 0x30 which is aligned to 16-bytes boundary.
So the offset is calculated as below:
Expand All @@ -54,5 +54,7 @@ E9 cw JMP rel16 Jump near, relative, displacement relative to next instruction.
> A relative offset (rel8, rel16, or rel32) is generally specified as a label in assembly code, but at the machine code level, it is encoded as a signed 8-, 16-, or 32-bit immediate value. This value is added to the value in the EIP register. (Here, the EIP register contains the address of the instruction following the JMP instruction). When using relative offsets, the opcode (for short vs.
near jumps) and the operand-size attribute (for near relative jumps) determines the size of the target operand (8, 16, or 32 bits).

<https://www.intel.com/content/dam/www/public/us/en/documents/manuals/64-ia-32-architectures-software-developer-vol-2a-manual.pdf#page590>
<https://pdos.csail.mit.edu/6.828/2004/readings/i386/JMP.htm>
## References

- <https://www.intel.com/content/dam/www/public/us/en/documents/manuals/64-ia-32-architectures-software-developer-vol-2a-manual.pdf#page590>
- <https://pdos.csail.mit.edu/6.828/2004/readings/i386/JMP.htm>

0 comments on commit b737977

Please sign in to comment.