coolwanglu/scanmem — pull request #27 by sriemer (2014-06-17 22:27:55+00:00)
Title: ARM fixes

On an armv7l system we've noticed an alignment issue. The kernel detected that in arch/arm/mm/alignment.c:
Alignment trap: scanmem (7783) PC=0x3aaea6b4 Instr=0xedd00b00 Address=0x0001d191 FSR 0x001

We can't dereference a memory address which is not sizeof(void *) aligned. So copy the data instead of dereferencing. Do this only for ARM as it might be slower on other systems.
-------------------------------------------------------------------------------------------------------------------------------------
The assuption that there is always a .rodata section and .data is consecutive to the previous region is wrong. On an armv7l system we've found a binary without one. Furthermore, we've found a binary on that system which has the heap region consecutive to .data of the executable. So it has been assigned to it by mistake. With this information it is clear now that the only way to be sure here is to compare the filename for each possible code region. Only for the .bss section it is still safe to assume that its filename is empty and that its consecutive to the .data section.

Add a source code documentation for the algorithm so that others can follow this approach.
------------------------------------------------------------------------------------------------------------------------------------
Tested on Nokia N9 MeeGo 1.2 Harmattan phone with: gof2, angrybirdsfreemagic, tuxracer, worthedig
Also tested again on x86 and x86_64 with: chromium-bsu, warzone2100, sol, sauerbraten