linux-user: correct core dump format
This patch allows to really use the core dumped by qemu with guest
architecture tools.
- it adds a missing bswap_phdr() for the program headers
of memory regions.
"objdump -x" sample:
BEFORE:
0x1000000 off 0x00200000 vaddr 0x00000400 paddr 0x00000000 align 2**21
filesz 0x00000000 memsz 0x00100000 flags ---
0x1000000 off 0x00200000 vaddr 0x00100400 paddr 0x00000000 align 2**21
filesz 0x00000000 memsz 0x00080000 flags --- 6000000
AFTER:
LOAD off 0x00002000 vaddr 0x00040000 paddr 0x00000000 align 2**13
filesz 0x00000000 memsz 0x00001000 flags ---
LOAD off 0x00002000 vaddr 0x00041000 paddr 0x00000000 align 2**13
filesz 0x00000000 memsz 0x00000800 flags rw-
- it doesn't pad the note size to sizeof(int32_t).
On m68k the NT_PRSTATUS note size is 154 and
must not be rounded up to 156, because this value is checked by
objdump and gdb.
"gdb" symptoms:
"warning: Couldn't find general-purpose registers in core file."
"objdump -x" sample:
BEFORE:
Sections:
Idx Name Size VMA LMA File off Algn
0 note0
000001c4 00000000 00000000 000003b4 2**0
CONTENTS, READONLY
1 .auxv
00000070 00000000 00000000 00000508 2**2
CONTENTS
2 proc1
00100000 00000400 00000000 00200000 2**10
READONLY
AFTER:
Sections:
Idx Name Size VMA LMA File off Algn
0 note0
000001c4 00000000 00000000 000003b4 2**0
CONTENTS, READONLY
1 .reg/19022
00000050 00000000 00000000 0000040e 2**2
CONTENTS
2 .reg
00000050 00000000 00000000 0000040e 2**2
CONTENTS
3 .auxv
00000070 00000000 00000000 00000508 2**2
CONTENTS
4 load1
00000000 00040000 00000000 00002000 2**13
ALLOC, READONLY
Signed-off-by: Laurent Vivier <laurent@vivier.eu>
Signed-off-by: Riku Voipio <riku.voipio@nokia.com>