diff options
Diffstat (limited to 'elf.e')
| -rw-r--r-- | elf.e | 25 |
1 files changed, 8 insertions, 17 deletions
diff --git a/elf.e b/elf.e index 708de13..68eb6f2 100644 --- a/elf.e +++ b/elf.e @@ -9,22 +9,11 @@ ~ This relies on the label facility defined in labels.e. Make sure to load ~ that first. -~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~ -~ ~~ Runtime memory origin ~~ -~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~ -~ -~ First, we pick an origin to load at. This is arbitrary, but it can't be -~ zero. We define a constant word for it so the body of the program can use -~ it in label calculations in whatever ways it needs to. - -: origin 0x08000000 ; - - ~ ~~~~~~~~~~~~~~~~~~~~~ ~ ~~ ELF file header ~~ ~ ~~~~~~~~~~~~~~~~~~~~~ ~ -~ Second, we output ELF's top-level file header. This header describes the +~ First, we output ELF's top-level file header. This header describes the ~ entire file. An ELF always has exactly one of this header, which is always ~ at the start of the file. ~ @@ -48,7 +37,7 @@ 0x3e pack16 ~ *Intel x86-64 1 pack32 ~ ELF format version - L@' cold-start origin + pack64 ~ *entry point + L@' cold-start L@' origin + pack64 ~ *entry point ~ This includes the origin, intentionally. L@' elf-program-header pack64 ~ *program header offset @@ -74,7 +63,7 @@ ~ ~~ ELF program header ~~ ~ ~~~~~~~~~~~~~~~~~~~~~~~~ ~ -~ Third, we output ELF's program header, which lists the memory regions +~ Second, we output ELF's program header, which lists the memory regions ~ ("segments") we want to have and where we want them to come from. There may ~ be any number of these entries, one per segment, , and they may be anywhere ~ in the file as long as they're consecutive. @@ -104,7 +93,7 @@ 1 pack32 ~ *"loadable" segment type 0x05 pack32 ~ *read+execute permission 0 pack64 ~ *offset in file - origin pack64 ~ *virtual address + L@' origin pack64 ~ *virtual address ~ required, but can be anything, subject to alignment 0 pack64 ~ physical address (ignored) @@ -123,6 +112,8 @@ ~ ~~~~~~~~~~~~~~~~ ~ ~ ELF is a simple format, really. Now you can output your own machine code -~ that you generate however you want; make sure to define the label -~ cold-start, which will be the first thing that runs. +~ that you generate however you want; make sure to define the labels "origin" +~ and "cold-start". Origin will control the address the code loads at; +~ cold-start will be the first thing that runs. The origin is arbitrary, but +~ can't be zero. |