X-Authentication-Warning: delorie.com: mail set sender to djgpp-bounces using -f Newsgroups: comp.os.msdos.djgpp Subject: Help: PE operations on a non PE file. From: Tom Junior Organization: Automated Design Corporation Content-Type: text/plain; format=flowed; charset=iso-8859-15 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Message-ID: User-Agent: Opera7.21/Win32 M2 build 3218 Lines: 159 Date: Fri, 21 May 2004 15:48:31 GMT NNTP-Posting-Host: 66.82.112.1 X-Complaints-To: abuse AT earthlink DOT net X-Trace: newsread2.news.atl.earthlink.net 1085154511 66.82.112.1 (Fri, 21 May 2004 08:48:31 PDT) NNTP-Posting-Date: Fri, 21 May 2004 08:48:31 PDT To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Reply-To: djgpp AT delorie DOT com Hi! 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 how I can 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/