DynamoRIO / dynamorio

Dynamic Instrumentation Tool Platform
Other
2.62k stars 554 forks source link

Add support for gcc 6 #1958

Open clarkb7 opened 8 years ago

clarkb7 commented 8 years ago

gcc 6 changed some things around, notably:

This issue will keep track of fixes needed to get DR compiling with gcc 6

https://gcc.gnu.org/gcc-6/changes.html

derekbruening commented 7 years ago

Xref https://groups.google.com/forum/#!topic/dynamorio-users/ylQUmvi6tTg

[ 50%] Linking C executable bin/security-common.selfmod-big
/usr/bin/ld: CMakeFiles/security-common.selfmod-big.dir/selfmod-big.c_asm.asm.o: relocation R_X86_64_32S against undefined symbol `big' can not be used when making a shared object; recompile with -fPIC
/usr/bin/ld: final link failed: Nonrepresentable section on output
collect2: error: ld returned 1 exit status
egrimley commented 7 years ago

Currently (d747cc1) DynamoRIO works on ARM and AArch64 with GCC 6.3.0 (Debian Stretch).

Also, there's a "gcc621" system on CDash (http://dynamorio.org/CDash/viewSite.php?siteid=13&project=1&currenttime=1489366800) so with any luck it won't get broken again by accident.

derekbruening commented 6 years ago

Xref #2020, #1820 on c++11 support in DR

derekbruening commented 6 years ago

I recently upgraded to gcc 6.3.0 and I'm hitting issues referenced here and in #2737:

FAILED: suite/tests/bin/client.drutil-test 
/usr/bin/ld: suite/tests/CMakeFiles/client.drutil-test.dir/client-interface/drutil-test.c.o: relocation R_X86_64_32 against `.data' can not be used when making a shared object; recompile with -fPIC

FAILED: suite/tests/bin/client.signal 
/usr/bin/ld: suite/tests/CMakeFiles/client.signal.dir/client-interface/signal.c.o: relocation R_X86_64_32S against `.bss' can not be used when making a shared object; recompile with -fPIC

FAILED: suite/tests/bin/client.drmgr-test 
/usr/bin/ld: suite/tests/CMakeFiles/client.drmgr-test.dir/client-interface/drmgr-test.c.o: relocation R_X86_64_32 against `.data' can not be used when making a shared object; recompile with -fPIC

FAILED: suite/tests/bin/linux.fib-static 
/usr/lib/gcc/x86_64-linux-gnu/6/../../../x86_64-linux-gnu/libc.a(memmove.o): In function `__memmove_sse2_unaligned':
(.text+0xf0): multiple definition of `memcpy'
lib64/libdrhelper.a(x86_shared.asm.o):/home/bruening/dr/git/src/core/arch/x86/x86_shared.asm:470: first defined here

FAILED: suite/tests/bin/common.decode 
/usr/bin/ld: suite/tests/CMakeFiles/common.decode.dir/decode.c_asm.asm.o: relocation R_X86_64_32S against undefined symbol `mark' can not be used when making a shared object; recompile with -fPIC

FAILED: suite/tests/bin/security-common.selfmod-big 
/usr/bin/ld: suite/tests/CMakeFiles/security-common.selfmod-big.dir/selfmod-big.c_asm.asm.o: relocation R_X86_64_32S against undefined symbol `big' can not be used when making a shared object; recompile with -fPIC
fhahn commented 6 years ago

I think recent versions of ld have become stricter with relocations on X86. Most likely we should compile the the tests with -fPIC?

egrimley commented 6 years ago

I think the problems are caused by (inline) assembler code, which presumably should be rewritten to resemble what the compiler generates with -fPIC.

derekbruening commented 6 years ago

Yes, I also believe it's asm, which we have seen before and had to make it PIC manually. The hard part is finding the asm: this collection of tests that fail to link don't seem to have much in common and don't have their own asm so they must be referencing certain routines in libtools.a or sthg.

derekbruening commented 6 years ago

This is blocking me so I'm assigning it to myself.

derekbruening commented 6 years ago

I take it back: these tests do have their own asm and it is clear where the issues are, so far.

derekbruening commented 6 years ago

After fixing the build issues I'm seeing test failures:

The following tests FAILED:
     21 - code_api|common.nativeexec_exe (Failed)
     22 - code_api|common.nativeexec_bindnow (Failed)
     24 - code_api|common.nativeexec_exe_opt (Failed)
     25 - code_api|common.nativeexec_bindnow_opt (Failed)
     67 - code_api|linux.sigcontext (Failed)
    183 - code_api|client.pcache-use (Failed)
    276 - code_api|api.static_sideline_FLAKY (Failed)
Errors while running CTest

The last 2 may be flaky but I'm pretty sure the nativeexec ones are new and probably specific to gcc 6.x.