diff --git a/lld/ELF/Relocations.cpp b/lld/ELF/Relocations.cpp --- a/lld/ELF/Relocations.cpp +++ b/lld/ELF/Relocations.cpp @@ -777,6 +777,14 @@ return s; } + // Case mismatch, e.g. Foo vs FOO. + for (auto &it : map) + if (name.equals_lower(it.first)) + return it.second; + for (Symbol *sym : symtab->symbols()) + if (!sym->isUndefined() && name.equals_lower(sym->getName())) + return sym; + // The reference may be a mangled name while the definition is not. Suggest a // missing extern "C". if (name.startswith("_Z")) { diff --git a/lld/test/ELF/undef-spell-corrector.s b/lld/test/ELF/undef-spell-corrector.s --- a/lld/test/ELF/undef-spell-corrector.s +++ b/lld/test/ELF/undef-spell-corrector.s @@ -63,6 +63,16 @@ # CONST-NEXT: >>> referenced by {{.*}} # CONST-NEXT: >>> did you mean: foo(int const*) +## Case mismatch. +# RUN: echo 'call _Z3FOOPKi' | llvm-mc -filetype=obj -triple=x86_64 - -o %t1.o +# RUN: not ld.lld %t.o %t1.o -o /dev/null 2>&1 | FileCheck --check-prefix=CASE %s +# RUN: echo '_Z3fooPKi: call _Z3FOOPKi' | llvm-mc -filetype=obj -triple=x86_64 - -o %t1.o +# RUN: not ld.lld %t1.o -o /dev/null 2>&1 | FileCheck --check-prefix=CASE %s + +# CASE: error: undefined symbol: FOO(int const*) +# CASE-NEXT: >>> referenced by {{.*}} +# CASE-NEXT: >>> did you mean: foo(int const*) + .globl _start, abcde, _Z3fooPKi _start: abcde: