Author Topic: Linking a 64 bit kernel  (Read 9769 times)

Offline Anonymous

  • Jr. Member
  • *
  • Posts: 78
  • Country: us
Linking a 64 bit kernel
« on: August 11, 2014, 01:10:32 AM »
Hi All I have been trying to link my assembly code to a C++ file so I can fall my function kMain from assembly and When I link it with this script :
Code: [Select]
ENTRY(_Start)
SECTIONS
{
    . = 0x2000;

    .text : AT(ADDR(.text) - 0x2000)
    {
        _code = .;
        *(.text)
        *(.rodata*)
        . = ALIGN(4096);
    }

   .data : AT(ADDR(.data) - 0x2000)
   {
        _data = .;
        *(.data)
        . = ALIGN(4096);
   }

   .eh_frame : AT(ADDR(.eh_frame) - 0x2000)
   {
       _ehframe = .;
       *(.eh_frame)
        . = ALIGN(4096);
   }

   .bss : AT(ADDR(.bss) - 0x2000)
   {
       _bss = .;
       *(.bss)

       /*
        * You usually need to include generated COMMON symbols
        * under kernel BSS section or use gcc's -fno-common
        */

        *(COMMON)
       . = ALIGN(4096);
   }

   _end = .;

   /DISCARD/ :
   {
        *(.comment)
   }
}

I get a warning saying : x86_64-elf-ld: warning: cannot find entry symbol _Start; defaulting to 0000000000002000
But in my Assembly Code I have this at the start:
Code: [Select]
[BITS 16]
_Start:
Any Ideas as to why its not linking Correctly??
Edit:
I changed it to global _Start:
_Start and it worked my mistake
« Last Edit: August 11, 2014, 02:35:14 AM by Anonymous »
Thanks in advance, Anonymous

Offline Frank Kotler

  • NASM Developer
  • Hero Member
  • *****
  • Posts: 2667
  • Country: us
Re: Linking a 64 bit kernel
« Reply #1 on: August 13, 2014, 05:16:28 AM »
I hear through the grapevine that the code is here:

https://github.com/AnonymousUser1337/Anmu

Right? Good plan!

Best,
Frank


Offline Anonymous

  • Jr. Member
  • *
  • Posts: 78
  • Country: us
Re: Linking a 64 bit kernel
« Reply #2 on: August 15, 2014, 08:14:35 PM »
Ya it is Thanks :D
Thanks in advance, Anonymous