Wednesday, March 20, 2013

Build kernel linux in virtualbox machine Ubuntu 10.04

This post is useful only for me, for remember what command I have to launch for compiling the kernel on the MY VirtualBox machine with Ubuntu 10.04.

However it can be useful for a starting point for other people.

$ make menuconfig
This command open a graphics menu where I check the options that are written in this link http://en.gentoo-wiki.com/wiki/Virtualbox_Guest

$ make

$ make modules

$ sudo make modules_install

$ sudo make install

$ cd /boot

$ sudo mkinitramfs -o initrd.img-2.6.32.60 2.6.32.60 (depends on the kernel version)

$ sudo grub-mkconfig -o /boot/grub/grub.cfg (I'm using grub)

When reboot the machine hold shift for choose the kernel.

Thursday, March 14, 2013

Simple echo in ASM code

This is very very simple and stupid code that reads from the standard input a string and writes on the standard output the same string.

The system calls are called by ASM code

#define BUF_SIZE 1024
#define READ 3
#define WRITE 4
#define FD 0

void main(){

 int __res;

 char __str[BUF_SIZE];

 //__res = read(0,__str,BUF_SIZE)
 __asm__ volatile ("int $0x80" : \
  "=a" (__res) : \
  "a" (READ), \
  "b" (FD), \
  "c" (__str), \
  "d" (BUF_SIZE));

 //write(0,__str,__res)
 __asm__ volatile ("int $0x80" : : \
  "a" (WRITE), \
  "b" (FD), \
  "c" (__str), \
  "d" (__res));

}