grub not liking ". = ALIGN (0x1000);" in ld script

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
bradbobak
Member
Member
Posts: 26
Joined: Fri Apr 14, 2006 11:00 pm

grub not liking ". = ALIGN (0x1000);" in ld script

Post by bradbobak »

Here is my ld script where grub outputs "Error 13: Invalid or unsupported executable format'".

Code: Select all

ENTRY (loaded)

SECTIONS
{
  . = 0x00100000;

  .text ALIGN (0x1000) :
  {
    syscall.o (.text)

    . = ALIGN (0x1000);

    * (.text)
  }
}
The other sections are standard (.rodata, .data, .bss) and work fine as-is.

Removing the ". = ALIGN(0x1000);" works fine, but I'd like syscall.o aligned on its own pages (just so I can mark those pages as accessible from ring 3). Possibly there is another way to do this?
User avatar
xenos
Member
Member
Posts: 1121
Joined: Thu Aug 11, 2005 11:00 pm
Libera.chat IRC: xenos1984
Location: Tartu, Estonia
Contact:

Re: grub not liking ". = ALIGN (0x1000);" in ld script

Post by xenos »

Looks like a typical case of pushing your multiboot header beyond the first 8k of your kernel executable. Make sure that the multiboot header comes close to the beginning of your kernel.
Programmers' Hardware Database // GitHub user: xenos1984; OS project: NOS
Kevin
Member
Member
Posts: 1071
Joined: Sun Feb 01, 2009 6:11 am
Location: Germany
Contact:

Re: grub not liking ". = ALIGN (0x1000);" in ld script

Post by Kevin »

The multiboot header must be within the first 8k of the binary. You're probably moving it too far to the end this way. Make sure to have the object file with the multiboot header first. Then aligning syscall.o should work fine.
Developer of tyndur - community OS of Lowlevel (German)
bradbobak
Member
Member
Posts: 26
Joined: Fri Apr 14, 2006 11:00 pm

Re: grub not liking ". = ALIGN (0x1000);" in ld script

Post by bradbobak »

Excellent, works like a charm now. Thanks for the help.
Post Reply