Fix vdso32 relocation for paddr
PATCH 1/1 Fix vdso32 relocation for paddr
Hi,
`readelf -Wl file-dumped-from-/proc/self/maps-[vdso]' for x86_64 process prints:
Program Headers:
Type Offset VirtAddr PhysAddr FileSiz MemSiz Flg Align LOAD 0x000000 0xffffffffff700000 0xffffffffff700000 0x000890 0x000890 R E 0x1000 DYNAMIC 0x000410 0xffffffffff700410 0xffffffffff700410 0x0000f0 0x0000f0 R 0x8 NOTE 0x0002d0 0xffffffffff7002d0 0xffffffffff7002d0 0x00003c 0x00003c R 0x4 GNU_EH_FRAME 0x00030c 0xffffffffff70030c 0xffffffffff70030c 0x000034 0x000034 R 0x4
while such dump for i386 process prints:
Program Headers:
Type Offset VirtAddr PhysAddr FileSiz MemSiz Flg Align LOAD 0x000000 0xffffe000 0x00000000 0x00434 0x00434 R E 0x1000 DYNAMIC 0x000350 0xffffe350 0x00000350 0x00078 0x00078 R 0x4 NOTE 0x0001c4 0xffffe1c4 0x000001c4 0x00060 0x00060 R 0x4 GNU_EH_FRAME 0x000224 0xffffe224 0x00000224 0x00024 0x00024 R 0x4
The mapped location can be arbirary (according to the rules of PIC - Position Independent Code) but currently the i386 vdso (vdso32) looks as an overlayed code as it has LMA != VMA (rule contained in GDB function section_is_overlay, as suggested by Daniel Jacobowitz).
Fixed vdso32 prints:
Program Headers:
Type Offset VirtAddr PhysAddr FileSiz MemSiz Flg Align LOAD 0x000000 0xffffe000 0xffffe000 0x00434 0x00434 R E 0x1000 DYNAMIC 0x000350 0xffffe350 0xffffe350 0x00078 0x00078 R 0x4 NOTE 0x0001c4 0xffffe1c4 0xffffe1c4 0x00060 0x00060 R 0x4 GNU_EH_FRAME 0x000224 0xffffe224 0xffffe224 0x00024 0x00024 R 0x4
It required now a workaround in GDB patch so at least to fix it in Linux kernel:
http://sourceware.org/ml/gdb-patches/2009-08/msg00437.html
Thanks,
Jan
arch/x86/vdso/vdso32-setup.c renamed from arch/x86/vdso/vdso32-setup.c-orig +1 -0
@@ -172,6 +172,7 @@ static __init void relocate_vdso(Elf32_E phdr = (void *)ehdr + ehdr->e_phoff;for (i =0 ; i < ehdr->e_phnum; i++) { phdr[i].p_vaddr +=VDSO_ADDR_ADJUST ; + phdr[i].p_paddr +=VDSO_ADDR_ADJUST ;/* relocate dynamic stuff */ if (phdr[i].p_type ==PT_DYNAMIC )
Quoted 31 lines · Jan Kratochvil
Hi,
`readelf -Wl file-dumped-from-/proc/self/maps-[vdso]' for
x86_64process prints:
Program Headers:
Type Offset VirtAddr PhysAddr FileSiz MemSiz Flg Align LOAD0x0000000xffffffffff7000000xffffffffff7000000x0008900x000890R E0x1000DYNAMIC 0x0004100xffffffffff7004100xffffffffff7004100x0000f00x0000f0R0x8NOTE0x0002d00xffffffffff7002d00xffffffffff7002d00x00003c0x00003cR0x4GNU_EH_FRAME0x00030c0xffffffffff70030c0xffffffffff70030c0x0000340x000034R0x4while such dump for i386 process prints:
Program Headers:
Type Offset VirtAddr PhysAddr FileSiz MemSiz Flg Align LOAD0x0000000xffffe0000x000000000x004340x00434R E0x1000DYNAMIC 0x0003500xffffe3500x000003500x000780x00078R0x4NOTE0x0001c40xffffe1c40x000001c40x000600x00060R0x4GNU_EH_FRAME0x0002240xffffe2240x000002240x000240x00024R0x4The mapped location can be arbirary (according to the rules of PIC - Position Independent Code) but currently the i386 vdso (vdso32) looks as an overlayed code as it has LMA != VMA (rule contained in GDB function
section_is_overlay, as suggested by Daniel Jacobowitz).Fixed vdso32 prints:
Program Headers:
Type Offset VirtAddr PhysAddr FileSiz MemSiz Flg Align LOAD0x0000000xffffe0000xffffe0000x004340x00434R E0x1000DYNAMIC 0x0003500xffffe3500xffffe3500x000780x00078R0x4NOTE0x0001c40xffffe1c40xffffe1c40x000600x00060R0x4GNU_EH_FRAME0x0002240xffffe2240xffffe2240x000240x00024R0x4
Quoted 4 lines
It required now a workaround in GDB patch so at least to fix it in Linux kernel:
http://sourceware.org/ml/gdb-patches/2009-08/msg00437.html
This patch looks fine for me. But I think we should hear from Roland. Roland?
Quoted 22 lines
Thanks,
JanSigned-off-by Jan Kratochvil <[email protected]>arch/x86/vdso/vdso32-setup.c 2009-08-26 22:38:10.000000000 +0200 renamed from arch/x86/vdso/vdso32-setup.c-orig 2009-08-26 22:23:08.000000000 +0200 +1
-1@@ -172,6 +172,7 @@ static __init void relocate_vdso(Elf32_E phdr = (void *)ehdr + ehdr->e_phoff; for (i = 0; i < ehdr->e_phnum; i++) { phdr[i].p_vaddr += VDSO_ADDR_ADJUST; + phdr[i].p_paddr += VDSO_ADDR_ADJUST; /* relocate dynamic stuff */ if (phdr[i].p_type == PT_DYNAMIC) --To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
A message that is not in the archive (sent off-list or not yet received): [email protected]
Quoted 2 lines · Roland McGrath
Thanks for heads-up. It's definitely right to CC me on patches that change the build/setup vDSO details.
OK, I thought more about {p,u}trace.
Quoted 3 lines
That change seems fine. Or just explicit
p_addr=p_vaddrwould be fine too (and not assume that what the linker produced is consistent, in case some old linkers produce stranger results from the vdso linker scripts).
Updated. Verified on x86_64 host it works right for an i386 binary.
Thanks,
Jan
arch/x86/vdso/vdso32-setup.c renamed from arch/x86/vdso/vdso32-setup.c-orig +1 -0
@@ -172,6 +172,7 @@ static __init void relocate_vdso(Elf32_E phdr = (void *)ehdr + ehdr->e_phoff;for (i =0 ; i < ehdr->e_phnum; i++) { phdr[i].p_vaddr +=VDSO_ADDR_ADJUST ; + phdr[i].p_paddr = phdr[i].p_vaddr;/* relocate dynamic stuff */ if (phdr[i].p_type ==PT_DYNAMIC )
Quoted 5 lines · Roland McGrath
Quoted 2 lines
Thanks for heads-up. It's definitely right to CC me on patches that change the build/setup vDSO details.
OK, I thought more about {p,u}trace.
It so happens I'm also the vDSO and ELF-magic guru for the kernel. It's an unrelated hat.
Quoted 1 line
Updated. Verified on
x86_64host it works right for an i386 binary.
Looks good to me!
Thanks,
Roland