From: Jan Schiefer <cheaterjs@gmx.de>
To: linux-kernel@vger.kernel.org
Subject: Wired linker problem...
Date: Sun, 14 Aug 2005 12:36:42 +0200 [thread overview]
Message-ID: <ddn6oa$gl2$1@sea.gmane.org> (raw)
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
This is not linux kernel related, but at least it's kernel releated.
So I think u're the experts, that can help me. :)
I'm coding a little kernel in C and ASM and I use only GCC + NASM for
coding. GRUB loads my little kernel.
Everything goes well, but there is one really wired problem with ld,
which I use for linking the stuff...
My kernel is about 8kb big and loads well with GRUB. But when I exceed a
specific amount of code the size of my kernel goes up from 8kb to 1 MB
and GRUB won't load it anymore.
It says, it won't recognize the file format anymore. So I think it
doesn't finds the GRUB boot sigmature ( in entry.asm ) anymore.
I use following command for linking: ld -T link.ld -o kernel.bin entry.o
main.o display.o memory.o string.o io.o gdt.o gdt_helper.o
The linker script link.ld:
OUTPUT_FORMAT("binary")
ENTRY(start)
phys = 0x00100000;
SECTIONS
{
.text phys : AT(phys) {
code = .;
*(.text)
. = ALIGN(4096);
}
.data : AT(phys + (data - code))
{
data = .;
*(.data)
. = ALIGN(4096);
}
.bss : AT(phys + (bss - code))
{
bss = .;
*(.bss)
. = ALIGN(4096);
}
end = .;
}
My start code in entry.asm:
[BITS 32]
global start
start:
mov esp, _sys_stack ; This points the stack to our new stack area
jmp stublet
; This part MUST be 4byte aligned, so we solve that issue using 'ALIGN 4'
ALIGN 4
mboot:
; Multiboot macros to make a few lines later more readable
MULTIBOOT_PAGE_ALIGN equ 1<<0
MULTIBOOT_MEMORY_INFO equ 1<<1
MULTIBOOT_AOUT_KLUDGE equ 1<<16
MULTIBOOT_HEADER_MAGIC equ 0x1BADB002
MULTIBOOT_HEADER_FLAGS equ MULTIBOOT_PAGE_ALIGN |
MULTIBOOT_MEMORY_INFO | MULTIBOOT_AOUT_KLUDGE
MULTIBOOT_CHECKSUM equ -(MULTIBOOT_HEADER_MAGIC +
MULTIBOOT_HEADER_FLAGS)
EXTERN code, bss, end
; This is the GRUB Multiboot header. A boot signature
dd MULTIBOOT_HEADER_MAGIC
dd MULTIBOOT_HEADER_FLAGS
dd MULTIBOOT_CHECKSUM
; AOUT kludge - must be physical addresses. Make a note of these:
; The linker script fills in the data for these ones!
dd mboot
dd code
dd bss
dd end
dd start
stublet:
extern k_main
call k_main
jmp $
; Here is the definition of our BSS section. Right now, we'll use
; it just to store the stack. Remember that a stack actually grows
; downwards, so we declare the size of the data before declaring
; the identifier '_sys_stack'
SECTION .bss
resb 8192 ; This reserves 8KBytes of memory here
_sys_stack
I think the problem lies in the liker script, but I'm unable to find it
myself... *sniff* :(
Greetings,
Jan Schiefer!
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.5 (GNU/Linux)
Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org
iD8DBQFC/x66zC00UKXFdVcRAhvNAJ9uQ5UOT4wvKk5kKWAdfHE4ZXc8fwCfc4cB
drqR27xFcBEhXNReznruMJo=
=DCVJ
-----END PGP SIGNATURE-----
reply other threads:[~2005-08-14 10:50 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='ddn6oa$gl2$1@sea.gmane.org' \
--to=cheaterjs@gmx.de \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox