This shouldn't even compile. The symbol is rdram, not rdram_memory. If the linker isn't failing due to undefined symbols then you must have seperate symbols for both rdram and rdram_memory.First, I added 8MB more to .bss:
Code:.bss .align 12 .type extra_memory, %object .size extra_memory, 16777216 extra_memory: .space 16777216+8388608+64+16+16+8+8+8+8+256+8+8+128+128+128+16+8+132+4+256+512+4194304 rdram_memory = extra_memory + 16777216 .align 12 .type rdram_memory, %object .size rdram_memory, 8388608 dynarec_local = rdram_memory + 8388608 .align 4 .type dynarec_local, %object .size dynarec_local, 64
And the redundant .aligns are useless.
Then I pointed rdram to this area in assem_arm.h:
Code:// This is defined in linkage_arm.s, but gcc -O3 likes this better //#define rdram ((unsigned int *)0x80000000) extern char rdram_memory[8388608]; #define rdram ((unsigned int *)rdram_memory)
rdram is used in many more places than assem_arm.* This can not possibly work.
BTW, the reason I repeated that definition was to work around a bug in gcc's optimizer. It was making some invalid assumptions about where rdram was located, and removing null pointer checks. I'm assuming you won't run into this bug with rdram in bss.
Next, I mmapped it in new_dynarec_init():
Code:u_char *tmp=(u_char*)rdram; if (mmap (tmp, 8388608, PROT_READ | PROT_WRITE | PROT_EXEC, MAP_FIXED | MAP_PRIVATE | MAP_ANONYMOUS, -1, 0) <= 0) {__android_log_print( ANDROID_LOG_ERROR, "new_dynarec", "Error: mmap() of rdram failed!" );}
There is absolutely no reason to make this region executable. Get rid of this.
Unmapping part of bss is just asking for trouble. Seriously, wtf?And munmapped it in new_dynarec_cleanup():
Okay.And finally, I set using_tlb to 1 in new_dynarec_init():
Code:// TLB //using_tlb=0; using_tlb=1;
Memory info after the changes:
Code:003ba000 g DO .bss 01000000 extra_memory 013ba000 g DO .bss 00800000 rdram_memory
The allocation is fine, but should be named rdram.
Last edited: