offline
- savan2
- Građanin
- Pridružio: 15 Jul 2009
- Poruke: 150
|
Pozdrav svima, radim nesto u linux kernelu tj pokusavam da definisem par funkcija kako nebi morao da "portujem" komplet "kod" iz kernela u neki "userspace" program, znaci hocu jednostavno da te funkcije/intervale citam/pozivam iz memorije... slucaj je sledeci:
- par funkcija u kernel modulu sam napravio ovako:
int a, b, c, d, e;
int recovery_leave(void) {
if (a) return a;
else return 0;
}
EXPORT_SYMBOL(recovery_leave);
int recovery_x(void) {
if (b) return b;
else return 0;
}
EXPORT_SYMBOL(recovery_x);
int recovery_y(void) {
if (c) return c;
else return 0;
}
EXPORT_SYMBOL(recovery_y);
int recovery_w(void) {
if (d) return d;
else return 0;
}
EXPORT_SYMBOL(recovery_w);
int recovery_z(void) {
if (e) return e;
else return 0;
}
EXPORT_SYMBOL(recovery_z);
Intervali a,b,c,d,e bi trebali da su promenjivi posto sam ih u kernel modulu postavio na mestima gde odredjena funkcija cita vrednosti... otprilike ovako: a=neki_nesto[i][0]; c=0; ...itd. E sad "kallsyms" i adrese do funkcija kada "objdump" vmlinux izgledaju ovako:
c02c7c88 <recovery_leave>:
c02c7c88: e1a0c00d mov ip, sp
c02c7c8c: e92dd800 push {fp, ip, lr, pc}
c02c7c90: e24cb004 sub fp, ip, #4 ; 0x4
c02c7c94: e59f3004 ldr r3, [pc, #4] ; c02c7ca0 <recovery_leave+0x18>
c02c7c98: e5930000 ldr r0, [r3]
c02c7c9c: e89da800 ldm sp, {fp, sp, pc}
c02c7ca0: c074878c .word 0xc074878c
c02c7ca4 <recovery_x>:
c02c7ca4: e1a0c00d mov ip, sp
c02c7ca8: e92dd800 push {fp, ip, lr, pc}
c02c7cac: e24cb004 sub fp, ip, #4 ; 0x4
c02c7cb0: e59f3004 ldr r3, [pc, #4] ; c02c7cbc <recovery_x+0x18>
c02c7cb4: e5930004 ldr r0, [r3, #4]
c02c7cb8: e89da800 ldm sp, {fp, sp, pc}
c02c7cbc: c074878c .word 0xc074878c
c02c7cc0 <recovery_y>:
c02c7cc0: e1a0c00d mov ip, sp
c02c7cc4: e92dd800 push {fp, ip, lr, pc}
c02c7cc8: e24cb004 sub fp, ip, #4 ; 0x4
c02c7ccc: e59f3004 ldr r3, [pc, #4] ; c02c7cd8 <recovery_y+0x18>
c02c7cd0: e5930008 ldr r0, [r3, #8]
c02c7cd4: e89da800 ldm sp, {fp, sp, pc}
c02c7cd8: c074878c .word 0xc074878c
c02c7cdc <recovery_w>:
c02c7cdc: e1a0c00d mov ip, sp
c02c7ce0: e92dd800 push {fp, ip, lr, pc}
c02c7ce4: e24cb004 sub fp, ip, #4 ; 0x4
c02c7ce8: e59f3004 ldr r3, [pc, #4] ; c02c7cf4 <recovery_w+0x18>
c02c7cec: e593000c ldr r0, [r3, #12]
c02c7cf0: e89da800 ldm sp, {fp, sp, pc}
c02c7cf4: c074878c .word 0xc074878c
c02c7cf8 <recovery_z>:
c02c7cf8: e1a0c00d mov ip, sp
c02c7cfc: e92dd800 push {fp, ip, lr, pc}
c02c7d00: e24cb004 sub fp, ip, #4 ; 0x4
c02c7d04: e59f3004 ldr r3, [pc, #4] ; c02c7d10 <recovery_z+0x18>
c02c7d08: e5930010 ldr r0, [r3, #16]
c02c7d0c: e89da800 ldm sp, {fp, sp, pc}
c02c7d10: c074878c .word 0xc074878c
Ono sto ja hocu a nikad nisam radio (ovo mi je prvi put) je da citam interval recovery_z "iz userspace programa" tako sto bi pozvao kernel funkciju koja bi trebala da je u memoriji na adresi 0xc02c7cf8 otprilike ovako:
int (*recovery_z)(void) = (void*) 0xc02c7cf8;
a novi interval "int nn_z = recovery_z();"
medjutim nesto nije u redu, verovatno se to tako ne radi ... svaka pomoc dobro dosla!
|