This guide uses a lot of weird names, phrases and such. To faciliate a quicker assimilation of information, this little section is a must read.
Imagine that you are trying to assemble a simple command:
mov r1,r0When the compiler assembles it, it comes to something like this:
e1a01000and that's how it gets writen into the output binary file. But if you are using a little-endian, this will be written into the binary file as:
0010a0e1As you can see, it's just a difference in bytes ordering.
Side note:, endianess can be defined as the way to see a byte in which case we would be talking about bit ordering endianess but the StrongArm use big endian bit ordering endianess, in our case we are concerned with byte-ordering endianess which deals with the ordering of a sequence of bytes of 4 bytes). The StrongArm is a 32bits processor which uses Little Endian words (4 bytes).
A simple microkernel operating system. Check out the source code at Minix repository.
Location (in absolute 32bits) for the linker to assume that the kernel will be running from. You see, when the linker links the code, it uses absolute address to reference to string variables and such. So if you don't specify what location in memory the linker should assume the program(kernel) will be loaded, your program(kernel) will display garbage. Here is an example, lets assume we want to load into a register the pointer to a string variable:
puts("boo!"); 800c: e59f0004 ldr r0, [pc, #4] ; 8018 <L4> 8010: eb000019 bl 807c <_puts> 8014: ea000000 b 801c <L2> 00008018 <L4>: 8018: 0000809c muleq r0, r12, r0 0000809c <LC0>: 809c: 216f6f62 cmncs pc, r2, ror #30 ; "boo!"The ldr is a load word into a register, bl is a branching with return (something equivalant to i386 call). As you can see, the register r0 contains now the contents of location 8018, which is 0000809c. 0000809c is the string "boo!" in hexidecimal. The problem is that when you deploy this program (kernel) on to a system, you might not put the code at 00008000, but somewhere else. So when your program (kernel) runs, it will fetch the data from the wrong location! That is why you need to change the text location to the address where you will put the program (kernel). The argument for the linker is -Ttext=0x[some-value-here]
A toolchain actually consists of a number of components. The main one is the compiler itself gcc, which can be native to the host or a cross-compiler. This is supported by binutils, a set of tools for manipulating binaries. These components are all you need for compiling the kernel, but almost anything else you compile also needs the C-library glibc. As you will realize if you think about it for a moment, compiling the compiler poses a bootstrapping problem, which is the main reason why generating a toolset is not a simple exercise.