Index: lld/ELF/Relocations.cpp =================================================================== --- lld/ELF/Relocations.cpp +++ lld/ELF/Relocations.cpp @@ -982,12 +982,13 @@ // is always at the beginning of a search list. We can leverage that fact. if (Sym.isGnuIFunc()) { if (!Config->ZText && Config->WarnIfuncTextrel) { - warn("using ifunc symbols when text relocations are allowed may produce " - "a binary that will segfault, if the object file is linked with " - "old version of glibc (glibc 2.28 and earlier). If this applies to " - "you, consider recompiling the object files without -fPIC and " - "without -Wl,-z,notext option. Use -no-warn-ifunc-textrel to " - "turn off this warning." + + warn("We detected that your program uses both ifunc symbols and text " + "relocations, which is not compatible with glibc released in 2018 " + "or earlier (version 2.28 or earlier) due to a bug in glibc. As a " + "result, your program may crash on startup on a system that uses " + "glibc as a libc (i.e. most Linux systems). If this applies to you, " + "consider recompiling with `-fPIC` or link your program without " + "`-z notext`. Use `-no-warn-ifunc-textrel` to disable this warning." + getLocation(Sec, Sym, Offset)); } Expr = toPlt(Expr); Index: lld/docs/ld.lld.1 =================================================================== --- lld/docs/ld.lld.1 +++ lld/docs/ld.lld.1 @@ -447,16 +447,9 @@ .It Fl -warn-common Warn about duplicate common symbols. .It Fl -warn-ifunc-textrel -Warn about using ifunc symbols in conjunction with text relocations. -Older versions of glibc library (2.28 and earlier) has a bug that causes -the segment that includes ifunc symbols to be marked as not executable when -they are relocated. As a result, although the program compiles and links -successfully, it gives segmentation fault when the instruction pointer reaches -an ifunc symbol. Use -warn-ifunc-textrel to let lld give a warning, if the -code may include ifunc symbols, may do text relocations and be linked with -an older glibc version. Otherwise, there is no need to use it, as the default -value does not give a warning. This flag has been introduced in late 2018, -has no counter part in ld and gold linkers, and may be removed in the future. +Warn if both ifunc symbols and text relocations are used. glibc +released in 2018 or earlier (version 2.28 or earlier) has a bug that +causes programs to crash on startup if both features are used. .It Fl -warn-unresolved-symbols Report unresolved symbols as warnings. .It Fl -whole-archive Index: lld/test/ELF/textrel.s =================================================================== --- lld/test/ELF/textrel.s +++ lld/test/ELF/textrel.s @@ -6,12 +6,7 @@ # With --warn-text-ifunc, lld should run with warnings: # RUN: ld.lld --warn-ifunc-textrel -z notext %t.o -o /dev/null 2>&1 | FileCheck %s -# CHECK: using ifunc symbols when text relocations are allowed may produce -# CHECK-SAME: a binary that will segfault, if the object file is linked with -# CHECK-SAME: old version of glibc (glibc 2.28 and earlier). If this applies to -# CHECK-SAME: you, consider recompiling the object files without -fPIC and -# CHECK-SAME: without -Wl,-z,notext option. Use -no-warn-ifunc-textrel to -# CHECK-SAME: turn off this warning. +# CHECK: We detected that your program uses both ifunc symbols and # CHECK: >>> defined in {{.*}} # CHECK: >>> referenced by {{.*}}:(.text+0x8)