https://gcc.gnu.org/bugzilla/show_bug.cgi?id=119386
Bug ID: 119386 Summary: [14/15 Regression][x64] Shared libraries can no longer be compiled with profiling Product: gcc Version: 15.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: target Assignee: unassigned at gcc dot gnu.org Reporter: sirl at gcc dot gnu.org Target Milestone: --- Hi, compiling even the simplest code to a shared library with profiling is broken since r14-811-bde21de1205c0456f6df68c950fb7ee631fcfa93 . int f(int var) { return var; } Compiled and linked like that: # gcc-trunk -pg -W -Wall -fPIC -c test-shared-pg.c # gcc-trunk -pg -shared -o libtest.so test-shared-pg.o /usr/x86_64-suse-linux/bin/ld: test-shared-pg.o: warning: relocation against `mcount@@GLIBC_2.2.5' in read-only section `.text' /usr/x86_64-suse-linux/bin/ld: test-shared-pg.o: relocation R_X86_64_PC32 against symbol `mcount@@GLIBC_2.2.5' can not be used when making a shared object; recompile with -fPIC /usr/x86_64-suse-linux/bin/ld: final link failed: bad value collect2: error: ld returned 1 exit status Compiling with -mno-direct-extern-access fixes it, but there is a fat warning about mixing -mno-direct-extern-access and the default -mdirect-extern-access in the manual. In the bad case a naked "call mcount" is emitted, with -mno-direct-extern-access or gcc-13 it's "call *mcount@GOTPCREL(%rip)".