[Bug 192686] Segfaults using combinations of -pie -pthread -lm(|_p) when profiling

From: <bugzilla-noreply_at_freebsd.org>
Date: Mon, 07 Apr 2025 00:14:52 UTC
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=192686

yu shan wei <mpysw@vip.163.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |mpysw@vip.163.com

--- Comment #5 from yu shan wei <mpysw@vip.163.com> ---
[1]> clang -pg -pie -pthread -lm profile.c && ./a.out
ld: error: relocation R_X86_64_64 cannot be used against local symbol;
recompile with -fPIC
>>> defined in /tmp/profile-387333.o
>>> referenced by profile.c
>>>               /tmp/profile-387333.o:(main)

ld: error: relocation R_X86_64_64 cannot be used against symbol 'main';
recompile with -fPIC
>>> defined in /tmp/profile-387333.o
>>> referenced by crt1_s.S:69 (/usr/src/lib/csu/amd64/crt1_s.S:69)
>>>               /usr/lib/gcrt1.o:(_start)

ld: error: relocation R_X86_64_64 cannot be used against local symbol;
recompile with -fPIC
>>> defined in /usr/lib/gcrt1.o
>>> referenced by crt1_s.S:72 (/usr/src/lib/csu/amd64/crt1_s.S:72)
>>>               /usr/lib/gcrt1.o:(_start)

ld: error: relocation R_X86_64_64 cannot be used against symbol 'etext';
recompile with -fPIC
>>> defined in <internal>
>>> referenced by crt1_s.S:73 (/usr/src/lib/csu/amd64/crt1_s.S:73)
>>>               /usr/lib/gcrt1.o:(_start)
clang: error: linker command failed with exit code 1 (use -v to see invocation)
[2]> clang -pg -pie -pthread -lm_p profile.c && ./a.out
clang -pg -pie -pthread -lm_p profile.c && ./a.out
ld: error: unable to find library -lm_p

clang -pg -pie -pthread -lmp profile.c && ./a.out
ld: error: relocation R_X86_64_64 cannot be used against local symbol;
recompile with -fPIC
>>> defined in /tmp/profile-8d9771.o
>>> referenced by profile.c
>>>               /tmp/profile-8d9771.o:(main)

ld: error: relocation R_X86_64_64 cannot be used against symbol 'main';
recompile with -fPIC
>>> defined in /tmp/profile-8d9771.o
>>> referenced by crt1_s.S:69 (/usr/src/lib/csu/amd64/crt1_s.S:69)
>>>               /usr/lib/gcrt1.o:(_start)

ld: error: relocation R_X86_64_64 cannot be used against local symbol;
recompile with -fPIC
>>> defined in /usr/lib/gcrt1.o
>>> referenced by crt1_s.S:72 (/usr/src/lib/csu/amd64/crt1_s.S:72)
>>>               /usr/lib/gcrt1.o:(_start)

ld: error: relocation R_X86_64_64 cannot be used against symbol 'etext';
recompile with -fPIC
>>> defined in <internal>
>>> referenced by crt1_s.S:73 (/usr/src/lib/csu/amd64/crt1_s.S:73)
>>>               /usr/lib/gcrt1.o:(_start)
clang: error: linker command failed with exit code 1 (use -v to see invocation)

[3]> clang -pg -pthread -lm profile.c && ./a.out
success
[4]> clang -pg -pthread -lm_p profile.c && ./a.out
clang -pg -pthread -lm_p profile.c && ./a.out
success
[5]> clang -pg -pthread -lm profile.c && ./a.out
success
[6]> clang -pg -pie -pthread  profile.c && ./a.out
ld: error: relocation R_X86_64_64 cannot be used against local symbol;
recompile with -fPIC
>>> defined in /tmp/profile-1d081e.o
>>> referenced by profile.c
>>>               /tmp/profile-1d081e.o:(main)

ld: error: relocation R_X86_64_64 cannot be used against symbol 'main';
recompile with -fPIC
>>> defined in /tmp/profile-1d081e.o
>>> referenced by crt1_s.S:69 (/usr/src/lib/csu/amd64/crt1_s.S:69)
>>>               /usr/lib/gcrt1.o:(_start)

ld: error: relocation R_X86_64_64 cannot be used against local symbol;
recompile with -fPIC
>>> defined in /usr/lib/gcrt1.o
>>> referenced by crt1_s.S:72 (/usr/src/lib/csu/amd64/crt1_s.S:72)
>>>               /usr/lib/gcrt1.o:(_start)

ld: error: relocation R_X86_64_64 cannot be used against symbol 'etext';
recompile with -fPIC
>>> defined in <internal>
>>> referenced by crt1_s.S:73 (/usr/src/lib/csu/amd64/crt1_s.S:73)
>>>               /usr/lib/gcrt1.o:(_start)
clang: error: linker command failed with exit code 1 (use -v to see invocation)



FreeBSD 14.2

-- 
You are receiving this mail because:
You are the assignee for the bug.