How to generate gcc debug symbol outside the build target?

How to generate gcc debug symbol outside the build target?

1. how to strip elf.

2. how to separate debug information from elf files.

3. how to use debug information in gdb(or ida pro).

ida pro : file -> load file -> DBG file

4. how to merge debug information into elf files.

How debuggers work: Part 3 – Debugging information

About debugging information.

How to find functions, variables and line number based on debugging information(dwarf)

process infomation get within kernel

linux get process name from pid within kernel

  unsigned int pid = task_pid_nr(current);

 unsigned char * comm= current->comm;

printk(KERN_INFO “Simon:pid=%u,comm=%s\n,pid,comm);

How to get current process’s UID and EUID in Linux Kernel 4.2?

unsigned int uid = current_uid();

unsigned int euid = current_euid();

 unsigned int suid = current_suid();

unsigned int gid = current_gid();

Get time within kernel :

unsigned int get_kernel_time_sec()


        struct timeval ctv;


        return (unsigned int)ctv.tv_usec;

}// And then you can create a rand function based on time. 

unsigned int rand(unsigned int limit)


        unsigned int c_tv = get_kernel_time_sec();



                return c_tv;




                return c_tv%limit;



#include <linux/cred.h> // current_uid & current_euid

#include <linux/time.h> // current_kernel_time

#include <linux/types.h> //timespec

#include <linux/timer.h>

#include <linux/sched.h> // task_pid_nr    current->comm;