- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi all,
i write a program under nios2 using assemble lanauge, following is the source code # include <linux/module.h># include <linux/kernel.h> void print(void) { printk("function print\n"); } typedef void(*pointer)(void); ulong code[3]; void jump(void) { __asm__("movia r12, print"); __asm__("jmp r12"); } int __init init_filter(void) { jump(); } void __exit exit_filter(void) { } module_init(init_filter); module_exit(exit_filter); this can work well, but if i change the function init_filter as bellow, the system will reboot, int __init init_filter(void) { pointer p; code[0]=0x03000034; code[1]=0x63000004; code[2]=0x6000683a; p = (pointer)code; p(); } code[0]~code[2] is the hex value that i get from nios2-elf-objdump according to two assemble sentences. how should i do? thanks a lotLink Copied
2 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi qiunuoku,
I'm assuming that 'code' is a valid pointer ... and the opcodes are correct. That said, if you're using a data cache, you need to flush the region you modified with the new instructions. Then if you're using and instruction cache, you need invalidate the appropiate region as well. Otherwise, you will likely be executing stale bits rather than your copied code. Regards, --Scott- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
to Scott
thanks
Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page