From 3c171f420084b2db590a938dcaaaad3fd92ef287 Mon Sep 17 00:00:00 2001 From: Fangrui Song Date: Wed, 11 Mar 2026 10:38:21 -0700 Subject: [PATCH] [ELF,test] Add test for -u error message referencing object file (#185938) When -u creates an undefined symbol and a relocatable file has a weak reference, the error message references the relocatable file, not . --- lld/test/ELF/weak-undef-lib.s | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/lld/test/ELF/weak-undef-lib.s b/lld/test/ELF/weak-undef-lib.s index 8f89c6f421ad..5192893615dd 100644 --- a/lld/test/ELF/weak-undef-lib.s +++ b/lld/test/ELF/weak-undef-lib.s @@ -33,6 +33,12 @@ # CHECK-U: Section: # CHECK-U-SAME: .text +## When the definition is not available, the error references the object file, +## not . +# RUN: not ld.lld -u foo %t1.o -o /dev/null 2>&1 | FileCheck %s --check-prefix=CHECK-UERR +# CHECK-UERR: error: undefined symbol: foo +# CHECK-UERR-NEXT: >>> referenced by {{.*}}1.o + .weak foo call foo@PLT