What is "ld -Ttext" option doing?
<p>I am following <a href="https://www.cs.bham.ac.uk/~exr/lectures/opsys/10_11/lectures/os-dev.pdf" rel="noreferrer">this half-completed tutorial</a> to develop a simple OS. One step (on page 50) is to compile a simple kernel with <code>$ld -o kernel.bin -Ttext 0x1000 kernel.o --oformat binary</code>. However I don't really understand what is the option <code>-Ttext</code> doing.</p>

<p>To make the question specific, why in the following experiment are md5s of <code>kernel_1000.bin</code> &amp; <code>kernel.bin</code> equal, <code>kernel_1001.bin</code> &amp; <code>kernel_1009.bin</code> equal, and <code>kernel_1007.bin</code> &amp; <code>kernel_1017.bin</code> equal, while all other pairs are not equal?</p>

<h1>My experiment</h1>

<p>I tried to compile several different kernels with different <code>-Ttext</code> like the in the following <code>Makefile</code>:</p>

<pre><code>...
kernel.o: kernel.c
    gcc -ffreestanding -c kernel.c

kernel.bin: kernel.o
    ld -o $@ kernel.o --oformat binary

kernel_1000.bin: kernel.o
    ld -o $@ -Ttext 0x1000 kernel.o --oformat binary

kernel_1001.bin: kernel.o
    ld -o $@ -Ttext 0x1001 kernel.o --oformat binary
...
</code></pre>

<p>And then I checked their md5:</p>

<pre><code>$ ls *.bin | xargs md5sum
d9248440a2c816e41527686cdb5118e4  kernel_1000.bin
65db5ab465301da1176b523dec387a40  kernel_1001.bin
819a5638827494a4556b7a96ee6e14b2  kernel_1007.bin
d9248440a2c816e41527686cdb5118e4  kernel_1008.bin
65db5ab465301da1176b523dec387a40  kernel_1009.bin
216b24060abce034911642acfa880403  kernel_1015.bin
e92901b1d12d316c564ba7916abca20c  kernel_1016.bin
819a5638827494a4556b7a96ee6e14b2  kernel_1017.bin
d9248440a2c816e41527686cdb5118e4  kernel.bin
</code></pre>

<h1>kernel.c</h1>

<pre><code>void main() {
  char* video_memory = (char*) 0xb8000;
  *video_memory = 'X';
}
</code></pre>

<h1>Development environment</h1>

<pre><code>$ gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/4.9/lto-wrapper
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Debian 4.9.2-10' --with-bugurl=file:///usr/share/doc/gcc-4.9/README.Bugs --enable-languages=c,c++,java,go,d,fortran,objc,obj-c++ --prefix=/usr --program-suffix=-4.9 --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --with-gxx-include-dir=/usr/include/c++/4.9 --libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --enable-gnu-unique-object --disable-vtable-verify --enable-plugin --with-system-zlib --disable-browser-plugin --enable-java-awt=gtk --enable-gtk-cairo --with-java-home=/usr/lib/jvm/java-1.5.0-gcj-4.9-amd64/jre --enable-java-home --with-jvm-root-dir=/usr/lib/jvm/java-1.5.0-gcj-4.9-amd64 --with-jvm-jar-dir=/usr/lib/jvm-exports/java-1.5.0-gcj-4.9-amd64 --with-arch-directory=amd64 --with-ecj-jar=/usr/share/java/eclipse-ecj.jar --enable-objc-gc --enable-multiarch --with-arch-32=i586 --with-abi=m64 --with-multilib-list=m32,m64,mx32 --enable-multilib --with-tune=generic --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu
Thread model: posix
gcc version 4.9.2 (Debian 4.9.2-10) 
$ uname -a
Linux localhost 3.16.0-4-amd64 #1 SMP Debian 3.16.7-ckt20-1+deb8u1 (2015-12-14) x86_64 GNU/Linux
</code></pre>