Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"unrecognized reloc 22" error linking libclang_rt.asan-x86_64.so with lld #27252

Closed
emaste opened this issue Mar 8, 2016 · 3 comments
Closed
Labels
bugzilla Issues migrated from bugzilla lld

Comments

@emaste
Copy link
Member

emaste commented Mar 8, 2016

Bugzilla Link 26878
Resolution FIXED
Resolved on Mar 11, 2016 12:35
Version unspecified
OS FreeBSD
Blocks #23588

Extended Description

Attempting to build the asan runtime with lld as the linker on FreeBSD fails with:

[3/4] Linking CXX shared library lib/c...lib/freebsd/libclang_rt.asan-x86_64.so
FAILED: : && /usr/bin/CC -fPIC -fPIC -fvisibility-inlines-hidden -Wall -W -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wmissing-field-initializers -pedantic -Wno-long-long -Wcovered-switch-default -Wdelete-non-virtual-dtor -std=c++11 -fcolor-diagnostics -fdata-sections -Wall -std=c++11 -fuse-ld=lld -Wl,-z,origin -m64 -fPIC -fno-builtin -fno-exceptions -fomit-frame-pointer -funwind-tables -fno-stack-protector -fvisibility=hidden -fvisibility-inlines-hidden -fno-lto -O3 -gline-tables-only -Wno-gnu -Wno-variadic-macros -Wno-c99-extensions -Wno-non-virtual-dtor -fno-rtti -ftls-model=initial-exec -Wl,--version-script,/tank/emaste/src/llvm/build-lld-selfhost2/projects/compiler-rt/lib/asan/clang_rt.asan-dynamic-x86_64.vers -shared -Wl,-soname,libclang_rt.asan-x86_64.so -o lib/clang/3.9.0/lib/freebsd/libclang_rt.asan-x86_64.so projects/compiler-rt/lib/interception/CMakeFiles/RTInterception.x86_64.dir/interception_linux.cc.o [...] projects/compiler-rt/lib/ubsan/CMakeFiles/RTUbsan_cxx.x86_64.dir/ubsan_type_hash_win.cc.o -L/usr/local/lib -lc -lrt -lm -lpthread -lstdc++ -Wl,-rpath,"$ORIGIN/../lib" && :
unrecognized reloc 22

@llvmbot
Copy link
Collaborator

llvmbot commented Mar 8, 2016

This reduces to


bar:
movq %fs:0, %rax
addq foo@GOTTPOFF(%rip), %rax
retq

.section	.tbss,"awT",@nobits

foo:
.long 0

being linked into a shared library.

@llvmbot
Copy link
Collaborator

llvmbot commented Mar 10, 2016

It turns out one can just use symbol 0 as bfd ld does.

Given

    addq    foo@GOTTPOFF(%rip), %rax
    addq    bar@GOTTPOFF(%rip), %rax


    .section        .tbss,"awT",@nobits

foo:
.long 0
bar:
.long 0

it produces

Relocation section '.rela.dyn' at offset 0x1c8 contains 2 entries:
Offset Info Type Sym. Value Sym. Name + Addend
0000002002f8 000000000012 R_X86_64_TPOFF64 4
000000200300 000000000012 R_X86_64_TPOFF64 0

I will implement that.

@llvmbot
Copy link
Collaborator

llvmbot commented Mar 11, 2016

Fixed in r26878.

@llvmbot llvmbot transferred this issue from llvm/llvm-bugzilla-archive Dec 10, 2021
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bugzilla Issues migrated from bugzilla lld
Projects
None yet
Development

No branches or pull requests

2 participants