Open GoogleCodeExporter opened 9 years ago
I don't understand why ld is reporting that it is making a shared library, it
should be linking hello.o into an executable. Can you try adding "-fPIC" to
the gcc options in builder/llvm/Native.cc? After "args.push_back("-O3");" add
args.push_back("-fPIC");
Handing this off to Shannon in case he has any insights.
Original comment by mind...@gmail.com
on 16 Aug 2012 at 12:01
$ ./crackc -v hello.crk
Generating file:
hello.o
Generating Native Executable With:
/usr/bin/gcc -O3 -fPIC -m64 -o hello hello.o -Wl,--add-needed -L.
-Wl,-rpath=/mnt/md3/cache/inst/crack-language/build -L/usr/local/lib/crack-0.6
-Wl,-rpath=/usr/local/lib64/crack-0.6 -L/usr/local/lib/crack-0.6/crack
-Wl,-rpath=/usr/local/lib64/crack-0.6/crack
/usr/local/lib/crack-0.6/crack/runtime.so -lCrackNativeRuntime
/usr/lib/gcc/x86_64-pc-linux-gnu/4.6.4/../../../../x86_64-pc-linux-gnu/bin/ld:
hello.o: relocation R_X86_64_32 against `.builtin.VTableBase_3A_body' can not
be used when making a shared object; recompile with -fPIC
hello.o: could not read symbols: Bad value
collect2: ld returned 1 exit status
Original comment by wbr...@gmail.com
on 16 Aug 2012 at 12:30
I guess hello.o (not hello) should be compiled with -fPIE -pie
-fvisibility=hidden
Original comment by wbr...@gmail.com
on 16 Aug 2012 at 1:02
example of building of C program
$ gcc -O2 -v ./1.c -o 1
Using built-in specs.
COLLECT_GCC=/usr/x86_64-pc-linux-gnu/gcc-bin/4.7.2/gcc
COLLECT_LTO_WRAPPER=/usr/libexec/gcc/x86_64-pc-linux-gnu/4.7.2/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with:
/mnt/md3/cache/portage/sys-devel/gcc-4.7.2/work/gcc-4.7-20120804/configure
--prefix=/usr --bindir=/usr/x86_64-pc-linux-gnu/gcc-bin/4.7.2
--includedir=/usr/lib/gcc/x86_64-pc-linux-gnu/4.7.2/include
--datadir=/usr/share/gcc-data/x86_64-pc-linux-gnu/4.7.2
--mandir=/usr/share/gcc-data/x86_64-pc-linux-gnu/4.7.2/man
--infodir=/usr/share/gcc-data/x86_64-pc-linux-gnu/4.7.2/info
--with-gxx-include-dir=/usr/lib/gcc/x86_64-pc-linux-gnu/4.7.2/include/g++-v4
--host=x86_64-pc-linux-gnu --build=x86_64-pc-linux-gnu --disable-altivec
--disable-fixed-point --without-ppl --without-cloog --enable-lto --disable-nls
--with-system-zlib --enable-obsolete --disable-werror --enable-secureplt
--enable-multilib --with-multilib-list=m32,m64 --with-arch=core2
--with-tune=core2 --disable-plugin --disable-libmudflap --disable-libssp
--enable-esp --disable-libgomp
--with-python-dir=/share/gcc-data/x86_64-pc-linux-gnu/4.7.2/python
--enable-checking=release --disable-libgcj --disable-libquadmath
--enable-languages=c,c++ --enable-shared --enable-threads=posix
--enable-__cxa_atexit --enable-clocale=gnu --enable-targets=all
--with-bugurl=http://bugs.gentoo.org/ --with-pkgversion='Gentoo Hardened 4.7.2
p1.2, pie-0.5.3'
Thread model: posix
gcc version 4.7.2 20120804 (prerelease) (Gentoo Hardened 4.7.2 p1.2, pie-0.5.3)
COLLECT_GCC_OPTIONS='-O2' '-v' '-o' '1' '-mtune=core2' '-march=core2' '-fPIE'
'-fvisibility=hidden' '-pie'
/usr/libexec/gcc/x86_64-pc-linux-gnu/4.7.2/cc1 -quiet -v ./1.c -fno-strict-overflow -quiet -dumpbase 1.c -mtune=core2 -march=core2 -auxbase 1 -O2 -version -fPIE -fvisibility=hidden -fstack-protector-all -o /tmp/ccJ9o6QM.s
GNU C (Gentoo Hardened 4.7.2 p1.2, pie-0.5.3) version 4.7.2 20120804
(prerelease) (x86_64-pc-linux-gnu)
compiled by GNU C version 4.7.2 20120804 (prerelease), GMP version 5.0.5, MPFR version 3.1.1, MPC version 0.9
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
ignoring nonexistent directory
"/usr/lib/gcc/x86_64-pc-linux-gnu/4.7.2/../../../../x86_64-pc-linux-gnu/include"
#include "..." search starts here:
#include <...> search starts here:
/usr/lib/gcc/x86_64-pc-linux-gnu/4.7.2/include
/usr/local/include
/usr/lib/gcc/x86_64-pc-linux-gnu/4.7.2/include-fixed
/usr/include
End of search list.
GNU C (Gentoo Hardened 4.7.2 p1.2, pie-0.5.3) version 4.7.2 20120804
(prerelease) (x86_64-pc-linux-gnu)
compiled by GNU C version 4.7.2 20120804 (prerelease), GMP version 5.0.5, MPFR version 3.1.1, MPC version 0.9
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
Compiler executable checksum: 46fa11a2283ab2708cb037abf6b5babb
COLLECT_GCC_OPTIONS='-O2' '-v' '-o' '1' '-mtune=core2' '-march=core2' '-fPIE'
'-fvisibility=hidden' '-pie'
/usr/lib/gcc/x86_64-pc-linux-gnu/4.7.2/../../../../x86_64-pc-linux-gnu/bin/as -v --64 -o /tmp/ccCKi8Xj.o /tmp/ccJ9o6QM.s
GNU assembler version 2.22.90 (x86_64-pc-linux-gnu) using BFD version (GNU
Binutils) 2.22.90.20120727
COMPILER_PATH=/usr/libexec/gcc/x86_64-pc-linux-gnu/4.7.2/:/usr/libexec/gcc/x86_6
4-pc-linux-gnu/4.7.2/:/usr/libexec/gcc/x86_64-pc-linux-gnu/:/usr/lib/gcc/x86_64-
pc-linux-gnu/4.7.2/:/usr/lib/gcc/x86_64-pc-linux-gnu/:/usr/lib/gcc/x86_64-pc-lin
ux-gnu/4.7.2/../../../../x86_64-pc-linux-gnu/bin/
LIBRARY_PATH=/usr/lib/gcc/x86_64-pc-linux-gnu/4.7.2/:/usr/lib/gcc/x86_64-pc-linu
x-gnu/4.7.2/../../../../lib64/:/lib/../lib64/:/usr/lib/../lib64/:/usr/lib/gcc/x8
6_64-pc-linux-gnu/4.7.2/../../../../x86_64-pc-linux-gnu/lib/:/usr/lib/gcc/x86_64
-pc-linux-gnu/4.7.2/../../../:/lib/:/usr/lib/
COLLECT_GCC_OPTIONS='-O2' '-v' '-o' '1' '-mtune=core2' '-march=core2' '-fPIE'
'-fvisibility=hidden' '-pie'
/usr/libexec/gcc/x86_64-pc-linux-gnu/4.7.2/collect2 --eh-frame-hdr -m elf_x86_64 -dynamic-linker /lib64/ld-linux-x86-64.so.2 -pie -z now -o 1 /usr/lib/gcc/x86_64-pc-linux-gnu/4.7.2/../../../../lib64/Scrt1.o /usr/lib/gcc/x86_64-pc-linux-gnu/4.7.2/../../../../lib64/crti.o /usr/lib/gcc/x86_64-pc-linux-gnu/4.7.2/crtbeginS.o -L/usr/lib/gcc/x86_64-pc-linux-gnu/4.7.2 -L/usr/lib/gcc/x86_64-pc-linux-gnu/4.7.2/../../../../lib64 -L/lib/../lib64 -L/usr/lib/../lib64 -L/usr/lib/gcc/x86_64-pc-linux-gnu/4.7.2/../../../../x86_64-pc-linux-gnu/lib -L/usr/lib/gcc/x86_64-pc-linux-gnu/4.7.2/../../.. /tmp/ccCKi8Xj.o -lgcc --as-needed -lgcc_s --no-as-needed -lc -lgcc --as-needed -lgcc_s --no-as-needed /usr/lib/gcc/x86_64-pc-linux-gnu/4.7.2/crtendS.o /usr/lib/gcc/x86_64-pc-linux-gnu/4.7.2/../../../../lib64/crtn.o
Original comment by wbr...@gmail.com
on 16 Aug 2012 at 1:11
Does adding those options ("-fPIE -pie -fvisibility=hidden") to
builder/llvm/Native.cc produce a successful build?
Original comment by mind...@gmail.com
on 16 Aug 2012 at 1:21
No. It seems those options are used only during linking. It should be used also
during compiling.
Original comment by wbr...@gmail.com
on 16 Aug 2012 at 1:32
wbrana, there is support in LLVM for creating position independent executables,
so this should be possible. I'll get a builder option in so you can try it out.
Original comment by weyrick
on 16 Aug 2012 at 6:06
please try r1723 and let me know
Original comment by weyrick
on 20 Aug 2012 at 7:41
$ crackc -v -b PIE=1 hello.crk
Generating file:
hello.o
Generating Native Executable With:
/usr/lib/ccache/bin/gcc -O3 -fPIC -m64 -o hello hello.o -Wl,--add-needed -L.
-Wl,-rpath=/mnt/md3/cache/inst/crack-language/example
-L/usr/local/lib/crack-0.6 -Wl,-rpath=/usr/local/lib64/crack-0.6
-L/usr/local/lib/crack-0.6/crack -Wl,-rpath=/usr/local/lib64/crack-0.6/crack
/usr/local/lib/crack-0.6/crack/runtime.so -lCrackNativeRuntime
/usr/lib/gcc/x86_64-pc-linux-gnu/4.6.4/../../../../x86_64-pc-linux-gnu/bin/ld:
hello.o: relocation R_X86_64_32 against `.builtin.VTableBase_3A_body' can not
be used when making a shared object; recompile with -fPIC
hello.o: could not read symbols: Bad value
collect2: ld returned 1 exit status
Original comment by wbr...@gmail.com
on 20 Aug 2012 at 8:03
You should be able to test it on your PC if you add "-pie" to link flags.
Original comment by wbr...@gmail.com
on 20 Aug 2012 at 9:51
Please try r1724, it now works for me.
Original comment by weyrick
on 21 Aug 2012 at 2:35
It compiles, but crashing at runtime
GNU gdb (Gentoo 7.5 p1) 7.5
Copyright (C) 2012 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law. Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-pc-linux-gnu".
For bug reporting instructions, please see:
<http://bugs.gentoo.org/>...
Reading symbols from /mnt/md3/cache/inst/crack-language/example/hello...(no
debugging symbols found)...done.
(gdb) r
Starting program: /mnt/md3/cache/inst/crack-language/example/hello
Program received signal SIGSEGV, Segmentation fault.
0x00000073e77d5655 in crack.lang.Object.oper_20_bind ()
(gdb) bt
#0 0x00000073e77d5655 in crack.lang.Object.oper_20_bind ()
#1 0x00000073e77dad0f in crack.io.FDWriter._iface_getWriterObject ()
#2 0x00000073eb7004e0 in ?? ()
#3 0x00000073e77d5b23 in crack.lang.Writer.oper_20_bind ()
#4 0x00000073e77db6ea in crack.io.StandardFormatter.oper_20_init ()
#5 0x00000073e77db74c in crack.io.StandardFormatter.oper_20_new ()
#6 0x00000073e77da7ab in crack.io_3A_main ()
#7 0x00000073e77dce22 in
.main._00871da86a5e706b8e176fe45b0d155f_5fhello_2ecrk_3A_main ()
#8 0x00000073e77dcee8 in main ()
Original comment by wbr...@gmail.com
on 21 Aug 2012 at 2:51
Can you reproduce crash or do you need more info?
Original comment by wbr...@gmail.com
on 22 Aug 2012 at 5:42
Yes, I can reproduce. However, I'm not likely to pursue this further for the
time being, as we have other priorities before a 1.0 release. We'll leave the
bug open, and feel free to work on it yourself, we can provide guidance.
Original comment by weyrick
on 22 Aug 2012 at 5:59
could you add "--no-pie" to default link flags when PIE=1 isn't used as
workaround until PIE=1 will be fixed
Original comment by wbr...@gmail.com
on 30 Aug 2012 at 12:41
I think this is probably fine, I would just want to confirm this won't break
builds for linkers that don't understand that parameter. Do you know if that's
the case?
Original comment by weyrick
on 30 Aug 2012 at 2:16
someone will create new issue if build will be broken
Original comment by wbr...@gmail.com
on 30 Aug 2012 at 2:26
I'm not sure I'm comfortable pushing that in as a default just now. But it
should be trivial to change for your testing purposes for now: just an else
block added around line 95 in Native.cc.
I wonder if this isn't better solved by us adding the contents of LDFLAGS to
the link.
Original comment by weyrick
on 30 Aug 2012 at 6:49
Original issue reported on code.google.com by
wbr...@gmail.com
on 15 Aug 2012 at 8:44