BullseyeCoverage Up Contents Search

Relocation Error Making a Shared Object

Symptoms

Errors like those shown below occur when linking a shared object with BullseyeCoverage instrumentation.

R_X86_64_32 relocation at offset 0x5 against symbol `cov_...' can not be used; recompile with -fPIC
relocation R_X86_64_PC32 against symbol `cov_...' can not be used when making a shared object; recompile with -fPIC
relocation R_AARCH64_ADR_PREL_PG_HI21 against symbol `cov_...' which may bind externally can not be used when making a shared object; recompile with -fPIC

Cause

BullseyeCoverage instrumentation introduces references to data that require relocation at link time.

Resolution

Use compiler option -fPIC on all compile commands that produce code linked into shared objects.

Updated: 20 Jun 2024