file mode changes (-x)
implement 16-bit kernel relocation

After doing an upgrade to GCC 4.8.2 the kernel no longer
booted. This commit is a step in the direction of having
the kernel boot again, by implementing 16bit relocation.

As it turns out, the new GCC objcopy or ld no longer resolves
16bit data references while folding data into code.

Two main changes are implemented in the relocation table code:

1) the 16bit relocation table is written. A bug is now fixed
that would make the 32 bit relocation table seem empty when 16
bit relocation data was written. Now, there is always a count
for 16 bit relocation entries regardless of whether 16 bit relocation
is clobbered, thus having the bootloader properly detect the correct
offset for the 32 bit relocation table.

2) there are now 2 16 bit tables, one for .data16 and one for .text,
as each has a different relocation.
Since it is required that the 16 bit kernel header is executed in
realmode, the kernel must not be loaded high. Therefore, the 32 bit
relocation must be within 16 bit address space so as to not overflow
the 16 bit relocation table.

Makefile:
	temporarily produce a minimal ISO restoring the
	initial build speed. The idea is to produce a second
	DATA ISO which' changes are mostly independent of the
	code or Kernel ISO containing the boot image and a minimal
	filesystem (with the default minimalistic site sans documentation
	and source references).
	Basically all generated and imported web content is no longer
	imported.

kernel/realmode.s:
	add debugging to test realmode data offsets. This revealed that
	the .data16 offsets were indeed relative to .data16 ( > 0)
	and no longer normalized to .text.

bootloader/sector1.s:
	moved the pmode code into a 16 bit shareable include
	in preparation of reusing the code in kernel/pmode.s,
	as it contains a working interrupt handler. The pmode.s
	does not set up the IDT until protected mode is entered,
	and so this minimal handler would assist in debugging
	the current boot problem described in pmode.s's changelog.

16/pmode.s:
	factored out of bootloader/sector1.s.

kernel/gdt.s:
	debugging update; print the cs selector data.

kernel/pmode.s:
	QEmu's debug logging reveals that a protection fault
	is generated in the 'jlmpl' instruction right after
	setting the PMODE flag in cr0.
	The addressing scheme has been modified in setting up
	the protected mode address to jump to. It is as yet
	uncertain which is the right value, although the current
	value seems correct. 16 bit symbol addressing is now used,
	so that the 16 bit relocation is applied to the pmode_entry$
	method aswell. (otherwise the address ends up being relocated
	not at all or only with the .text offset (0x13000), and thus
	missing the offset of .data16 which _should_ be 0 but is
	relative to .text/.text16).
[WIP] booting proceeds until hardware int

Further improvements; this commit marks a stable situation.

The screen_buf_flush event handler in kernel/print.s is disabled
due to false symbol relocation.

Updated the GDT and IDT code to use 16 bit offsets to fix relocation
for the .data16 section (same as before; when referring to data in
.data16 there are 2 relocations: 32bit .text (0x13000), and 16bit .data16
(0x2000 or so).
Revive kernel: fix relocation and linker issues

	NOTE: the kernel now boots into the shell, but crashes
	soon after. However, to even get to this point a great
	amount of debugging was required, since the kernel would
	not even sucessfully enter protected mode.

	The main problem that this commit solves is that the recent
	GCC version does not update the relocation and symbol table
	entries for merged sections, leaving the original offsets
	in place, which causes the relocation to not be uniform
	(different values for different locations).

util/coff.cpp:
	Implement normalisation of relocation info:

	add option '--link <symbol>': perform link-time relocation, by
	updating the section data with the symbol values (for those symbols
	higher than or equal to the given symbol),
	replacing all relocation entries' symbol references to <symbol>,
	and finally resetting the symbol's offset to 0,
	thereby effectively making the entire image relocatable by
	the value of a single symbol (namely the given <symbol>).

	The resulting image is fully relocated with base address 0,
	so that runtime relocation can use the kernel load address
	to relocate the entire kernel.

util/reloc.pl:
	add %addr32reloc: store relocations grouped by symbol, potentially
	for future use (right now relocations using different symbols
	are handled by coff.cpp's --link normalisation).

	check for duplicate symbol definitions (same name, different address),
	and use the first one. In the current kernel object, input
	section relocations are kept; if we have 3 .text sections (due to
	having 3 .o files), then we have 3 .text symbols, each with different
	addresses. This corrects for this issue by assuming identically named
	symbols are consecutive, taking the first symbol (lowest address).

	fix some typos in pod doc.

util/ql.pl:
	usage: `ql.pl < qemu.log`: adds labels to code offsets.

Makefile:
	build util/symtab.cpp, used in util/ql.pl (the qemu log
	analyzer).

kernel/Makefile:
	don't make srcref by default (for faster builds);
	simplify cleaning temporary files;
	add 16/pmode.s as kernel dependency;
	echo the LD step for ring2.o;

	perform relocation using coff.cpp --link of the relocatable
	object file, kernel.obj.r.

kernel/idt.s:
kernel/gdt.s:
	Update calculation of IDT and GDT table offsets:

	"offset .text" was used to easily get at the relocation value.
	However, it does not refer to the kernel image start, but to
	the start of the 32 bit code segment, which is off by a few
	kilobytes.

	The GDTR and IDTR must contain physical memory addresses.
	The kernel's code selector is currently zero-based, so 'unrelocation'
	is not necessary here.

kernel/pmode.s:
	disable the 16/pmode.s test (entering/exiting pmode); left
	in there for testing purposes because it is relatively stable
	(the bootloaded uses it) and may work when the pmode code in
	this file doesn't;

	remove the "offset .text" calculations for $pmode_entry and
	use 32 bit relocated value instead;

	add (disabled) debug: delay loop just before entering pmode,
	and some trace code (writing a single character to screen in pmode).

bootloader/sector1.s:
	call print_16, not print;
	add debugging option TRACE_RELOC_ADDR to trace relocation of a single
	address, showing before and after values.

16/pmode.s:
	fix: call realmode print functions (otherwise the
	segment is reset to .text32 causing the following
	code to be placed in the wrong section).

kernel/print.s:
	fix symbol reference (forgot $ which made it reference code, not
	data).

kernel/dma.s:
kernel/fs.s:
kernel/oo.s:
kernel/lib/handles.s
	Several linker fixes: when the same file is included in several .o files,
	only one of them must define symbols and data; the others must merely
	declare the existence of them (using .global, which marks them as
	external to the object file, resolved during linking).
	The fixes are:

	- only define data and structure labels (and code) when DEFINE is
	  true, fixing duplicate symbols;
	- declare those symbols global if DEFINE is not true;

	This reduces the number of duplicate symbols to the section symbols
	(.text etc).

DOC/Bootsector.txt:
	describe the util/coff.cpp --link option;

DOC/Debugging.txt:
	notes on the difficulties debugging the recent GCC linker issues,
	and an idea for automated kernel testing.
Revived kernel: perform full relocation

	Main change: relocate 16bit and REL32 relocation.

	NOTE: 16 bit relocation is clobbered, because
	util/coff.cpp at current can only handle one --link
	argument; a dynamic list must be added to contain
	all relocated symbols, which are to be reset after
	relocation is done.

	NOTE: symbols themselves are also relocated, although
	their values are not reset to 0, which is required
	in order to produce the kernel.sym. Performing
	coff.exe --link twice on the same kernel.obj will
	relocate symbols twice.

Makefile:
	clobber 16 bit relocation entries in kernel.reloc

kernel/Makefile:
	remove redundant linking steps;

kernel/pmode.s:
	reduce debug level.

util/coff.cpp:
	verbose mode defaults to --link .text (without making changes);

	perform 16 bit relocation;
	perform 32bit relative relocation (REL32);

util/reloc.pl:
	add --no-16 option to clobber 16 bit relocation;
	update writing empty 16 bit relocation structure
	(bootloader relocation expects 2 16 bit tables,
	one for .text16, one for .data16);