Compile error "recompile with -fPIC"

3,036 views
Skip to first unread message

mike

unread,
Jun 20, 2017, 5:59:02 AM6/20/17
to Jailhouse
To learn about jailhouse I'm trying to compile jailhouse on a ubuntu 17.04 machine and I'm getting the link error

LD /home/mike/jailhouse/jailhouse/tools/jailhouse
/usr/bin/ld: /home/mike/jailhouse/jailhouse/tools/jailhouse.o: relocation R_X86_64_32 against `.rodata.str1.1' 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
/home/mike/jailhouse/jailhouse/tools/Makefile:60: recipe for target '/home/mike/jailhouse/jailhouse/tools/jailhouse' failed
make[3]: *** [/home/mike/jailhouse/jailhouse/tools/jailhouse] Error 1
scripts/Makefile.build:567: recipe for target '/home/mike/jailhouse/jailhouse/tools' failed
make[2]: *** [/home/mike/jailhouse/jailhouse/tools] Error 2
Makefile:1524: recipe for target '_module_/home/mike/jailhouse/jailhouse' failed
make[1]: *** [_module_/home/mike/jailhouse/jailhouse] Error 2
Makefile:36: recipe for target 'modules' failed
make: *** [modules] Error 2

Any suggestions how to solve this error?
Thanks,
mike

Henning Schild

unread,
Jun 20, 2017, 6:42:44 AM6/20/17
to mike, Jailhouse
Am Tue, 20 Jun 2017 02:59:02 -0700
schrieb mike <diede...@gmail.com>:

> To learn about jailhouse I'm trying to compile jailhouse on a ubuntu
> 17.04 machine and I'm getting the link error

Maybe try an older compiler, which version is your gcc? You can
probably install something older and compile jailhouse with that
i.e
"make CC=gcc-6"

Henning

mike

unread,
Jun 20, 2017, 6:54:11 AM6/20/17
to Jailhouse
Henning, thanks for the hint.

make "CC=gcc-6"
gives the same error.
My installed compiler version is
mike@ubuntu1704ssd:~/jailhouse/jailhouse$ gcc --version
gcc (Ubuntu 6.3.0-12ubuntu2) 6.3.0 20170406

I also tried to build the tagged versions v0.7 and v0.6 and I'm getting the same error. So I think it's a problem with my local configuration/installation.

Any other advise?
Regards,
mike


On Tuesday, June 20, 2017 at 12:42:44 PM UTC+2, Henning Schild wrote:
> Am Tue, 20 Jun 2017 02:59:02 -0700

> schrieb mike:

Henning Schild

unread,
Jun 20, 2017, 7:07:56 AM6/20/17
to mike, Jailhouse
Am Tue, 20 Jun 2017 03:54:10 -0700
schrieb mike <diede...@gmail.com>:

> Henning, thanks for the hint.
>
> make "CC=gcc-6"
> gives the same error.
> My installed compiler version is
> mike@ubuntu1704ssd:~/jailhouse/jailhouse$ gcc --version
> gcc (Ubuntu 6.3.0-12ubuntu2) 6.3.0 20170406

Well because your default is 6 anyways, try 5 or 4.9 in that case. I
will try to reproduce it. gcc-6.3 works on debian just fine. Just to
make sure you are on x86_64?

Henning

mike

unread,
Jun 20, 2017, 7:36:15 AM6/20/17
to Jailhouse, diede...@gmail.com, henning...@siemens.com
Henning,
i installed gcc-5 with the same results:

mike@ubuntu1704ssd:~/jailhouse/jailhouse$ sudo apt-get install gcc-5
mike@ubuntu1704ssd:~/jailhouse/jailhouse$ make CC=gcc-5

LD /home/mike/jailhouse/jailhouse/tools/jailhouse
/usr/bin/ld: /home/mike/jailhouse/jailhouse/tools/jailhouse.o: relocation R_X86_64_32 against `.rodata.str1.1' 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
/home/mike/jailhouse/jailhouse/tools/Makefile:60: recipe for target '/home/mike/jailhouse/jailhouse/tools/jailhouse' failed
make[3]: *** [/home/mike/jailhouse/jailhouse/tools/jailhouse] Error 1
scripts/Makefile.build:567: recipe for target '/home/mike/jailhouse/jailhouse/tools' failed
make[2]: *** [/home/mike/jailhouse/jailhouse/tools] Error 2
Makefile:1524: recipe for target '_module_/home/mike/jailhouse/jailhouse' failed
make[1]: *** [_module_/home/mike/jailhouse/jailhouse] Error 2
Makefile:36: recipe for target 'modules' failed
make: *** [modules] Error 2

My system is an intel core-i7 processor:

mike@ubuntu1704ssd:~/jailhouse/jailhouse$ uname -a
Linux ubuntu1704ssd 4.10.0-19-generic #21-Ubuntu SMP Thu Apr 6 17:04:57 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux

mike@ubuntu1704ssd:~/jailhouse/jailhouse$ lscpu
Architecture: x86_64
CPU op-mode(s): 32-bit, 64-bit
Byte Order: Little Endian
CPU(s): 8
On-line CPU(s) list: 0-7
Thread(s) per core: 2
Core(s) per socket: 4
Socket(s): 1
NUMA node(s): 1
Vendor ID: GenuineIntel
CPU family: 6
Model: 30
Model name: Intel(R) Core(TM) i7 CPU 860 @ 2.80GHz
Stepping: 5
CPU MHz: 2000.000
CPU max MHz: 2800,0000
CPU min MHz: 1200,0000
BogoMIPS: 5617.26
Virtualization: VT-x
L1d cache: 32K
L1i cache: 32K
L2 cache: 256K
L3 cache: 8192K
NUMA node0 CPU(s): 0-7
Flags: fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx rdtscp lm constant_tsc arch_perfmon pebs bts rep_good nopl xtopology nonstop_tsc aperfmperf pni dtes64 monitor ds_cpl vmx smx est tm2 ssse3 cx16 xtpr pdcm sse4_1 sse4_2 popcnt lahf_lm tpr_shadow vnmi flexpriority ept vpid dtherm ida

Regards,
mike

Henning Schild

unread,
Jun 20, 2017, 11:12:59 AM6/20/17
to mike, Jailhouse
Am Tue, 20 Jun 2017 04:36:14 -0700
schrieb mike <diede...@gmail.com>:

> Henning,
> i installed gcc-5 with the same results:
>
> mike@ubuntu1704ssd:~/jailhouse/jailhouse$ sudo apt-get install gcc-5
> mike@ubuntu1704ssd:~/jailhouse/jailhouse$ make CC=gcc-5
>
> LD /home/mike/jailhouse/jailhouse/tools/jailhouse
> /usr/bin/ld: /home/mike/jailhouse/jailhouse/tools/jailhouse.o:
> relocation R_X86_64_32 against `.rodata.str1.1' 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 /home/mike/jailhouse/jailhouse/tools/Makefile:60: recipe for
> target '/home/mike/jailhouse/jailhouse/tools/jailhouse' failed
> make[3]: *** [/home/mike/jailhouse/jailhouse/tools/jailhouse] Error 1
> scripts/Makefile.build:567: recipe for target
> '/home/mike/jailhouse/jailhouse/tools' failed make[2]: ***
> [/home/mike/jailhouse/jailhouse/tools] Error 2 Makefile:1524: recipe
> for target '_module_/home/mike/jailhouse/jailhouse' failed make[1]:
> *** [_module_/home/mike/jailhouse/jailhouse] Error 2 Makefile:36:
> recipe for target 'modules' failed make: *** [modules] Error 2

I can reproduce it and am guessing that is somehow coming from a kernel
config option or maybe a ubuntu patched toolchain. But you can probably
just add the "-fPIC" and proceed. Edit tools/Makefile and add it to
KBUILD_CFLAGS.

Henning

mike

unread,
Jun 20, 2017, 11:49:42 AM6/20/17
to Jailhouse, diede...@gmail.com, henning...@siemens.com
Henning,
thank you for the great support.

Adding -fPIC to tools/Makefile

KBUILD_CFLAGS := -fPIC -g -O3 -DLIBEXECDIR=\"$(libexecdir)\" \
-Wall -Wextra -Wmissing-declarations -Wmissing-prototypes -Werror \
-DJAILHOUSE_VERSION=\"$(shell cat $(src)/../VERSION)\" $(EXTRA_CFLAGS)

did the job.
Regards,
mike

resurgen...@gmail.com

unread,
Jun 22, 2017, 11:20:35 PM6/22/17
to Jailhouse, diede...@gmail.com, henning...@siemens.com

Thank your guys, I have solved the same problem with the same measure...

Henning Schild

unread,
Jun 23, 2017, 4:05:14 AM6/23/17
to resurgen...@gmail.com, Jailhouse, diede...@gmail.com
Am Thu, 22 Jun 2017 20:20:35 -0700
schrieb <resurgen...@gmail.com>:
You can revert that local change and "git am"
https://groups.google.com/forum/message/raw?msg=jailhouse-dev/qMoi1sjjyfk/6BhZVAxtAwAJ

Henning

Message has been deleted

shilpara...@gmail.com

unread,
Aug 10, 2018, 8:08:50 AM8/10/18
to Jailhouse
Hi,
Even am getting similar kind of error but the difference is am executing in CentOS 7.5. and am not able to find in which make file i need to add -fPIC option because tools/makefile is not present.

ERROR obtained :

g++ -shared -fPIC -o Build/libNSCGBI.so dllmain.o NSCGBI.o
/usr/bin/ld: NSCGBI.o: relocation R_X86_64_32 against `.rodata' 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

Can any one help me regarding this ??

Reply all
Reply to author
Forward
0 new messages