Linker error: PE operations on non PE file
From: Tom Junior (tbjnospam_at_automateddesign.com)
Date: 05/21/04
- Next message: Gary Labowitz: "Re: Book on C++"
- Previous message: Mark : "Re: Is there a more elegant way to populate a linked list ?"
- Next in thread: Mike Wahler: "Re: [OT, redir] Linker error: PE operations on non PE file"
- Reply: Mike Wahler: "Re: [OT, redir] Linker error: PE operations on non PE file"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Fri, 21 May 2004 15:50:33 GMT
Hi,
I don't know if this group covers linker errors. Anyway...
I'm running Windows 2000 Pro and using the latest version of DJGPP.
All I'm trying to do is compile and link a simple kernel example so I can
burn it to a floppy.
It involves 3 files:
kernel.c
kernel_start.asm
link.ld
Everything compiles fine using the following:
nasmw -f coff kernel_start.asm - o ks.o
gcc -c kernel.c -o kernel.o
Then I try to do the linking:
ld -T link.ld -o kernel.bin ks.o kernel.o
Result:
ld: PE operations on non PE file
Here's the linker file:
OUTPUT_FORMAT("binary")
ENTRY(start)
SECTIONS
{
.text 0x100000 : {
code = .; _code = .; __code = .;
*(.text)
. = ALIGN(4096);
}
.data : {
data = .; _data = .; __data = .;
*(.data)
. = ALIGN(4096);
}
.bss :
{
bss = .; _bss = .; __bss = .;
*(.bss)
. = ALIGN(4096);
}
end = .; _end = .; __end = .;
}
Can someone please explain the error and why I can't get these two files
to link?
Note: Compiling the assembly file to a.out format instead of coff does not
work, and gives me the error Invalid file format.
Thanks in advance,
Tom
The rest of the code:
kernel.c:
//////////////////////////////////////////////
// This code was made for the tutorial:
// "Making a Simple C kernel with Basic printf and clearscreen Functions"
//
// This code comes with absolutly
// NO WARRANTY
// you can not hold me(KJ), nor
// anyone else responsible for what
// this code does.
//
// This code is in the public domain,
// you may use it however you want
//////////////////////////////////////////////
#define WHITE_TXT 0x07 // white on black text
void k_clear_screen();
unsigned int k_printf(char *message, unsigned int line);
k_main() // like main in a normal C program
{
k_clear_screen();
k_printf("Hi!\nHow's this for a starter OS?", 0);
};
void k_clear_screen() // clear the entire text screen
{
char *vidmem = (char *) 0xb8000;
unsigned int i=0;
while(i < (80*25*2))
{
vidmem[i]=' ';
i++;
vidmem[i]=WHITE_TXT;
i++;
};
};
unsigned int k_printf(char *message, unsigned int line) // the message and
then the line #
{
char *vidmem = (char *) 0xb8000;
unsigned int i=0;
i=(line*80*2);
while(*message!=0)
{
if(*message=='\n') // check for a new line
{
line++;
i=(line*80*2);
*message++;
} else {
vidmem[i]=*message;
*message++;
i++;
vidmem[i]=WHITE_TXT;
i++;
};
};
return(1);
};
kernel_start.asm:
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; This code was made for the tutorial:
;; "Making a Simple C kernel with Basic printf and clearscreen Functions"
;;
;; This code comes with absolutly
;; NO WARRANTY
;; you can not hold me(KJ), nor
;; anyone else responsible for what
;; this code does.
;;
;; This code is in the public domain,
;; you may use it however you want
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
[BITS 32]
[global start]
[extern _k_main] ; this is in the c file
start:
call _k_main
cli ; stop interrupts
hlt ; halt the CPU
-- Using M2, Opera's revolutionary e-mail client: http://www.opera.com/m2/ -- Using M2, Opera's revolutionary e-mail client: http://www.opera.com/m2/
- Next message: Gary Labowitz: "Re: Book on C++"
- Previous message: Mark : "Re: Is there a more elegant way to populate a linked list ?"
- Next in thread: Mike Wahler: "Re: [OT, redir] Linker error: PE operations on non PE file"
- Reply: Mike Wahler: "Re: [OT, redir] Linker error: PE operations on non PE file"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|
|