linux-old/arch/x86_64/tools/offset.c
<<
>>
Prefs
   1/* Written 2000 by Andi Kleen */
   2/* This program is never executed, just its assembly is examined for offsets 
   3   (this trick is needed to get cross compiling right) */  
   4/* $Id: offset.c,v 1.16 2002/07/18 13:41:46 ak Exp $ */
   5#define ASM_OFFSET_H 1
   6#ifndef __KERNEL__
   7#define __KERNEL__ 
   8#endif
   9#include <linux/sched.h> 
  10#include <linux/stddef.h>
  11#include <linux/errno.h> 
  12#include <asm/pda.h>
  13#include <asm/hardirq.h>
  14#include <asm/processor.h>
  15#include <asm/desc.h>
  16
  17#define output(x) asm volatile ("--- " x)
  18#define outconst(x,y) asm volatile ("--- " x : : "i" (y)) 
  19
  20int main(void) 
  21{ 
  22        output("/* Auto generated by arch/../tools/offset.c at " __DATE__ ". Do not edit. */\n"); 
  23        output("#ifndef ASM_OFFSET_H\n");
  24        output("#define ASM_OFFSET_H 1\n"); 
  25
  26        // task struct entries needed by entry.S
  27#define ENTRY(entry) outconst("#define tsk_" #entry " %0", offsetof(struct task_struct, entry))
  28        ENTRY(state);
  29        ENTRY(flags); 
  30        ENTRY(sigpending); 
  31        ENTRY(addr_limit); 
  32        ENTRY(need_resched); 
  33        ENTRY(exec_domain); 
  34        ENTRY(ptrace); 
  35        ENTRY(processor);
  36        ENTRY(need_resched); 
  37        ENTRY(thread); 
  38#undef ENTRY
  39#define ENTRY(entry) outconst("#define pda_" #entry " %0", offsetof(struct x8664_pda, entry))
  40        ENTRY(kernelstack); 
  41        ENTRY(oldrsp); 
  42        ENTRY(pcurrent); 
  43        ENTRY(irqrsp);
  44        ENTRY(irqcount);
  45        ENTRY(pgd_quick);
  46        ENTRY(pmd_quick);
  47        ENTRY(pte_quick);
  48        ENTRY(pgtable_cache_sz);
  49        ENTRY(cpunumber);
  50        ENTRY(irqstackptr);
  51        ENTRY(level4_pgt);
  52#undef ENTRY
  53        output("#ifdef __ASSEMBLY__"); 
  54        outconst("#define PT_TRACESYS %0", PT_TRACESYS);
  55        outconst("#define TASK_SIZE %0", TASK_SIZE); 
  56        outconst("#define SIGCHLD %0", SIGCHLD);
  57        outconst("#define CLONE_VFORK %0", CLONE_VFORK); 
  58        outconst("#define CLONE_VM %0", CLONE_VM); 
  59
  60
  61        outconst("#define thread_flags %0" , offsetof(struct thread_struct, flags));
  62        outconst("#define ASM_THREAD_IA32 %0", THREAD_IA32);
  63
  64        outconst("#define PER_CPU_GDT_SIZE %0", sizeof(struct per_cpu_gdt)); 
  65        output("#endif"); 
  66
  67        output("#endif\n"); 
  68
  69        return(0); 
  70} 
  71
  72
lxr.linux.no kindly hosted by Redpill Linpro AS, provider of Linux consulting and operations services since 1995.