|
From: Nicholas N. <nj...@ca...> - 2004-07-27 14:08:47
|
Hi, I'm making progress on x86-64; I've discovered that the calling conventions for functions and system calls are totally different than for x86... ABI documents are useful :) Anyway, I'm getting a strange error. stage1 is successfully starting stage2, but then bad things are happening. The problem is that some of the VG_(clo_*) arguments are initialised to the right values, but some of them are being initialised to totally bogus values. Here's some debugging output -- for each variable I print the name, its address, the value it is initialised to in the code, and then the actual value it gets at run-time. ---------------------------------------- stage2 main! ---------------------------------------- VG_(clo_error_limit) 0x601b03dd = True; 1 VG_(clo_db_command) 0x601b03e0 = VG_CLO_DEFAULT_DBCOMMAND; /usr/bin/gdb -nw %f %p VG_(clo_sanity_level) 0x601b03e8 = 1; 1 VG_(clo_verbosity) 0x601b03ec = 1; 1 VG_(clo_demangle) 0x601b03f0 = True; 1 VG_(clo_trace_children) 0x601bd8ae = False; 0 VG_(clo_log_fd) 0x601b03f4 = 1; 1 VG_(clo_suppressions)[] 0x602f19c0 = ?; 0x602f19c0 VG_(clo_optimise) 0x601b03f8 = True; 1 VG_(clo_trace_codegen) 0x601bd8ca = 0; // 00000000b 0 VG_(clo_trace_syscalls) 0x601bd8cb = False; 0 VG_(clo_backtrace_size) 0x601b03fc = 4; 4 VG_(clo_run_libc_freere)0x601b0400 = True; 1 VG_(clo_track_fds) 0x601bd8e0 = False; 0 VG_(clo_chain_bb) 0x601b0401 = True; 1 VG_(clo_pointercheck) 0x601b0402 = True; 1 ---- VG_(clo_db_attach) 0x601bd8ac = False; 16 VG_(clo_gen_suppression)0x601bd8ad = False; 51 VG_(clo_log_to) 0x601bd8b0 = VgLogTo_Fd; 992843285 VG_(clo_log_name) 0x601bd8b8 = NULL; 0x9715000034210758 VG_(clo_input_fd) 0x601bd8c0 = 0; /* stdin */ 15149 VG_(clo_n_suppressions) 0x601bd8c4 = 0; 124265218 VG_(clo_profile) 0x601bd8c8 = False; 209 VG_(clo_single_step) 0x601bd8c9 = False; 26 VG_(clo_trace_signals) 0x601bd8cc = False; 21 VG_(clo_trace_symtab) 0x601bd8cd = False; 164 VG_(clo_trace_sched) 0x601bd8ce = False; 203 VG_(clo_trace_pthread_level) 0x601bd8d0 = 0; 587333632 VG_(clo_dump_error) 0x601bd8d4 = 0; -1828585352 VG_(clo_weird_hacks) 0x601bd8d8 = NULL; 0xd54516000021 VG_(clo_show_below_main)0x601bd8e1 = False; 2 VG_(clo_branchpred) 0x601bd8e2 = False; 154 Those in the top half are correctly initialised to the value specified in the code. Those in the bottom half are getting bogus values. The bogus values are bogus from the very moment they are mapped into memory, in mapelf(). (I checked this with a hexdump of the just-mapped-in code in mapelf()) The interesting thing is that all the bogus ones are in one memory area around 0x601bd8a0, but most of the correct ones are in a different memory area around 0x601b03d8. (Some of the correct ones have similar addresses to the bogus ones... these are mostly meant to be 0, eg. VG_(clo_trace_children), so they are probably bogus but just getting the right value by chance.) I've used readelf to look at stage2 and the variable addresses do seem to be correct, so that's no help. I'm stumped... can anyone see what might be happening here? I'm highly suspicious of the variables being put in two different memory locations. If it's any use, the equivalent dump for x86 is below; for it the variables aren't partitioned into two different areas, and they are (not surprisingly) all correct. ---------------------------------------- stage2 main! ---------------------------------------- VG_(clo_error_limit) 0xb00826b8 = True; 1 VG_(clo_db_command) 0xb00826bc = VG_CLO_DEFAULT_DBCOMMAND; /usr/bin/gdb -nw %f %p VG_(clo_sanity_level) 0xb00826c4 = 1; 1 VG_(clo_verbosity) 0xb00826c8 = 1; 1 VG_(clo_demangle) 0xb00826cc = True; 1 VG_(clo_trace_children) 0xb00826cd = False; 0 VG_(clo_log_fd) 0xb00826d4 = 1; 1 VG_(clo_suppressions)[] 0xb01b2420 = ?; 0xb01b2420 VG_(clo_optimise) 0xb00826e6 = True; 1 VG_(clo_trace_codegen) 0xb00826e7 = 0; // 00000000b 0 VG_(clo_trace_syscalls) 0xb00826e8 = False; 0 VG_(clo_backtrace_size) 0xb00826f4 = 4; 4 VG_(clo_run_libc_freere)0xb00826fc = True; 1 VG_(clo_track_fds) 0xb00826fd = False; 0 VG_(clo_chain_bb) 0xb00826fe = True; 1 VG_(clo_pointercheck) 0xb0082700 = True; 1 ---- VG_(clo_db_attach) 0xb00826b9 = False; 0 VG_(clo_gen_suppression)0xb00826c0 = False; 0 VG_(clo_log_to) 0xb00826d0 = VgLogTo_Fd; 0 VG_(clo_log_name) 0xb00826d8 = NULL; (nil) VG_(clo_input_fd) 0xb00826dc = 0; /* stdin */ 0 VG_(clo_n_suppressions) 0xb00826e0 = 0; 0 VG_(clo_profile) 0xb00826e4 = False; 0 VG_(clo_single_step) 0xb00826e5 = False; 0 VG_(clo_trace_signals) 0xb00826e9 = False; 0 VG_(clo_trace_symtab) 0xb00826ea = False; 0 VG_(clo_trace_sched) 0xb00826eb = False; 0 VG_(clo_trace_pthread_level) 0xb00826ec = 0; 0 VG_(clo_dump_error) 0xb00826f0 = 0; 0 VG_(clo_weird_hacks) 0xb00826f8 = NULL; (nil) VG_(clo_show_below_main)0xb00826ff = False; 0 VG_(clo_branchpred) 0xb0082701 = False; 0 I can tar up my current workspace and put it on my website if that would be useful. Thanks. N |