0

I try to use the HWAddressSanitizer option in clang on an Ubuntu 20.04.3 LTS, but it results in a relocation truncated to fit: R_X86_64_PC32 against '.data' error while compiling.

The compiler comes from the clang-12 package installed by apt-get.

The compilation command used:

clang++-12 a.cpp -fsanitize=hwaddress   

The error report:

/tmp/a-ea2385.o: in function `main':
a.cpp:(.text+0xbe): relocation truncated to fit: R_X86_64_PC32 against `.rodata'
/tmp/a-ea2385.o: in function `__cxx_global_var_init':
a.cpp:(.text.startup+0x7): relocation truncated to fit: R_X86_64_PC32 against `.data'
a.cpp:(.text.startup+0x1a): relocation truncated to fit: R_X86_64_PC32 against `.data'
clang: error: linker command failed with exit code 1 (use -v to see invocation)

The program tested:

#include <bits/stdc++.h>
using namespace std;

int main() {
        printf("HelloWorld\n");
        return 0;
}

Some answers online suggest using -no-pie option but it doesn't work.

How can I sucessfully compile the program with HWAddressSanitizer enabled?

AceSrc
  • 11
  • 1

0 Answers0