From: Brian D. C. <bd...@ca...> - 2005-01-21 03:16:45
|
[ reposting lost message from Sat Jan 15 17:38:01 -0800 2005 ] I found that jikesrvm is not compiling its shared libraries libjpnexec and libsyswrap with the compiler options for position independent code. Apparently this is not always fatal but was fatal in my simulation environment. I am running jikesrvm from CVS at label JIKESRVM-2r3r3 on PowerPC with Yellow Dog Linux. I also use Mac OS X and linux/x86 but this problem was discovered on linux/ppc. I confirmed the problem still exists at CVS head on linux/x86. rvm runs fine out of the box on my YDL box. However, I usually run jikesrvm in out "less" PowerPC simulator. After recent simulator changes, I got a SIGSEGV when starting up JikesRVM. I used strace and gdb to investigate. The strace output is below but I'll highlight the main lines here. You can see that reading the RVM.image causes a 16k chunk to mmap for the FILE* buffer. the address is 0x310b4000 open("/Network/Servers/tcc.Stanford.EDU/Users/bdc/linux/rvmRoot/jikesrvm/build/RVM.image", O_RDONLY) = 10 fstat64(10, {st_mode=S_IFREG|0644, st_size=14567712, ...}) = 0 mmap(NULL, 16384, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x310b4000 then JikesRVM maps space for the image at 0x31000000, which overlaps with the 16k chunk mapped at 0x310b4000 mmap(0x31000000, 14569472, PROT_READ|PROT_WRITE|PROT_EXEC, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x31000000 when the file is closed the FILE* buffer is unmapepd munmap(0x310b4000, 16384) = 0 then in sys.C we get a SEGV when this loop hits 0x310b4000 /* update storage */ /* Note: if one knew the cache line size, one could write a better loop */ for (addr=start; addr < end; ++addr) asm("dcbst 0,%0" : : "r" (addr) ); no problem right? I just bump the BOOTIMAGE_LOAD_ADDRESS from 0x31000000 to 0x31000000 in my config: export BOOTIMAGE_LOAD_ADDRESS=0x32000000 "rvm" still runs fine outside without the simulator. However, now when I run in the simulator I get: JikesRVM: error loading library /Network/Servers/tcc.Stanford.EDU/Users/bdc/linux/rvmRoot/jikesrvm/build/libjpnexec.so: /Network/Servers/tcc.Stanford.EDU/Users/bdc/linux/rvmRoot/jikesrvm/build/libjpnexec.so: R_PPC_REL24 relocation at 0x0f87930c for symbol _assert_fail' out of range Well, thanks to google, I found that the ELF PPC relocation type R_PPC_REL24 really shouldn't be found in shared libraries. I checked with "objdump -R $RVM_BUILD/*.so" and all the classpath shared libraries are fine but not the ones built by jikesrvm. Fortunately simply adding -fPIC to my config fixes this problem. I checked at CVS head and the problem seems to exist on linux/x86 as well with "objdump -R" showing relocation records with types R_386_32 and R_386_PC32 that aren't present in the classpath files. I've attached a patch to CVS head for this issue for linux/x86, linux/ppc, and macosx. On Mac OS X I could not use "objdump -R" to test since it doesn't work well Mach-O files, but I added -fno-common matching what classpath does. The patch also includes a one line linux/x86 compilation fix that was necessary on my box (glibc-2.3.3 kernel 2.6.9) -bri -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- open("/Network/Servers/tcc.Stanford.EDU/Users/bdc/linux/rvmRoot/jikesrvm/build/RVM.image", O_RDONLY) = 10 fstat64(10, {st_mode=S_IFREG|0644, st_size=14567712, ...}) = 0 mmap(NULL, 16384, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x310b4000 fstat64(10, {st_mode=S_IFREG|0644, st_size=14567712, ...}) = 0 _llseek(10, 14565376, [14565376], SEEK_SET) = 0 read(10, "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., 2336) = 2336 _llseek(10, 0, [0], SEEK_SET) = 0 mmap(0x31000000, 14569472, PROT_READ|PROT_WRITE|PROT_EXEC, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x31000000 read(10, "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., 14565376) = 14565376 read(10, "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., 16384) = 2336 close(10) = 0 munmap(0x310b4000, 16384) = 0 sigaltstack({ss_sp=0x168de478, ss_flags=0, ss_size=16384}, NULL) = 0 rt_sigaction(SIGSEGV, {0x1000620c, ~[CONT RTMIN], SA_STACK|SA_RESTART|SA_SIGINFO}, NULL, 8) = 0 rt_sigaction(SIGTRAP, {0x1000620c, ~[CONT RTMIN], SA_STACK|SA_RESTART|SA_SIGINFO}, NULL, 8) = 0 rt_sigaction(SIGILL, {0x1000620c, ~[CONT RTMIN], SA_STACK|SA_RESTART|SA_SIGINFO}, NULL, 8) = 0 rt_sigaction(SIGALRM, {0x10006a8c, ~[CONT RTMIN], SA_STACK|SA_RESTART|SA_SIGINFO}, NULL, 8) = 0 rt_sigaction(SIGHUP, {0x10006a8c, ~[CONT RTMIN], SA_STACK|SA_RESTART|SA_SIGINFO}, NULL, 8) = 0 rt_sigaction(SIGQUIT, {0x10006a8c, ~[CONT RTMIN], SA_STACK|SA_RESTART|SA_SIGINFO}, NULL, 8) = 0 rt_sigaction(SIGTERM, {0x10006a8c, ~[CONT RTMIN], SA_STACK|SA_RESTART|SA_SIGINFO}, NULL, 8) = 0 rt_sigaction(SIGPIPE, {SIG_IGN}, NULL, 8) = 0 --- SIGSEGV (Segmentation fault) @ 0 (0) --- --- SIGSEGV (Segmentation fault) @ 0 (0) --- +++ killed by SIGSEGV +++ -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- zot:~/rvmRoot/jikesrvm $ cvs diff -c Index: rvm/config/i686-pc-linux-gnu =================================================================== RCS file: /usr/cvs/jikesrvm/rvm/config/i686-pc-linux-gnu,v retrieving revision 1.50 diff -c -r1.50 i686-pc-linux-gnu *** rvm/config/i686-pc-linux-gnu 19 Dec 2004 22:48:49 -0000 1.50 --- rvm/config/i686-pc-linux-gnu 16 Jan 2005 01:26:03 -0000 *************** *** 163,173 **** ## preprocessor macros. # export CC="/usr/bin/gcc -pipe -ggdb3 -O -W -Wall -Wbad-function-cast -Wcast-align -Wpointer-arith -Wcast-qual -Wshadow -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations -fkeep-static-consts -fkeep-inline-functions -Wwrite-strings -Wno-aggregate-return -Wmissing-noreturn -Wnested-externs -Wtrigraphs -Wconversion -Wsign-compare -Wno-float-equal -Wmissing-format-attribute -Wno-unreachable-code -Wdisabled-optimization" ! export CC="gcc -w -pipe -ggdb3 -O" ## What C++ compiler should be used? # export CPLUS='/usr/bin/g++ -pipe -ggdb3 -W -Wall -Wcast-align -Wpointer-arith -Wcast-qual -Wshadow -Wstrict-prototypes -Wmissing-prototypes -fkeep-static-consts -fkeep-inline-functions -Wwrite-strings -Wno-aggregate-return -Wmissing-noreturn -Wtrigraphs -Wconversion -Wsign-compare -Wno-float-equal -Wmissing-format-attribute -Wno-unreachable-code -Wdisabled-optimization -fcheck-new -fpermissive -Wctor-dtor-privacy -Wnon-virtual-dtor -Wreorder -Woverloaded-virtual -Wsign-promo -O' ! export CPLUS="g++ -w -pipe -ggdb3 -O" # how to link a shared C++ library (possibly also recompile one --- 163,173 ---- ## preprocessor macros. # export CC="/usr/bin/gcc -pipe -ggdb3 -O -W -Wall -Wbad-function-cast -Wcast-align -Wpointer-arith -Wcast-qual -Wshadow -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations -fkeep-static-consts -fkeep-inline-functions -Wwrite-strings -Wno-aggregate-return -Wmissing-noreturn -Wnested-externs -Wtrigraphs -Wconversion -Wsign-compare -Wno-float-equal -Wmissing-format-attribute -Wno-unreachable-code -Wdisabled-optimization" ! export CC="gcc -w -pipe -ggdb3 -O -fPIC" ## What C++ compiler should be used? # export CPLUS='/usr/bin/g++ -pipe -ggdb3 -W -Wall -Wcast-align -Wpointer-arith -Wcast-qual -Wshadow -Wstrict-prototypes -Wmissing-prototypes -fkeep-static-consts -fkeep-inline-functions -Wwrite-strings -Wno-aggregate-return -Wmissing-noreturn -Wtrigraphs -Wconversion -Wsign-compare -Wno-float-equal -Wmissing-format-attribute -Wno-unreachable-code -Wdisabled-optimization -fcheck-new -fpermissive -Wctor-dtor-privacy -Wnon-virtual-dtor -Wreorder -Woverloaded-virtual -Wsign-promo -O' ! export CPLUS="g++ -w -pipe -ggdb3 -O -fPIC" # how to link a shared C++ library (possibly also recompile one Index: rvm/config/powerpc-unknown-linux-gnu =================================================================== RCS file: /usr/cvs/jikesrvm/rvm/config/powerpc-unknown-linux-gnu,v retrieving revision 1.27 diff -c -r1.27 powerpc-unknown-linux-gnu *** rvm/config/powerpc-unknown-linux-gnu 8 Jul 2004 11:09:30 -0000 1.27 --- rvm/config/powerpc-unknown-linux-gnu 16 Jan 2005 01:26:03 -0000 *************** *** 64,73 **** export JIKES=/usr/bin/jikes # what C compilers should be used? ! export CC="/usr/bin/gcc -w -g -O -Wa,-mppc" # what C++ compilers should be used? ! export CPLUS='/usr/bin/g++ -w -g -O' # how to link a shared C++ library export LDSHARED="${CPLUS} -shared" --- 64,73 ---- export JIKES=/usr/bin/jikes # what C compilers should be used? ! export CC="/usr/bin/gcc -w -g -O -Wa,-mppc -fPIC" # what C++ compilers should be used? ! export CPLUS='/usr/bin/g++ -w -g -O -fPIC' # how to link a shared C++ library export LDSHARED="${CPLUS} -shared" Index: rvm/config/powerpc-unknown-osx-gnu =================================================================== RCS file: /usr/cvs/jikesrvm/rvm/config/powerpc-unknown-osx-gnu,v retrieving revision 1.4 diff -c -r1.4 powerpc-unknown-osx-gnu *** rvm/config/powerpc-unknown-osx-gnu 17 Dec 2004 18:34:53 -0000 1.4 --- rvm/config/powerpc-unknown-osx-gnu 16 Jan 2005 01:26:03 -0000 *************** *** 60,72 **** export JIKES=/usr/local/bin/jikes # v 1.18 # what C compilers should be used? ! export CC="/usr/bin/gcc -w -O" # what C++ compilers should be used? ! export CPLUS="/usr/bin/g++" # how to link a shared C++ library ! export LDSHARED="/usr/bin/g++ -dynamiclib" # used by the jbuild.linkBooter export CPP=/usr/bin/cpp --- 60,72 ---- export JIKES=/usr/local/bin/jikes # v 1.18 # what C compilers should be used? ! export CC="/usr/bin/gcc -w -O -fno-common" # what C++ compilers should be used? ! export CPLUS="/usr/bin/g++ -fno-common" # how to link a shared C++ library ! export LDSHARED="${CPLUS} -dynamiclib" # used by the jbuild.linkBooter export CPP=/usr/bin/cpp Index: rvm/src/tools/bootImageRunner/sys.C =================================================================== RCS file: /usr/cvs/jikesrvm/rvm/src/tools/bootImageRunner/sys.C,v retrieving revision 1.103 diff -c -r1.103 sys.C *** rvm/src/tools/bootImageRunner/sys.C 18 Dec 2004 00:54:13 -0000 1.103 --- rvm/src/tools/bootImageRunner/sys.C 16 Jan 2005 01:26:04 -0000 *************** *** 44,50 **** #include <sys/stat.h> #include <sys/sysinfo.h> #include <netinet/in.h> - #include <linux/net.h> #include <signal.h> #include <sys/ioctl.h> #include <asm/ioctls.h> --- 44,49 ---- -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- |