Bug 377066 - Some Valgrind unit tests fail to compile on Ubuntu 16.10 with PIE enabled by default
Summary: Some Valgrind unit tests fail to compile on Ubuntu 16.10 with PIE enabled by ...
Status: RESOLVED FIXED
Alias: None
Product: valgrind
Classification: Developer tools
Component: general (other bugs)
Version First Reported In: 3.13 SVN
Platform: Compiled Sources Linux
: NOR major
Target Milestone: ---
Assignee: Ivo Raisr
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2017-03-01 15:37 UTC by Ivo Raisr
Modified: 2017-05-10 05:44 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed/Implemented In:
Sentry Crash Report:


Attachments
proposed patch (3.94 KB, patch)
2017-05-07 15:59 UTC, Ivo Raisr
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Ivo Raisr 2017-03-01 15:37:12 UTC
Ubuntu 16.10 on amd64 comes with gcc 6.2 with PIE (position independent executable) enabled by default. See Ubuntu wiki [1] for more details.

Because of this, the following unit tests fail to compile:
Making check in memcheck
Making check in .
Making check in tests
Making check in .
Making check in amd64
/usr/bin/ld: fxsave-amd64.o: relocation R_X86_64_32S against symbol `vecZ' 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
/usr/bin/ld: shr_edx.o: relocation R_X86_64_32S against undefined symbol `data' 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
Making check in linux
Making check in amd64-linux
/usr/bin/ld: defcfaexpr.o: relocation R_X86_64_32 against `.text' can not be used when making a shared object; recompile with -fPIC
/usr/bin/ld: defcfaexpr.o: relocation R_X86_64_PC32 against symbol `malloc@@GLIBC_2.2.5' can not be used when making a shared object; recompile with -fPIC
/usr/bin/ld: final link failed: Bad value
collect2: error: ld returned 1 exit status
Making check in none
Making check in .
Making check in tests
Making check in .
Making check in amd64
/usr/bin/ld: cmpxchg.o: relocation R_X86_64_32S against undefined symbol `rax' 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
/usr/bin/ld: sbbmisc.o: relocation R_X86_64_32S against undefined symbol `in_b' 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
/usr/bin/ld: fcmovnu.o: relocation R_X86_64_32S against undefined symbol `zzz' 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
/usr/bin/ld: fxtract-fxtract.o: relocation R_X86_64_32S against undefined symbol `arg' 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
/usr/bin/ld: looper.o: relocation R_X86_64_32S against symbol `arg' 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
/usr/bin/ld: jrcxz.o: relocation R_X86_64_32S against undefined symbol `arg64' 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
/usr/bin/ld: shrld.o: relocation R_X86_64_32S against undefined symbol `data' 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
Making check in exp-bbv
Making check in .
Making check in tests
Making check in .
Making all in .
Making all in amd64-linux
Making check in amd64-linux
/usr/bin/ld: rep_prefix.o: relocation R_X86_64_32S against `.bss' 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
/usr/bin/ld: fldcw_check.o: relocation R_X86_64_32S against `.data' 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
/usr/bin/ld: complex_rep.o: relocation R_X86_64_32S against `.bss' 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
/usr/bin/ld: clone_test.o: relocation R_X86_64_32S against `.bss' 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
/usr/bin/ld: ll.o: relocation R_X86_64_32 against `.data' 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

A workaround is to pass CFLAGS="-no-pie" to configure.
However this needs to be fixed.


[1] https://wiki.ubuntu.com/SecurityTeam/PIE
Comment 1 Ivo Raisr 2017-05-07 15:59:08 UTC
Created attachment 105379 [details]
proposed patch
Comment 2 Ivo Raisr 2017-05-07 18:43:51 UTC
Attached patch has been successfully tested on amd64/Linux (Ubuntu) and amd64/Solaris. That means on a system where gcc produces PIE by default and on a system where gcc does not produce PIE by default.
Comment 3 Ivo Raisr 2017-05-10 05:44:02 UTC
Committed in Valgrind SVN as r16349.