Page 1 of 1

[SOLVED] Problem with "Higher Half with GDT" lds

Posted: Mon Sep 24, 2007 5:43 pm
by Morpheu5
I've modified my toy kernel following http://www.osdev.org/osfaq2/index.php/HigherHalfWithGdt directions and I've simply grabbed that ld script. The symbols and sections are just at the right places (double checked, even triple checked) but when I link the final executable and objdump it I get some weird numbers:

Code: Select all

Sections:
Idx Name          Size      VMA       LMA       File off  Algn
  0 .text         00001a6d  00100000  40100000  000000e0  2**4
                  CONTENTS, ALLOC, LOAD, CODE
  1 .setup        0000001e  00100000  00100000  000000b4  2**0
                  CONTENTS, ALLOC, LOAD, READONLY, DATA
  2 .data         0000068e  00102000  40102000  000020e0  2**2
                  CONTENTS, ALLOC, LOAD, DATA
  3 .bss          0000102c  00103000  40103000  0000276e  2**2
                  ALLOC
  4 .comment      000003aa  00000000  00000000  0000276e  2**0
                  CONTENTS, READONLY
  5 .note.GNU-stack 00000000  00000000  00000000  00002b18  2**0
                  CONTENTS, READONLY
I thought that the VMA and LMA columns had to be inverted... indeed GRUB's complaining about not being able to load my executable at physical 0x401000000: of course it's not!

For what I know about ld scripts, that script is just ok and does what it is supposed to do... so why is my ld doing this thing? (For what matters, I'm using GCC 4.1.2 and LD 2.16.1.

Thanks.

Posted: Tue Sep 25, 2007 5:14 am
by Morpheu5
Sorry, I forgot to remove the -Ttext 0x100000 switch from the LDFLAGS in my Makefile. Indeed I've never used a linker script for my toy kernel.