Skip to content

Building scudo trunk fails with R_X86_64_PC32 relocation in read-only section .text #46667

Open
@joshtriplett

Description

@joshtriplett
Bugzilla Link 47323
Version unspecified
OS Linux

Extended Description

I tried to build scudo from LLVM trunk (commit 486ed88), following the instructions on https://www.llvm.org/docs/ScudoHardenedAllocator.html (under "You may also build Scudo like this:"). (I had to make the slight modification of changing cc to cpp when referencing sanitizer_common.)

I ended up with this error:

ld.lld: error: relocation R_X86_64_PC32 cannot be used against symbol __interception::real_vfork; recompile with -fPIC

defined in /tmp/sanitizer_common_interceptors_vfork_x86_64-5badfa.o
referenced by /tmp/sanitizer_common_interceptors_vfork_x86_64-5badfa.o:(vfork)
clang: error: linker command failed with exit code 1 (use -v to see invocation)

I get the same error (other than symbol encoding) if I build with ld:

/usr/bin/ld: /tmp/sanitizer_common_interceptors_vfork_x86_64-01b7d5.o: warning: relocation against _ZN14__interception10real_vforkE' in read-only section .text'
/usr/bin/ld: /tmp/sanitizer_common_interceptors_vfork_x86_64-01b7d5.o: relocation R_X86_64_PC32 against symbol `_ZN14__interception10real_vforkE' can not be used when making a shared object; recompile with -fPIC
/usr/bin/ld: final link failed: bad value
clang: error: linker command failed with exit code 1 (use -v to see invocation)

I used this command line:

clang++-11 -fPIC -std=c++11 -msse4.2 -O2 -I. scudo/.cpp $(\ls sanitizer_common/.{cpp,S} | grep -v "sanitizer_termination|sanitizer_common_nolibc|sancov_|sanitizer_unwind|sanitizer_symbol") -shared -o libscudo.so -pthread

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugzillaIssues migrated from bugzillacompiler-rt:scudoScudo Hardened Allocator

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions