[lld] [llvm] [dyndbg][LLD][ELF] Initial LLD support for dynamic debugging (PR #214188)

Andrew Ng via llvm-commits llvm-commits at lists.llvm.org
Thu Sep 3 07:02:19 PDT 2026


================
@@ -3,91 +3,104 @@
 
 # RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t
 # RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux \
-# RUN: %p/Inputs/trace-symbols-foo-weak.s -o %t1
+# RUN:   %p/Inputs/trace-symbols-foo-weak.s -o %t1
 # RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux \
-# RUN: %p/Inputs/trace-symbols-foo-strong.s -o %t2
+# RUN:   %p/Inputs/trace-symbols-foo-strong.s -o %t2
 # RUN: ld.lld -shared %t1 -o %t1.so
 # RUN: ld.lld -shared %t2 -o %t2.so
 # RUN: rm -f %t1.a
 # RUN: llvm-ar rcs %t1.a %t1
 # RUN: rm -f %t2.a
 # RUN: llvm-ar rcs %t2.a %t2
+## Create dynamic debugging style object.
+# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux \
+# RUN:   %p/Inputs/trace-symbols-dyndbg-opt.s -o %t3
+# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux \
+# RUN:   %p/Inputs/trace-symbols-dyndbg-unopt.s -o %t-unopt
+# RUN: llvm-objcopy --add-section=.debug_llvm_dyndbg=%t-unopt %t3
+# RUN: llvm-objcopy --set-section-type=.debug_llvm_dyndbg=0x6fff4c10 \
+# RUN:              --set-section-alignment=.debug_llvm_dyndbg=8 %t3
 
 # RUN: ld.lld -y foo -shared %t1 %t1.so -o /dev/null | \
 # RUN:   FileCheck --check-prefix=PREEMPT %s --implicit-check-not=foo
 # PREEMPT:      trace-symbols.s.tmp1: definition of foo
 # PREEMPT-NEXT: trace-symbols.s.tmp1.so: shared definition of foo
 
 # RUN: ld.lld -y foo -trace-symbol common -trace-symbol=hsymbol \
-# RUN:   %t %t1 %t2 -o %t3 | FileCheck -check-prefix=OBJECTRFOO %s
+# RUN:   %t %t1 %t2 -o /dev/null | FileCheck -check-prefix=OBJECTRFOO %s
 # OBJECTRFOO: trace-symbols.s.tmp: reference to foo
 
 # RUN: ld.lld -y foo -trace-symbol=common -trace-symbol=hsymbol \
-# RUN:   %t %t1 %t2 -o %t3 | FileCheck -check-prefix=OBJECTDCOMMON %s
+# RUN:   %t %t1 %t2 -o /dev/null | FileCheck -check-prefix=OBJECTDCOMMON %s
 # OBJECTDCOMMON: trace-symbols.s.tmp1: common definition of common
 
 # RUN: ld.lld -y foo -trace-symbol=common -trace-symbol=hsymbol \
-# RUN:   %t %t1 %t2 -o %t3 | FileCheck -check-prefix=OBJECTD1FOO %s
+# RUN:   %t %t1 %t2 -o /dev/null | FileCheck -check-prefix=OBJECTD1FOO %s
 # OBJECTD1FOO: trace-symbols.s.tmp: reference to foo
 # OBJECTD1FOO: trace-symbols.s.tmp1: common definition of common
 # OBJECTD1FOO: trace-symbols.s.tmp1: definition of foo
 # OBJECTD1FOO: trace-symbols.s.tmp2: definition of foo
 
-# RUN: ld.lld -y foo %t1 %t2 %t -o %t3 | FileCheck -check-prefix=REFLAST %s
+# RUN: ld.lld -y foo %t1 %t2 %t -o /dev/null | FileCheck -check-prefix=REFLAST %s
 # REFLAST: trace-symbols.s.tmp1: definition of foo
 # REFLAST: trace-symbols.s.tmp2: definition of foo
 # REFLAST: trace-symbols.s.tmp: reference to foo
 
 # RUN: ld.lld -y foo -trace-symbol=common -trace-symbol=hsymbol \
-# RUN:   %t %t1 %t2 -o %t3 | FileCheck -check-prefix=OBJECTD2FOO %s
+# RUN:   %t %t1 %t2 -o /dev/null | FileCheck -check-prefix=OBJECTD2FOO %s
 # RUN: ld.lld -y foo -y common --trace-symbol=hsymbol \
-# RUN:   %t %t2 %t1 -o %t3 | FileCheck -check-prefix=OBJECTD2FOO %s
-# RUN: ld.lld -y foo -y common %t %t1.so %t2 -o %t3 | \
+# RUN:   %t %t2 %t1 -o /dev/null | FileCheck -check-prefix=OBJECTD2FOO %s
+# RUN: ld.lld -y foo -y common %t %t1.so %t2 -o /dev/null | \
 # RUN:   FileCheck -check-prefix=OBJECTD2FOO %s
 # OBJECTD2FOO: trace-symbols.s.tmp2: definition of foo
 
-# RUN: ld.lld -y foo -y common %t %t2 %t1.a -o %t3 | \
+# RUN: ld.lld -y foo -y common %t %t2 %t1.a -o /dev/null | \
 # RUN:   FileCheck -check-prefix=FOO_AND_COMMON %s
 # FOO_AND_COMMON: trace-symbols.s.tmp: reference to foo
 # FOO_AND_COMMON: trace-symbols.s.tmp2: definition of foo
 # FOO_AND_COMMON: trace-symbols.s.tmp1.a({{.*}}.tmp1): lazy definition of common
 
-# RUN: ld.lld -y foo -y common %t %t1.so %t2 -o %t3 | \
+# RUN: ld.lld -y foo -y common %t %t1.so %t2 -o /dev/null | \
 # RUN:   FileCheck -check-prefix=SHLIBDCOMMON %s
 # SHLIBDCOMMON: trace-symbols.s.tmp1.so: shared definition of common
 
-# RUN: ld.lld -y foo -y common %t %t2.so %t1.so -o %t3 | \
+# RUN: ld.lld -y foo -y common %t %t2.so %t1.so -o /dev/null | \
 # RUN:   FileCheck -check-prefix=SHLIBD2FOO %s
-# RUN: ld.lld -y foo %t %t1.a %t2.so -o %t3 | \
+# RUN: ld.lld -y foo %t %t1.a %t2.so -o /dev/null | \
 # RUN:   FileCheck -check-prefix=NO-SHLIBD2FOO %s
 # SHLIBD2FOO:        trace-symbols.s.tmp2.so: shared definition of foo
 # NO-SHLIBD2FOO-NOT: trace-symbols.s.tmp2.so: definition of foo
 
-# RUN: ld.lld -y foo -y common %t %t2 %t1.a -o %t3 | \
+# RUN: ld.lld -y foo -y common %t %t2 %t1.a -o /dev/null | \
 # RUN:   FileCheck -check-prefix=ARCHIVEDCOMMON %s
 # ARCHIVEDCOMMON-NOT: trace-symbols.s.tmp1.a(trace-symbols.s.tmp1): definition of \
 # common
 
-# RUN: ld.lld -y foo %t %t1.a %t2.so -o %t3 | \
+# RUN: ld.lld -y foo %t %t1.a %t2.so -o /dev/null | \
 # RUN:   FileCheck -check-prefix=ARCHIVED1FOO %s
 # ARCHIVED1FOO: trace-symbols.s.tmp1.a(trace-symbols.s.tmp1): definition of foo
 
-# RUN: ld.lld -y foo %t %t1.a %t2.a -o %t3 | \
+# RUN: ld.lld -y foo %t %t1.a %t2.a -o /dev/null | \
 # RUN:   FileCheck -check-prefix=ARCHIVED2FOO %s
 # ARCHIVED2FOO: trace-symbols.s.tmp2.a(trace-symbols.s.tmp2): definition of foo
 
-# RUN: ld.lld -y bar %t %t1.so %t2.so -o %t3 | \
+# RUN: ld.lld -y bar %t %t1.so %t2.so -o /dev/null | \
 # RUN:   FileCheck -check-prefix=SHLIBDBAR %s
 # SHLIBDBAR: trace-symbols.s.tmp2.so: shared definition of bar
 
-# RUN: ld.lld -y foo -y bar %t %t1.so %t2.so -o %t3 | \
+# RUN: ld.lld -y foo -y bar %t %t1.so %t2.so -o /dev/null | \
 # RUN:   FileCheck -check-prefix=SHLIBRBAR %s
 # SHLIBRBAR: trace-symbols.s.tmp1.so: reference to bar
 
-# RUN: ld.lld -y foo -y bar %t -u bar --start-lib %t1 %t2 --end-lib -o %t3 | \
+# RUN: ld.lld -y foo -y bar %t -u bar --start-lib %t1 %t2 --end-lib -o /dev/null | \
 # RUN:   FileCheck -check-prefix=STARTLIB %s
 # STARTLIB: trace-symbols.s.tmp1: reference to bar
 
+# RUN: ld.lld -y foo -shared %t2 %t3 -o /dev/null | FileCheck -check-prefix=DYNDBG %s
----------------
nga888 wrote:

I have add a new "split-file" based `trace-symbols-dynamic-debug.test` test and restored the `trace-symbols.s` to its original form.

https://github.com/llvm/llvm-project/pull/214188


More information about the llvm-commits mailing list