LLVM Bugzilla is read-only and represents the historical archive of all LLVM issues filled before November 26, 2021. Use github to submit LLVM bugs

Bug 26878 - "unrecognized reloc 22" error linking libclang_rt.asan-x86_64.so with lld
Summary: "unrecognized reloc 22" error linking libclang_rt.asan-x86_64.so with lld
Status: RESOLVED FIXED
Alias: None
Product: lld
Classification: Unclassified
Component: All Bugs (show other bugs)
Version: unspecified
Hardware: PC FreeBSD
: P normal
Assignee: Rafael Ávila de Espíndola
URL:
Keywords:
Depends on:
Blocks: 23214
  Show dependency tree
 
Reported: 2016-03-08 09:05 PST by emaste
Modified: 2016-03-11 12:35 PST (History)
2 users (show)

See Also:
Fixed By Commit(s):


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description emaste 2016-03-08 09:05:11 PST
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
Comment 1 Rafael Ávila de Espíndola 2016-03-08 11:47:38 PST
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.
Comment 2 Rafael Ávila de Espíndola 2016-03-10 08:35:08 PST
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.
Comment 3 Rafael Ávila de Espíndola 2016-03-11 12:35:31 PST
Fixed in r26878.