|
From: John C. <joh...@ta...> - 2003-12-23 00:43:04
|
Ok...
1) The reason why I'm using the bleeding edge Valgrind is I want to
use the new Full Virtualization stuff that allows non-statically
linked executables to be valgrinded. In particular ecos synthetic target
executables.
2) I have just tried Julian's suggested tweak to the linker script, it
required one or two more tweaks to get it to link. It now links
and run's outside of valgrind but under valgrind it says...
valgrind -v --leak-check=3Dyes ./MYPROG --io --nr --nw --exit
Executable is mapped outside of range 0x80d3000-0xbffff000
failed to load /usr/local/lib/valgrind/stage2: Cannot allocate memory
3) You say it may be a bug in valgrind, so I followed in gdb to the if
statement in ume.c (line 472) that decides to print the error message.
if (info->exe_base !=3D info->exe_end) {
if (minaddr >=3D maxaddr ||
=09 (minaddr < info->exe_base ||
=09 maxaddr > info->exe_end)) {
=09 fprintf(stderr, "Executable is mapped outside of range %p-%p\n",
=09=09 (void *)info->exe_base, (void *)info->exe_end);
=09 return ENOMEM;
}
}
(gdb) p/x *info
p/x *info
$6 =3D {
setbrk =3D 0x1,
map_base =3D 0xb0000000,
exe_base =3D 0x80d3000,
exe_end =3D 0xbffff000,
phdr =3D 0x8048034,
phnum =3D 0x8,
interp_base =3D 0x0,
entry =3D 0x80558f0,
init_eip =3D 0x0,
brkbase =3D 0x0,
argv0 =3D 0x0,
argv1 =3D 0x0,
argv =3D 0x0
}
(gdb) p/x minaddr
$7 =3D 0x8048000
(gdb) p/x maxaddr
$8 =3D 0x8131900
> Can you send me the the output of "readelf -hlS yourprog"? I can't
> reproduce this just by playing with the load address. Could you also
> send me your whole linker script?
4) Here it is...
ELF Header:
Magic: 7f 45 4c 46 01 01 01 00 00 00 00 00 00 00 00 00
Class: ELF32
Data: 2's complement, little endian
Version: 1 (current)
OS/ABI: UNIX - System V
ABI Version: 0
Type: EXEC (Executable file)
Machine: Intel 80386
Version: 0x1
Entry point address: 0x4000000
Start of program headers: 52 (bytes into file)
Start of section headers: 3122312 (bytes into file)
Flags: 0x0
Size of this header: 52 (bytes)
Size of program headers: 32 (bytes)
Number of program headers: 2
Size of section headers: 40 (bytes)
Number of section headers: 17
Section header string table index: 14
Section Headers:
[Nr] Name Type Addr Off Size ES Flg Lk I=
nf Al
[ 0] NULL 00000000 000000 000000 00 0 =
0 0
[ 1] .vectors PROGBITS 04000000 085fa0 000000 00 W 0 =
0 1
[ 2] .text PROGBITS 04000000 001000 06bbd1 00 AX 0 =
0 4
[ 3] .fini PROGBITS 0406bbd4 085fa0 000000 00 W 0 =
0 1
[ 4] .rodata1 PROGBITS 0406bbd8 085fa0 000000 00 W 0 =
0 1
[ 5] .rodata PROGBITS 0406bbd8 06cbd8 01759d 00 A 0 =
0 32
[ 6] .fixup PROGBITS 04083178 085fa0 000000 00 W 0 =
0 1
[ 7] .eh_frame PROGBITS 04083178 084178 000128 00 WA 0 =
0 4
[ 8] .gcc_except_table PROGBITS 040832a0 085fa0 000000 00 W 0 =
0 1
[ 9] .data PROGBITS 05000000 085000 000fa0 00 WA 0 =
0 32
[10] .sbss PROGBITS 05000fa0 085fa0 000000 00 W 0 =
0 1
[11] .bss NOBITS 05000fa0 085fa0 08fcb8 00 WA 0 =
0 32
[12] .stab PROGBITS 00000000 085fa0 109e18 0c 13 =
0 4
[13] .stabstr STRTAB 00000000 18fdb8 16a64b 00 0 =
0 1
[14] .shstrtab STRTAB 00000000 2fa403 000084 00 0 =
0 1
[15] .symtab SYMTAB 00000000 2fa730 0160d0 10 16 9=
dd 4
[16] .strtab STRTAB 00000000 310800 0293d3 00 0 =
0 1
Key to Flags:
W (write), A (alloc), X (execute), M (merge), S (strings)
I (info), L (link order), G (group), x (unknown)
O (extra OS processing required) o (OS specific), p (processor specific)
Program Headers:
Type Offset VirtAddr PhysAddr FileSiz MemSiz Flg Align
LOAD 0x001000 0x04000000 0x04000000 0x832a0 0x832a0 RWE 0x1000
LOAD 0x085000 0x05000000 0x05000000 0x00fa0 0x90c58 RW 0x1000
Section to Segment mapping:
Segment Sections...
00 .text .rodata .eh_frame
01 .data .bss
4) The linker script is basically just the eCos V2 synthetic target
script with Julian tweaks.
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
STARTUP(vectors.o)
ENTRY(_start)
INPUT(extras.o)
GROUP(libtarget.a libgcc.a libsupc++.a)
MEMORY
{
rom : ORIGIN =3D 0x4000000, LENGTH =3D 0x800000
ram : ORIGIN =3D 0x5000000, LENGTH =3D 0x800000
}
SECTIONS
{
.vectors 0x4000000 : { . =3D .; KEEP(*(.vectors)) } > rom
.text ALIGN (0x4) : { _stext =3D .; *(.text*) *(.gnu.warning) *(.gnu.li=
nkonce.t.*) *(.init) } > rom _etext =3D .; PROVIDE (etext =3D .);
.fini ALIGN (0x4) : { . =3D .; *(.fini) } > rom
.rodata1 ALIGN (0x8) : { . =3D .; *(.rodata1) } > rom
.rodata ALIGN (0x8) : { . =3D .; *(.rodata*) *(.gnu.linkonce.r.*) } > r=
om
.fixup ALIGN (0x4) : { _FIXUP_START_ =3D ABSOLUTE(.); *(.fixup) _FIXUP_=
END_ =3D ABSOLUTE(.);} > rom
.rel.text : { *(.rel.text) *(.rel.text.*) *(.rel.gnu.linkonce.t*) } > r=
om .rela.text : { *(.rela.text) *(.rela.text.*) *(.rela.gnu.linkonce.t*) } =
> rom .rel.data : { *(.rel.data) *(.rel.data.*) *(.rel.gnu.linkonce.d*) } >=
rom .rela.data : { *(.rela.data) *(.rela.data.*) *(.rela.gnu.linkonce.d*) =
} > rom .rel.rodata : { *(.rel.rodata) *(.rel.rodata.*) *(.rel.gnu.linkonce=
=2Er*) } > rom .rela.rodata : { *(.rela.rodata) *(.rela.rodata.*) *(.rela.g=
nu.linkonce.r*) } > rom .rel.got : { *(.rel.got) } > rom .rela.got : { *(.r=
ela.got) } > rom .rel.ctors : { *(.rel.ctors) } > rom .rela.ctors : { *(.re=
la.ctors) } > rom .rel.dtors : { *(.rel.dtors) } > rom .rela.dtors : { *(.r=
ela.dtors) } > rom .rel.init : { *(.rel.init) } > rom .rela.init : { *(.rel=
a.init) } > rom .rel.fini : { *(.rel.fini) } > rom .rela.fini : { *(.rela.f=
ini) } > rom .rel.bss : { *(.rel.bss) } > rom .rela.bss : { *(.rela.bss) } =
> rom .rel.plt : { *(.rel.plt) } > rom .rela.plt : { *(.rela.plt) } > rom .=
rel.dyn : { *(.rel.dyn) } > rom
.eh_frame ALIGN (0x4) : { . =3D .; __EH_FRAME_BEGIN__ =3D .; KEEP(*(.eh=
_frame)) __FRAME_END__ =3D .; . =3D . + 8; } > rom =3D 0
.rel.got ALIGN (0x1) : { *(.rel.got) } > rom
.gcc_except_table ALIGN (0x1) : { _EXCEPT_START_ =3D ABSOLUTE(.); *(.gc=
c_except_table) _EXCEPT_END_ =3D ABSOLUTE(.);} > rom
.data 0x5000000 : { __ram_data_start =3D ABSOLUTE(.); *(.data*) *(.gnu.=
linkonce.d.*) _GOT1_START_ =3D ABSOLUTE(.); *(.got1) _GOT1_END_ =3D ABSOLUT=
E(.); . =3D ALIGN(8); __CTOR_LIST__ =3D ABSOLUTE(.); KEEP(*(SORT(.ctors*)))=
__CTOR_END__ =3D ABSOLUTE(.); __DTOR_LIST__ =3D ABSOLUTE(.); KEEP(*(SORT(.=
dtors*))) __DTOR_END__ =3D ABSOLUTE(.); . =3D ALIGN(32); KEEP(*( SORT (.eco=
s.table.*))); _GOT2_START_ =3D ABSOLUTE(.); *(.got2) _GOT2_END_ =3D ABSOLUT=
E(.); _GOT_START_ =3D ABSOLUTE(.); _GLOBAL_OFFSET_TABLE_ =3D ABSOLUTE(. + 3=
2768); _SDA_BASE_ =3D ABSOLUTE(.); *(.got.plt) *(.got) _GOT_END_ =3D ABSOLU=
TE(.); *(.dynamic) _SDATA_START_ =3D ABSOLUTE(.); *(.sdata*) *(.gnu.linkonc=
e.s.*) } > ram __rom_data_start =3D LOADADDR(.data); __ram_data_end =3D .; =
PROVIDE(__ram_data_end =3D .); _edata =3D .; PROVIDE (edata =3D .);
.sbss ALIGN (0x4) : { __bss_start =3D ABSOLUTE (.); _SBSS_START_ =3D AB=
SOLUTE(.); *(.sbss*) *(.gnu.linkonce.sb.*) _SBSS_END_ =3D ABSOLUTE(.); *(.s=
common*) } > ram
.bss ALIGN (0x10) : { . =3D .; *(.dynbss*) *(.bss*) *(COMMON) *(.gnu.li=
nkonce.b.*) } > ram __bss_end =3D .;
__heap1 =3D ALIGN (0x10);
. =3D ALIGN(4); _end =3D .; PROVIDE (end =3D .);
}
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
On Mon, 22 Dec 2003, Jeremy Fitzhardinge wrote:
> On Sun, 2003-12-21 at 16:56, John Carter wrote:
> > I'm trying the latest (from about midnight UTC) version of Valgrind
> > from CVS on executable's created for eCos synthetic target.
> >
> > (eCos is a RTOS that has been ported to many platforms, including
> > i386, running on Linux. There is a "Synthetic Hal" Hardware Abstraction=
Layer
> > that just pop's out of eCos and invokes Linux system services.)
> >
> > I suspect it is because of the, umm, unusual linker script we are
> > using, but valgrind produces the following error message from ume.c
> > from the routine...
> >
> > static int load_ELF(char *hdr, int len, int fd, const char *name,
> > struct exeinfo *info)
> >
> > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D
> > Executable is mapped outside of range 0x80d3000-0xbffff000
> > failed to load /usr/local/lib/valgrind/stage2: Cannot allocate memory
> > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D
>
> Can you send me the the output of "readelf -hlS yourprog"? I can't
> reproduce this just by playing with the load address. Could you also
> send me your whole linker script?
>
> =09J
>
>
>
> -------------------------------------------------------
> This SF.net email is sponsored by: IBM Linux Tutorials.
> Become an expert in LINUX or just sharpen your skills. Sign up for IBM's
> Free Linux Tutorials. Learn everything from the bash shell to sys admin.
> Click now! http://ads.osdn.com/?ad_id=3D1278&alloc_id=3D3371&op=3Dclick
> _______________________________________________
> Valgrind-developers mailing list
> Val...@li...
> https://lists.sourceforge.net/lists/listinfo/valgrind-developers
>
John Carter Phone : (64)(3) 358 6639
Tait Electronics Fax : (64)(3) 359 4632
PO Box 1645 Christchurch Email : joh...@ta...
New Zealand
A Million Monkeys can inflict worse things than just Shakespeare on
your system.
|