2015-09-06 16:17:39 +02:00
|
|
|
SECTIONS
|
|
|
|
|
{
|
2018-05-06 14:33:33 +01:00
|
|
|
/* We could also pass the -Ttext 0x7C00 to as instead of doing this.
|
|
|
|
|
* If your program does not have any memory accesses, you can omit this.
|
|
|
|
|
*/
|
2015-09-06 16:17:39 +02:00
|
|
|
. = 0x7c00;
|
2015-09-06 21:45:05 +02:00
|
|
|
.text :
|
2015-09-06 16:17:39 +02:00
|
|
|
{
|
2015-11-09 12:15:15 +01:00
|
|
|
__start = .;
|
|
|
|
|
|
2018-05-06 14:33:33 +01:00
|
|
|
/* We are going to stuff everything
|
|
|
|
|
* into a text segment for now, including data.
|
|
|
|
|
* Who cares? Other segments only exist to appease C compilers.
|
2015-10-04 19:59:15 +02:00
|
|
|
*/
|
|
|
|
|
*(.text)
|
|
|
|
|
|
2018-05-06 14:33:33 +01:00
|
|
|
/* Magic bytes. 0x1FE == 510.
|
|
|
|
|
*
|
|
|
|
|
* We could add this on each Gas file separately with `.word`,
|
|
|
|
|
* but this is the perfect place to DRY that out.
|
|
|
|
|
*/
|
2015-09-06 18:47:10 +02:00
|
|
|
. = 0x1FE;
|
2015-09-07 16:27:49 +02:00
|
|
|
SHORT(0xAA55)
|
2015-10-04 19:59:15 +02:00
|
|
|
|
2018-05-06 14:33:33 +01:00
|
|
|
/* This is only needed if we are going to use a 2 stage boot process,
|
|
|
|
|
* e.g. by reading more disk than the default 512 bytes with BIOS `int 0x13`.
|
2015-10-04 19:59:15 +02:00
|
|
|
*/
|
|
|
|
|
*(.stage2)
|
2015-10-06 12:27:24 +02:00
|
|
|
|
2018-05-06 14:33:33 +01:00
|
|
|
/* Number of sectors in stage 2. Used by the `int 13` to load it from disk.
|
|
|
|
|
*
|
|
|
|
|
* The value gets put into memory as the very last thing
|
|
|
|
|
* in the `.stage` section if it exists.
|
|
|
|
|
*
|
|
|
|
|
* We must put it *before* the final `. = ALIGN(512)`,
|
|
|
|
|
* or else it would fall out of the loaded memory.
|
|
|
|
|
*
|
|
|
|
|
* This must be absolute, or else it would get converted
|
|
|
|
|
* to the actual address relative to this section (7c00 + ...)
|
|
|
|
|
* and linking would fail with "Relocation truncated to fit"
|
|
|
|
|
* because we are trying to put that into al for the int 13.
|
2015-10-06 12:27:24 +02:00
|
|
|
*/
|
2015-11-09 12:15:15 +01:00
|
|
|
__stage2_nsectors = ABSOLUTE((. - __start) / 512);
|
2015-10-06 12:27:24 +02:00
|
|
|
|
2015-10-17 00:03:05 +02:00
|
|
|
/* Ensure that the generated image is a multiple of 512 bytes long. */
|
2015-10-06 12:27:24 +02:00
|
|
|
. = ALIGN(512);
|
2015-10-27 09:04:46 +01:00
|
|
|
__end = .;
|
|
|
|
|
__end_align_4k = ALIGN(4k);
|
2015-09-06 16:17:39 +02:00
|
|
|
}
|
|
|
|
|
}
|