2013-04-05 81 views
4

我将Valgrind编译为openwrt x86平台。在目标上运行时不会检测到任何泄漏。在Ubuntu上,它工作正常。交叉编译Valgrind没有检测到明显的泄漏

我的测试程序简单

main() 
{ 
    char *p = malloc(10000); 

    *(p-1) = 1; 
} 

相关编辑步骤

i486-openwrt-linux-uclibc-gcc -c -o leak.o -pipe -march=i486 -fhonour-copts -I/home/r2/external/openwrt/staging_dir/target-i386_uClibc-0.9.30.1/usr/include -I/home/r2/external/openwrt/staging_dir/target-i386_uClibc-0.9.30.1/include -I/home/r2/external/openwrt/staging_dir/toolchain-i386_gcc-4.1.2_uClibc-0.9.30.1/include -O0 -g -I. -Idbus -I/home/r2/external/openwrt/staging_dir/target-i386_uClibc-0.9.30.1/usr/include leak.c 
leak.c: In function 'main': 
leak.c:3: warning: incompatible implicit declaration of built-in function 'malloc' 
    CC leak.c 
i486-openwrt-linux-uclibc-gcc leak.o -L/hom e/r2/external/openwrt/staging_dir/target-i386_uClibc-0.9.30.1/usr/lib -L/home/r2/external/openwrt/staging_dir/target-i386_uClibc-0.9.30.1/lib -L/home/r2/external/openwrt/staging_dir/toolchain-i386_gcc-4.1.2_uClibc-0.9.30.1/lib -o leak 
    LD leak 

它不是静态链接。 objdump的确认

objdump -x build_dir/target-i386_uClibc-0.9.30.1/test/leak 

build_dir/target-i386_uClibc-0.9.30.1/test/leak:  file format elf32-i386 
build_dir/target-i386_uClibc-0.9.30.1/test/leak 
architecture: i386, flags 0x00000112: 
EXEC_P, HAS_SYMS, D_PAGED 
start address 0x08048340 

Program Header: 
    PHDR off 0x00000034 vaddr 0x08048034 paddr 0x08048034 align 2**2 
     filesz 0x000000c0 memsz 0x000000c0 flags r-x 
    INTERP off 0x000000f4 vaddr 0x080480f4 paddr 0x080480f4 align 2**0 
     filesz 0x00000014 memsz 0x00000014 flags r-- 
    LOAD off 0x00000000 vaddr 0x08048000 paddr 0x08048000 align 2**12 
     filesz 0x000004ac memsz 0x000004ac flags r-x 
    LOAD off 0x000004ac vaddr 0x080494ac paddr 0x080494ac align 2**12 
     filesz 0x000000f4 memsz 0x00000110 flags rw- 
DYNAMIC off 0x000004c0 vaddr 0x080494c0 paddr 0x080494c0 align 2**2 
     filesz 0x000000b8 memsz 0x000000b8 flags rw- 
    STACK off 0x00000000 vaddr 0x00000000 paddr 0x00000000 align 2**2 
     filesz 0x00000000 memsz 0x00000000 flags rw- 

Dynamic Section: 
    NEEDED    libgcc_s.so.1 
    NEEDED    libc.so.0 
    INIT     0x080482d4 
    FINI     0x08048490 
    HASH     0x08048108 
    STRTAB    0x080481e4 
    SYMTAB    0x08048144 
    STRSZ    0x0000009c 
    SYMENT    0x00000010 
    DEBUG    0x00000000 
    PLTGOT    0x08049578 
    PLTRELSZ    0x00000020 
    PLTREL    0x00000011 
    JMPREL    0x080482b4 
    VERNEED    0x08048294 
    VERNEEDNUM   0x00000001 
    VERSYM    0x08048280 

Version References: 
    required from libgcc_s.so.1: 
    0x0b792650 0x00 02 GCC_3.0 

Sections: 
Idx Name   Size  VMA  LMA  File off Algn 
    0 .interp  00000014 080480f4 080480f4 000000f4 2**0 
        CONTENTS, ALLOC, LOAD, READONLY, DATA 
    1 .hash   0000003c 08048108 08048108 00000108 2**2 
        CONTENTS, ALLOC, LOAD, READONLY, DATA 
    2 .dynsym  000000a0 08048144 08048144 00000144 2**2 
        CONTENTS, ALLOC, LOAD, READONLY, DATA 
    3 .dynstr  0000009c 080481e4 080481e4 000001e4 2**0 
        CONTENTS, ALLOC, LOAD, READONLY, DATA 
    4 .gnu.version 00000014 08048280 08048280 00000280 2**1 
        CONTENTS, ALLOC, LOAD, READONLY, DATA 
    5 .gnu.version_r 00000020 08048294 08048294 00000294 2**2 
        CONTENTS, ALLOC, LOAD, READONLY, DATA 
    6 .rel.plt  00000020 080482b4 080482b4 000002b4 2**2 
        CONTENTS, ALLOC, LOAD, READONLY, DATA 
    7 .init   0000001c 080482d4 080482d4 000002d4 2**0 
        CONTENTS, ALLOC, LOAD, READONLY, CODE 
    8 .plt   00000050 080482f0 080482f0 000002f0 2**2 
        CONTENTS, ALLOC, LOAD, READONLY, CODE 
    9 .text   00000150 08048340 08048340 00000340 2**4 
        CONTENTS, ALLOC, LOAD, READONLY, CODE 
10 .fini   00000017 08048490 08048490 00000490 2**0 
        CONTENTS, ALLOC, LOAD, READONLY, CODE 
11 .eh_frame  00000004 080484a8 080484a8 000004a8 2**2 
        CONTENTS, ALLOC, LOAD, READONLY, DATA 
12 .ctors  00000008 080494ac 080494ac 000004ac 2**2 
        CONTENTS, ALLOC, LOAD, DATA 
13 .dtors  00000008 080494b4 080494b4 000004b4 2**2 
        CONTENTS, ALLOC, LOAD, DATA 
14 .jcr   00000004 080494bc 080494bc 000004bc 2**2 
        CONTENTS, ALLOC, LOAD, DATA 
15 .dynamic  000000b8 080494c0 080494c0 000004c0 2**2 
        CONTENTS, ALLOC, LOAD, DATA 
16 .got.plt  0000001c 08049578 08049578 00000578 2**2 
        CONTENTS, ALLOC, LOAD, DATA 
17 .data   0000000c 08049594 08049594 00000594 2**2 
        CONTENTS, ALLOC, LOAD, DATA 
18 .bss   0000001c 080495a0 080495a0 000005a0 2**2 
        ALLOC 
19 .comment  00000036 00000000 00000000 000005a0 2**0 
        CONTENTS, READONLY 
20 .debug_aranges 00000020 00000000 00000000 000005d6 2**0 
        CONTENTS, READONLY, DEBUGGING 
21 .debug_pubnames 0000001b 00000000 00000000 000005f6 2**0 
        CONTENTS, READONLY, DEBUGGING 
22 .debug_info 000000b1 00000000 00000000 00000611 2**0 
        CONTENTS, READONLY, DEBUGGING 
23 .debug_abbrev 0000004e 00000000 00000000 000006c2 2**0 
        CONTENTS, READONLY, DEBUGGING 
24 .debug_line 00000039 00000000 00000000 00000710 2**0 
        CONTENTS, READONLY, DEBUGGING 
25 .debug_frame 00000058 00000000 00000000 0000074c 2**2 
        CONTENTS, READONLY, DEBUGGING 
26 .debug_loc 00000043 00000000 00000000 000007a4 2**0 
        CONTENTS, READONLY, DEBUGGING 
SYMBOL TABLE: 
080480f4 l d .interp 00000000    .interp 
08048108 l d .hash 00000000    .hash 
08048144 l d .dynsym 00000000    .dynsym 
080481e4 l d .dynstr 00000000    .dynstr 
08048280 l d .gnu.version 00000000    .gnu.version 
08048294 l d .gnu.version_r 00000000    .gnu.version_r 
080482b4 l d .rel.plt 00000000    .rel.plt 
080482d4 l d .init 00000000    .init 
080482f0 l d .plt 00000000    .plt 
08048340 l d .text 00000000    .text 
08048490 l d .fini 00000000    .fini 
080484a8 l d .eh_frame 00000000    .eh_frame 
080494ac l d .ctors 00000000    .ctors 
080494b4 l d .dtors 00000000    .dtors 
080494bc l d .jcr 00000000    .jcr 
080494c0 l d .dynamic 00000000    .dynamic 
08049578 l d .got.plt 00000000    .got.plt 
08049594 l d .data 00000000    .data 
080495a0 l d .bss 00000000    .bss 
00000000 l d .comment 00000000    .comment 
00000000 l d .debug_aranges 00000000    .debug_aranges 
00000000 l d .debug_pubnames 00000000    .debug_pubnames 
00000000 l d .debug_info 00000000    .debug_info 
00000000 l d .debug_abbrev 00000000    .debug_abbrev 
00000000 l d .debug_line 00000000    .debug_line 
00000000 l d .debug_frame 00000000    .debug_frame 
00000000 l d .debug_loc 00000000    .debug_loc 
00000000 l df *ABS* 00000000    crtstuff.c 
080494ac l  O .ctors 00000000    __CTOR_LIST__ 
080494b4 l  O .dtors 00000000    __DTOR_LIST__ 
080484a8 l  O .eh_frame 00000000    __EH_FRAME_BEGIN__ 
080494bc l  O .jcr 00000000    __JCR_LIST__ 
080495a0 l  O .bss 00000001    completed.2431 
0804959c l  O .data 00000000    p.2429 
08048370 l  F .text 00000000    __do_global_dtors_aux 
080495a4 l  O .bss 00000018    object.2483 
080483d0 l  F .text 00000000    frame_dummy 
00000000 l df *ABS* 00000000    crtstuff.c 
080494b0 l  O .ctors 00000000    __CTOR_END__ 
080494b8 l  O .dtors 00000000    __DTOR_END__ 
080484a8 l  O .eh_frame 00000000    __FRAME_END__ 
080494bc l  O .jcr 00000000    __JCR_END__ 
08048460 l  F .text 00000000    __do_global_ctors_aux 
00000000 l df *ABS* 00000000    initfini.c 
00000000 l df *ABS* 00000000    leak.c 
080494c0 l  O .dynamic 00000000    .hidden _DYNAMIC 
08049598 l  O .data 00000000    .hidden __dso_handle 
08049578 l  O .got.plt 00000000    .hidden _GLOBAL_OFFSET_TABLE_ 
00000000  F *UND* 00000000    malloc 
08048310 w F *UND* 00000000    [email protected]@GCC_3.0 
080482d4 g  F .init 00000000    _init 
08048340 g  F .text 00000022    _start 
00000000  F *UND* 00000000    __uClibc_main 
080495a0 g  *ABS* 00000000    __bss_start 
08048424 g  F .text 00000033    main 
08048330 w F *UND* 00000000    [email protected]@GCC_3.0 
08049594 w  .data 00000000    data_start 
08048490 g  F .fini 00000000    _fini 
08048364 g  F .text 00000000    .hidden __get_pc_thunk_bx 
080495a0 g  *ABS* 00000000    _edata 
080495bc g  *ABS* 00000000    _end 
08049594 g  .data 00000000    __data_start 
00000000 w  *UND* 00000000    _Jv_RegisterClasses 

这里是关于目标86板Valgrind的输出

valgrind --leak-check=full -v -d -d -d -d -d ./leak 
--5221:1:debuglog DebugLog system started by Stage 1, level 5 logging requested 
--5221:1:launcher no tool requested, defaulting to 'memcheck' 
--5221:2:launcher selecting platform for './leak' 
--5221:2:launcher selecting platform for './leak' 
--5221:2:launcher opened './leak' 
--5221:2:launcher read 4096 bytes from './leak' 
--5221:2:launcher selected platform 'x86-linux' 
--5221:1:launcher selected platform 'x86-linux' 
--5221:1:launcher launching /usr/lib/valgrind/memcheck-x86-linux 
--5221:1:debuglog DebugLog system started by Stage 2 (main), level 5 logging requested 
--5221:1:main  Welcome to Valgrind version 3.8.0 debug logging 
--5221:1:main  Checking current stack is plausible 
--5221:1:main  Checking initial stack was noted 
--5221:1:main  Starting the address space manager 
--5221:2:aspacem   sp_at_startup = 0x00bfafb800 (supplied) 
--5221:2:aspacem     minAddr = 0x0004000000 (computed) 
--5221:2:aspacem     maxAddr = 0x00bfafafff (computed) 
--5221:2:aspacem     cStart = 0x0004000000 (computed) 
--5221:2:aspacem     vStart = 0x0061d7e000 (computed) 
--5221:2:aspacem suggested_clstack_top = 0x00beafbfff (computed) 
--5221:2:aspacem <<< SHOW_SEGMENTS: Initial layout (5 segments, 0 segnames) 
--5221:2:aspacem  0: RSVN 0000000000-0003ffffff  64m ----- SmFixed 
--5221:2:aspacem  1:  0004000000-0061d7dfff 1501m 
--5221:2:aspacem  2: RSVN 0061d7e000-0061d7efff 4096 ----- SmFixed 
--5221:2:aspacem  3:  0061d7f000-00bfafafff 1501m 
--5221:2:aspacem  4: RSVN 00bfafb000-00ffffffff 1029m ----- SmFixed 
--5221:2:aspacem >>> 
--5221:2:aspacem Reading /proc/self/maps 
--5221:2:aspacem <<< SHOW_SEGMENTS: With contents of /proc/self/maps (12 segments, 1 segnames) 
--5221:2:aspacem (0) /usr/lib/valgrind/memcheck-x86-linux 
--5221:2:aspacem  0: RSVN 0000000000-0003ffffff  64m ----- SmFixed 
--5221:2:aspacem  1:  0004000000-0037ffffff 832m 
--5221:2:aspacem  2: FILE 0038000000-0038288fff 2658304 r-x-- d=0x803 i=33422 o=4096 (0) 
--5221:2:aspacem  3: FILE 0038289000-003828afff 8192 rw--- d=0x803 i=33422 o=2658304 (0) 
--5221:2:aspacem  4: ANON 003828b000-0038d20fff  10m rw--- 
--5221:2:aspacem  5:  0038d21000-0061d7dfff 656m 
--5221:2:aspacem  6: RSVN 0061d7e000-0061d7efff 4096 ----- SmFixed 
--5221:2:aspacem  7:  0061d7f000-00bfae7fff 1501m 
--5221:2:aspacem  8: ANON 00bfae8000-00bfafcfff 86016 rw--- 
--5221:2:aspacem  9: RSVN 00bfafd000-00ffffdfff 1029m ----- SmFixed 
--5221:2:aspacem  10: ANON 00ffffe000-00ffffefff 4096 r-x-- 
--5221:2:aspacem  11: RSVN 00fffff000-00ffffffff 4096 ----- SmFixed 
--5221:2:aspacem >>> 
--5221:1:main  Address space manager is running 
--5221:1:main  Starting the dynamic memory manager 
--5221:1:mallocfr newSuperblock at 0x61D7F000 (pszB 4194288) owner VALGRIND/tool 
--5221:1:mallocfr deferred_reclaimSuperblock at 0x61D7F000 (pszB 4194288) (prev 0x0) owner VALGRIND/tool 
--5221:1:main  Dynamic memory manager is running 
--5221:1:main  Initialise m_debuginfo 
--5221:1:main  VG_(libdir) = /usr/lib/valgrind 
--5221:1:main  Getting launcher's name ... 
--5221:1:main  ... /usr/bin/valgrind 
--5221:1:main  Get hardware capabilities ... 
--5221:1:main  ... arch = X86, hwcaps = x86-sse1-sse2 
--5221:1:main  Getting the working directory at startup 
--5221:1:main  ... /root 
--5221:1:main  Split up command line 
--5221:1:main  (early_) Process Valgrind's command line options 
--5221:1:main  Create initial image 
--5221:1:initimg Loading client 
--5221:1:initimg Setup client env 
--5221:2:initimg preload_string: 
--5221:2:initimg  "/usr/lib/valgrind/vgpreload_core-x86-linux.so:/usr/lib/valgrind/vgpreload_memcheck-x86-linux.so" 
--5221:1:initimg Setup client stack: size will be 16777216 
--5221:2:initimg Client info: initial_IP=0x40008B4 initial_TOC=0x0 brk_base=0x804A000 
--5221:2:initimg Client info: initial_SP=0xBEAFBD80 max_stack_size=16777216 
--5221:1:initimg Setup client data (brk) segment 
--5221:1:main  Setup file descriptors 
--5221:1:main  Create fake /proc/<pid>/cmdline 
--5221:1:main  Initialise the tool part 1 (pre_clo_init) 
--5221:1:mallocfr deferred_reclaimSuperblock NULL (prev 0x61D7F000) owner VALGRIND/tool 
--5221:1:mallocfr newSuperblock at 0x6217F000 (pszB 1048560) owner VALGRIND/exectxt 
--5221:1:main  Print help and quit, if requested 
--5221:1:main  (main_) Process Valgrind's command line options, setup logging 
--5221:1:mallocfr newSuperblock at 0x6227F000 (pszB 1048560) owner VALGRIND/core 
--5221:1:main  Print the preamble... 
==5221== Memcheck, a memory error detector 
==5221== Copyright (C) 2002-2012, and GNU GPL'd, by Julian Seward et al. 
==5221== Using Valgrind-3.8.0 and LibVEX; rerun with -h for copyright info 
==5221== Command: ./leak 
==5221== 
--5221-- Valgrind options: 
--5221-- --leak-check=full 
--5221-- -v 
--5221-- -d 
--5221-- -d 
--5221-- -d 
--5221-- -d 
--5221-- -d 
--5221-- Contents of /proc/version: 
--5221-- Linux version 2.6.32.27 (rame[email protected]) (gcc version 4.1.2) #16 Mon Apr 1 15:37:49 PDT 2013 
--5221-- Arch and hwcaps: X86, x86-sse1-sse2 
--5221-- Page sizes: currently 4096, max supported 4096 
--5221-- Valgrind library directory: /usr/lib/valgrind 
--5221:1:main  ...finished the preamble 
--5221:1:main  Initialise the tool part 2 (post_clo_init) 
--5221:1:main  Initialise TT/TC 
--5221:2:transtab cache: 8 sectors of 27597024 bytes each = 220776192 total 
--5221:2:transtab table: 524168 total entries, max occupancy 340704 (65%) 
--5221:1:main  Initialise redirects 
--5221:1:mallocfr newSuperblock at 0x623FA000 (pszB 1048560) owner VALGRIND/dinfo 
--5221:1:main  Load initial debug info 
--5221-- Reading syms from /root/leak 
--5221:1:redir transfer ownership V -> C of 0x3803d000 .. 0x3803dfff 
--5221:1:main  Initialise scheduler (phase 1) 
--5221:1:sched sched_init_phase1 
--5221-- Scheduler: using generic scheduler lock implementation. 
--5221:1:main  Tell tool about initial permissions 
--5221:2:main  tell tool about 0004000000-0004003fff r-x 
--5221:2:main  tell tool about 0004004000-0004005fff rw- 
--5221:2:main  tell tool about 0008048000-0008048fff r-x 
--5221:2:main  tell tool about 0008049000-0008049fff rw- 
--5221:2:main  tell tool about 000804a000-000804afff rwx 
--5221:2:main  tell tool about 003803d000-003803dfff r-x 
--5221:2:main  tell tool about 00beafb000-00beafbfff rwx 
--5221:2:main  mark stack inaccessible 00beafb000-00beafbd7f 
--5221:1:main  Initialise scheduler (phase 2) 
--5221:1:sched sched_init_phase2: tid_main=1, cls_end=0xbeafbfff, cls_sz=16777216 
--5221:1:main  Finalise initial image 
--5221:1:main  Initialise signal management 
--5221:1:main  Load suppressions 
--5221-- Reading suppressions file: /usr/lib/valgrind/default.supp 
--5221:2:stacks  register 0xBEAFB000-0xBEAFBFFF as stack 0 
--5221:1:main  
--5221:1:main  
--5221:1:aspacem <<< SHOW_SEGMENTS: Memory layout at client startup (25 segments, 3 segnames) 
--5221:1:aspacem (0) /usr/lib/valgrind/memcheck-x86-linux 
--5221:1:aspacem (1) /root/leak 
--5221:1:aspacem (2) /lib/ld-uClibc-0.9.30.1.so 
--5221:1:aspacem 0: RSVN 0000000000-0003ffffff  64m ----- SmFixed 
--5221:1:aspacem 1: file 0004000000-0004003fff 16384 r-x-- d=0x803 i=86  o=0  (2) 
--5221:1:aspacem 2: file 0004004000-0004005fff 8192 rw--- d=0x803 i=86  o=12288 (2) 
--5221:1:aspacem 3:  0004006000-0008047fff  64m 
--5221:1:aspacem 4: file 0008048000-0008048fff 4096 r-x-- d=0x803 i=33471 o=0  (1) 
--5221:1:aspacem 5: file 0008049000-0008049fff 4096 rw--- d=0x803 i=33471 o=0  (1) 
--5221:1:aspacem 6: anon 000804a000-000804afff 4096 rwx-- 
--5221:1:aspacem 7: RSVN 000804b000-0008849fff 8384512 ----- SmLower 
--5221:1:aspacem 8:  000884a000-0037ffffff 759m 
--5221:1:aspacem 9: FILE 0038000000-003803cfff 249856 r-x-- d=0x803 i=33422 o=4096 (0) 
--5221:1:aspacem 10: file 003803d000-003803dfff 4096 r-x-- d=0x803 i=33422 o=253952 (0) 
--5221:1:aspacem 11: FILE 003803e000-0038288fff 2404352 r-x-- d=0x803 i=33422 o=258048 (0) 
--5221:1:aspacem 12: FILE 0038289000-003828afff 8192 rw--- d=0x803 i=33422 o=2658304 (0) 
--5221:1:aspacem 13: ANON 003828b000-0038d20fff  10m rw--- 
--5221:1:aspacem 14:  0038d21000-0061d7dfff 656m 
--5221:1:aspacem 15: RSVN 0061d7e000-0061d7efff 4096 ----- SmFixed 
--5221:1:aspacem 16: ANON 0061d7f000-0062509fff 7909376 rwx-- 
--5221:1:aspacem 17:  006250a000-00bdafbfff 1461m 
--5221:1:aspacem 18: RSVN 00bdafc000-00beafafff  15m ----- SmUpper 
--5221:1:aspacem 19: anon 00beafb000-00beafbfff 4096 rwx-- 
--5221:1:aspacem 20:  00beafc000-00bfae7fff  15m 
--5221:1:aspacem 21: ANON 00bfae8000-00bfafcfff 86016 rw--- 
--5221:1:aspacem 22: RSVN 00bfafd000-00ffffdfff 1029m ----- SmFixed 
--5221:1:aspacem 23: ANON 00ffffe000-00ffffefff 4096 r-x-- 
--5221:1:aspacem 24: RSVN 00fffff000-00ffffffff 4096 ----- SmFixed 
--5221:1:aspacem >>> 
--5221:1:main  
--5221:1:main  
--5221:1:main  Running thread 1 
--5221:1:syswrap- entering VG_(main_thread_wrapper_NORETURN) 
--5221:1:aspacem allocated thread stack at 0x6250a000 size 1064960 
--5221:1:syswrap- run_a_thread_NORETURN(tid=1): pre-thread_wrapper 
--5221:1:syswrap- thread_wrapper(tid=1): entry 
--5221:1:gdbsrv entering call_gdbserver init_reason ... pid 5221 tid 1 status VgTs_Runnable sched_jmpbuf_valid 0 
--5221:1:gdbsrv gdbserver_init gdbserver embedded in valgrind: gdbserver protocol box extracted from gdb 6.6 
==5221== embedded gdbserver: reading from /tmp/vgdb-pipe-from-vgdb-to-5221-by-root-on-??? 
==5221== embedded gdbserver: writing to /tmp/vgdb-pipe-to-vgdb-from-5221-by-root-on-??? 
==5221== embedded gdbserver: shared mem /tmp/vgdb-pipe-shared-mem-vgdb-5221-by-root-on-??? 
==5221== 
==5221== TO CONTROL THIS PROCESS USING vgdb (which you probably 
==5221== don't want to do, unless you know exactly what you're doing, 
==5221== or are doing some strange experiment): 
==5221== /usr/lib/valgrind/../../bin/vgdb --pid=5221 ...command... 
==5221== 
==5221== TO DEBUG THIS PROCESS USING GDB: start GDB like this 
==5221== /path/to/gdb ./leak 
==5221== and then give GDB the following command 
==5221== target remote | /usr/lib/valgrind/../../bin/vgdb --pid=5221 
==5221== --pid is optional if only one valgrind process is running 
==5221== 
--5221:1:gdbsrv Opening read side /tmp/vgdb-pipe-from-vgdb-to-5221-by-root-on-??? 
--5221:1:gdbsrv result fd 3 
--5221:1:gdbsrv result safe_fd 1019 
--5221:1:transtab allocate sector 0 
--5221:1:mallocfr newSuperblock at 0x64AE1000 (pszB 65520) owner VALGRIND/ttaux 
--5221:1:mallocfr newSuperblock at 0x64AF1000 (pszB 65520) owner VALGRIND/errors 
--5221:1:signals extending a stack base 0xbeafb000 down by 4096 
--5221:2:stacks  change stack 0 from 0xBEAFB000-0xBEAFBFFF to 0xBEAFA000-0xBEAFBFFF 
--5221:1:syswrap- thread_wrapper(tid=1): exit 
--5221:1:syswrap- run_a_thread_NORETURN(tid=1): post-thread_wrapper 
--5221:1:syswrap- run_a_thread_NORETURN(tid=1): last one standing 
--5221:1:main  entering VG_(shutdown_actions_NORETURN) 
--5221:1:aspacem <<< SHOW_SEGMENTS: Memory layout at client shutdown (43 segments, 8 segnames) 
--5221:1:aspacem (0) /usr/lib/valgrind/memcheck-x86-linux 
--5221:1:aspacem (1) /root/leak 
--5221:1:aspacem (2) /lib/ld-uClibc-0.9.30.1.so 
--5221:1:aspacem (3) /tmp/vgdb-pipe-shared-mem-vgdb-5221-by-root-on-??? 
--5221:1:aspacem (4) /usr/lib/valgrind/vgpreload_core-x86-linux.so 
--5221:1:aspacem (5) /usr/lib/valgrind/vgpreload_memcheck-x86-linux.so 
--5221:1:aspacem (6) /lib/libgcc_s.so.1 
--5221:1:aspacem (7) /lib/libuClibc-0.9.30.1.so 
--5221:1:aspacem 0: RSVN 0000000000-0003ffffff  64m ----- SmFixed 
--5221:1:aspacem 1: file 0004000000-0004003fff 16384 r-xT- d=0x803 i=86  o=0  (2) 
--5221:1:aspacem 2: file 0004004000-0004004fff 4096 r---- d=0x803 i=86  o=12288 (2) 
--5221:1:aspacem 3: file 0004005000-0004005fff 4096 rw--- d=0x803 i=86  o=16384 (2) 
--5221:1:aspacem 4: anon 0004006000-0004006fff 4096 rw--- 
--5221:1:aspacem 5:  0004007000-0004007fff 4096 
--5221:1:aspacem 6: file 0004008000-0004008fff 4096 r-xT- d=0x803 i=33412 o=0  (4) 
--5221:1:aspacem 7: file 0004009000-0004009fff 4096 rw--- d=0x803 i=33412 o=0  (4) 
--5221:1:aspacem 8: file 000400a000-0004012fff 36864 r-xT- d=0x803 i=33423 o=0  (5) 
--5221:1:aspacem 9: file 0004013000-0004013fff 4096 rw--- d=0x803 i=33423 o=32768 (5) 
--5221:1:aspacem 10: file 0004014000-000401dfff 40960 r-xT- d=0x803 i=338  o=0  (6) 
--5221:1:aspacem 11: file 000401e000-000401efff 4096 rw--- d=0x803 i=338  o=36864 (6) 
--5221:1:aspacem 12: file 000401f000-0004064fff 286720 r-xT- d=0x803 i=135  o=0  (7) 
--5221:1:aspacem 13: file 0004065000-0004065fff 4096 r---- d=0x803 i=135  o=282624 (7) 
--5221:1:aspacem 14: file 0004066000-0004066fff 4096 rw--- d=0x803 i=135  o=286720 (7) 
--5221:1:aspacem 15: anon 0004067000-000406bfff 20480 rw--- 
--5221:1:aspacem 16:  000406c000-0008047fff  63m 
--5221:1:aspacem 17: file 0008048000-0008048fff 4096 r-xT- d=0x803 i=33471 o=0  (1) 
--5221:1:aspacem 18: file 0008049000-0008049fff 4096 rw--- d=0x803 i=33471 o=0  (1) 
--5221:1:aspacem 19: anon 000804a000-000804cfff 12288 rwx-- 
--5221:1:aspacem 20: RSVN 000804d000-0008849fff 8376320 ----- SmLower 
--5221:1:aspacem 21:  000884a000-0037ffffff 759m 
--5221:1:aspacem 22: FILE 0038000000-003803cfff 249856 r-x-- d=0x803 i=33422 o=4096 (0) 
--5221:1:aspacem 23: file 003803d000-003803dfff 4096 r-x-- d=0x803 i=33422 o=253952 (0) 
--5221:1:aspacem 24: FILE 003803e000-0038288fff 2404352 r-x-- d=0x803 i=33422 o=258048 (0) 
--5221:1:aspacem 25: FILE 0038289000-003828afff 8192 rw--- d=0x803 i=33422 o=2658304 (0) 
--5221:1:aspacem 26: ANON 003828b000-0038d20fff  10m rw--- 
--5221:1:aspacem 27:  0038d21000-0061d7dfff 656m 
--5221:1:aspacem 28: RSVN 0061d7e000-0061d7efff 4096 ----- SmFixed 
--5221:1:aspacem 29: ANON 0061d7f000-0062509fff 7909376 rwx-- 
--5221:1:aspacem 30: ANON 006250a000-006250bfff 8192 ----- 
--5221:1:aspacem 31: ANON 006250c000-006260bfff 1048576 rwx-- 
--5221:1:aspacem 32: ANON 006260c000-006260dfff 8192 ----- 
--5221:1:aspacem 33: FILE 006260e000-006260efff 4096 rw--- d=0x00b i=8236 o=0  (3) 
--5221:1:aspacem 34: ANON 006260f000-0064b08fff  36m rwx-- 
--5221:1:aspacem 35:  0064b09000-00bdafbfff 1423m 
--5221:1:aspacem 36: RSVN 00bdafc000-00beaf9fff  15m ----- SmUpper 
--5221:1:aspacem 37: anon 00beafa000-00beafbfff 8192 rwx-- 
--5221:1:aspacem 38:  00beafc000-00bfae7fff  15m 
--5221:1:aspacem 39: ANON 00bfae8000-00bfafcfff 86016 rw--- 
--5221:1:aspacem 40: RSVN 00bfafd000-00ffffdfff 1029m ----- SmFixed 
--5221:1:aspacem 41: ANON 00ffffe000-00ffffefff 4096 r-x-- 
--5221:1:aspacem 42: RSVN 00fffff000-00ffffffff 4096 ----- SmFixed 
--5221:1:aspacem >>> 
==5221== 
==5221== HEAP SUMMARY: 
==5221==  in use at exit: 0 bytes in 0 blocks 
==5221== total heap usage: 0 allocs, 0 frees, 0 bytes allocated 
==5221== 
==5221== All heap blocks were freed -- no leaks are possible 
==5221== 
==5221== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 1 from 1) 
--5221-- 
--5221-- used_suppression:  1 ld(Cond) 
==5221== 
==5221== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 1 from 1) 
--5221:1:gdbsrv remote_finish (reason orderly_finish) 1019 -1 
--5221:1:gdbsrv unlinking 
    /tmp/vgdb-pipe-from-vgdb-to-5221-by-root-on-??? 
    /tmp/vgdb-pipe-to-vgdb-from-5221-by-root-on-??? 
    /tmp/vgdb-pipe-shared-mem-vgdb-5221-by-root-on-??? 
--5221:1:core_os VG_(terminate_NORETURN)(tid=1) 

回答

7

事实证明的OpenWrt条所有库包括的valgrind的vgpreload_xxxxxx.so库和libc.so.但是,valgrind需要.so文件中的节标题和符号。我禁用了libc和valgrind软件包的剥离,然后一切都像魅力一样工作。它花了一些时间来研究valgrind代码,以了解真正发生了什么。我希望有一些警告或valgrind的错误,如果它找不到REDIR的任何符号。本来会救我3天。哦,不管怎样,我学到了一些新东西。