Xv6 with picoc & Linkage editor
v1.0
The project delineate mutual cohesion between c library, linkage editor ( linker), interpreter and operating system by porting the same on xv6 kernel
|
00001 #ifndef __I386_PIC_H__ 00002 #define __I386_PIC_H__ 00003 #ifdef __DYN_LIB 00004 00005 #undef __i686 00006 00007 #if 1 00008 /* don't trash the athlon return stack */ 00009 #if (__GNUC__ >= 3) // FIXME: how do I check for the binutils version ? 00010 .section .gnu.linkonce.t.__i686.get_pc_thunk.bx,"ax",@progbits 00011 .global __i686.get_pc_thunk.bx 00012 .hidden __i686.get_pc_thunk.bx 00013 .type __i686.get_pc_thunk.bx,@function 00014 __i686.get_pc_thunk.bx: 00015 movl (%esp), %ebx 00016 ret 00017 .previous 00018 00019 .macro PIC_INIT 00020 call __i686.get_pc_thunk.bx 00021 addl $_GLOBAL_OFFSET_TABLE_, %ebx 00022 .endm 00023 #else 00024 .text 00025 .Lgetpic: 00026 mov (%esp),%ebx 00027 ret 00028 00029 .macro PIC_INIT 00030 call .Lgetpic 00031 addl $_GLOBAL_OFFSET_TABLE_, %ebx 00032 .endm 00033 #endif 00034 #else 00035 /* standard code for PIC init */ 00036 .macro PIC_INIT 00037 call 0f 00038 0: popl %ebx 00039 addl $_GLOBAL_OFFSET_TABLE_+[.-0b], %ebx 00040 .endm 00041 #endif 00042 00043 #define PIC_SAVE pushl %ebx 00044 #define PIC_RESTORE popl %ebx 00045 00046 00047 /* get memory variable (var) in register (reg) */ 00048 .macro GET_VAR var reg 00049 movl \var@GOT(%ebx), \reg 00050 movl (\reg), \reg 00051 .endm 00052 00053 /* put register (reg) into memory variable (var) TRASH register (tmp) */ 00054 .macro PUT_VAR reg var tmp 00055 movl \var@GOT(%ebx), \tmp 00056 movl \reg, (\tmp) 00057 .endm 00058 00059 /* get memory variable (var) in register (reg) 00060 * IF no more PIC-code is needed */ 00061 .macro GET_1VAR var reg 00062 PIC_SAVE 00063 PIC_INIT 00064 GET_VAR \var, \reg 00065 PIC_RESTORE 00066 .endm 00067 00068 /* put register (reg) into memory variable (var) 00069 * IF no more PIC-code is needed */ 00070 .macro PUT_1VAR reg var 00071 PIC_SAVE 00072 PIC_INIT 00073 PUT_VAR \reg, \var, %ebx 00074 PIC_RESTORE 00075 .endm 00076 00077 #else 00078 00079 #define PIC_SAVE 00080 #define PIC_RESTORE 00081 #define PIC_INIT 00082 00083 .macro GET_VAR var reg 00084 movl \var, \reg 00085 .endm 00086 00087 .macro PUT_VAR reg var tmp 00088 movl \reg, \var 00089 .endm 00090 00091 .macro GET_1VAR var reg 00092 GET_VAR \var, \reg 00093 .endm 00094 00095 .macro PUT_1VAR reg var 00096 PUT_VAR \reg, \var, none 00097 .endm 00098 00099 #endif 00100 #endif