summaryrefslogtreecommitdiffstats
path: root/README.build-process
blob: 12158d661cfae1915991d6651290ea2468c72cc0 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
During memory testing memtest86 relocates itself in memory so it can test the
memory it was previously running from.  memtest86 is compiled as position mostly
independent code.  Some relocations records must be processed to achieve the
affect of position independent code.  A 16 bit loader is prepended to memtest86
so it can be loaded from a floppy, or from lilo.

In restructuring the build process I had several goals.  Maintainability and
comprehensibility of the build process.  Simplicity of the toolset. And the
ability to build images bootable by both the legacy x86 bootloader,
and images bootable by bootloaders that directly load static ELF images. 

With the ability to process relocation records, memtest.bin has been
reduced in size from 84480 bytes to 49308 bytes.  And now only requires one copy
of memtest86.  A reduction in size of 35K.  And the build process can now ignore
the size of memtest86.

BIOS calls have been moved from setup.S to head.S making bootsect.S and
setup.S exclusively for booting.

memtest86 is built in three stages.  In the first stage the relocatable object
files are built as with any program.  In the second stage the relocatable object
files are linked together into memtest_shared, a shared library version
of memtest86.  In the third stage a raw memory image of memtest_shared is formed
and linked into memtest.bin, and memtest.

memtest.bin is the floppy/lilo bootable target.

memtest is the ELF bootable target.

Another major change is now data in the bss segment is also preserved
when memtest86 is relocated, and memtest86 can be relocated to any address. 

The one thing to watch out for is pointers to data inside of memtest86.  Except
for constant pointers to static data there is not enough information to generate
relocation records for pointers so they will not change when memtest86 is
relocated, which might lead to nasty surprises.

Eric Biederman <ebiederman@lnxi.com>