Skip to content

"make shlib" doesn't work on lld on FreeBSD, etc (needs to be recompiled with -fPIC) #121

@ngie-eign

Description

@ngie-eign

I suspect this issue occurs with other linkers and Linux as well.

% ld --version
LLD 19.1.7 (FreeBSD llvmorg-19.1.7-0-gcd708029e0b2-1400007) (https://github.com/llvm/llvm-project.git llvmorg-19.1.7-0-gcd708029e0b2) (compatible with GNU linkers)
% gcc --version
gcc (FreeBSD Ports Collection) 13.3.0
Copyright (C) 2023 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

% g++ --version
g++ (FreeBSD Ports Collection) 13.3.0
Copyright (C) 2023 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
rm -f libdmalloc.so libdmalloc.so.t
ld -shared --whole-archive -soname libdmalloc.so -o libdmalloc.so.t libdmalloc.a
ld: error: relocation R_X86_64_PC32 cannot be used against symbol '_dmalloc_heap_low'; recompile with -fPIC
>>> defined in libdmalloc.a(heap.o)
>>> referenced by heap.c:112 (/usr/home/ngie/git/dmalloc/heap.c:112)
>>>               heap.o:(heap_extend) in archive libdmalloc.a

ld: error: relocation R_X86_64_PC32 cannot be used against symbol '_dmalloc_heap_low'; recompile with -fPIC
>>> defined in libdmalloc.a(heap.o)
>>> referenced by heap.c:113 (/usr/home/ngie/git/dmalloc/heap.c:113)
>>>               heap.o:(heap_extend) in archive libdmalloc.a

ld: error: relocation R_X86_64_PC32 cannot be used against symbol '_dmalloc_heap_high'; recompile with -fPIC
>>> defined in libdmalloc.a(heap.o)
>>> referenced by heap.c:116 (/usr/home/ngie/git/dmalloc/heap.c:116)
>>>               heap.o:(heap_extend) in archive libdmalloc.a

ld: error: relocation R_X86_64_PC32 cannot be used against symbol '_dmalloc_heap_high'; recompile with -fPIC
>>> defined in libdmalloc.a(heap.o)
>>> referenced by heap.c:117 (/usr/home/ngie/git/dmalloc/heap.c:117)
>>>               heap.o:(heap_extend) in archive libdmalloc.a

ld: error: relocation R_X86_64_PC32 cannot be used against symbol '_dmalloc_flags'; recompile with -fPIC
>>> defined in libdmalloc.a(error.o)
>>> referenced by heap.c:120 (/usr/home/ngie/git/dmalloc/heap.c:120)
>>>               heap.o:(heap_extend) in archive libdmalloc.a

ld: error: relocation R_X86_64_PC32 cannot be used against symbol '_dmalloc_heap_high'; recompile with -fPIC
>>> defined in libdmalloc.a(heap.o)
>>> referenced by heap.c:121 (/usr/home/ngie/git/dmalloc/heap.c:121)
>>>               heap.o:(heap_extend) in archive libdmalloc.a

ld: error: relocation R_X86_64_PC32 cannot be used against symbol '_dmalloc_heap_low'; recompile with -fPIC
>>> defined in libdmalloc.a(heap.o)
>>> referenced by heap.c:121 (/usr/home/ngie/git/dmalloc/heap.c:121)
>>>               heap.o:(heap_extend) in archive libdmalloc.a

ld: error: relocation R_X86_64_32 cannot be used against local symbol; recompile with -fPIC
>>> defined in libdmalloc.a(heap.o)
>>> referenced by heap.c:121 (/usr/home/ngie/git/dmalloc/heap.c:121)
>>>               heap.o:(heap_extend) in archive libdmalloc.a

ld: error: relocation R_X86_64_PC32 cannot be used against symbol '_dmalloc_flags'; recompile with -fPIC
>>> defined in libdmalloc.a(error.o)
>>> referenced by heap.c:103 (/usr/home/ngie/git/dmalloc/heap.c:103)
>>>               heap.o:(heap_extend) in archive libdmalloc.a

ld: error: relocation R_X86_64_PC32 cannot be used against symbol 'dmalloc_errno'; recompile with -fPIC
>>> defined in libdmalloc.a(user_malloc.o)
>>> referenced by heap.c:108 (/usr/home/ngie/git/dmalloc/heap.c:108)
>>>               heap.o:(heap_extend) in archive libdmalloc.a

ld: error: relocation R_X86_64_32 cannot be used against local symbol; recompile with -fPIC
>>> defined in libdmalloc.a(heap.o)
>>> referenced by heap.c:109 (/usr/home/ngie/git/dmalloc/heap.c:109)
>>>               heap.o:(heap_extend) in archive libdmalloc.a

ld: error: relocation R_X86_64_PC32 cannot be used against symbol '_dmalloc_heap_low'; recompile with -fPIC
>>> defined in libdmalloc.a(heap.o)
>>> referenced by heap.c:112 (/usr/home/ngie/git/dmalloc/heap.c:112)
>>>               heap.o:(heap_extend) in archive libdmalloc.a

ld: error: relocation R_X86_64_32 cannot be used against local symbol; recompile with -fPIC
>>> defined in libdmalloc.a(heap.o)
>>> referenced by heap.c:104 (/usr/home/ngie/git/dmalloc/heap.c:104)
>>>               heap.o:(heap_extend) in archive libdmalloc.a
...

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions