aboutsummaryrefslogtreecommitdiff
path: root/ld/testsuite
diff options
context:
space:
mode:
Diffstat (limited to 'ld/testsuite')
-rw-r--r--ld/testsuite/ld-aarch64/protections/bti-and-memory-seal-plt-1-a.d45
-rw-r--r--ld/testsuite/ld-aarch64/protections/bti-and-memory-seal-plt-1-b.d14
-rw-r--r--ld/testsuite/ld-aarch64/protections/bti-plt-1-b.d2
-rw-r--r--ld/testsuite/ld-elf/tbss4.d13
-rw-r--r--ld/testsuite/ld-elf/tbss4.s25
-rw-r--r--ld/testsuite/ld-plugin/lto.exp32
-rw-r--r--ld/testsuite/ld-plugin/pr32846a.c6
-rw-r--r--ld/testsuite/ld-plugin/pr32846b.c4
-rw-r--r--ld/testsuite/ld-plugin/pr32846c.c6
-rw-r--r--ld/testsuite/ld-plugin/pr32846d.c12
-rw-r--r--ld/testsuite/ld-plugin/pr32846e.c4
-rw-r--r--ld/testsuite/ld-x86-64/dwarf4.s346
-rw-r--r--ld/testsuite/ld-x86-64/dwarf5a.s400
-rw-r--r--ld/testsuite/ld-x86-64/dwarf5b.s345
-rw-r--r--ld/testsuite/ld-x86-64/pr32809.d71
-rw-r--r--ld/testsuite/ld-x86-64/x86-64.exp1
16 files changed, 1325 insertions, 1 deletions
diff --git a/ld/testsuite/ld-aarch64/protections/bti-and-memory-seal-plt-1-a.d b/ld/testsuite/ld-aarch64/protections/bti-and-memory-seal-plt-1-a.d
new file mode 100644
index 0000000..f8b1c21
--- /dev/null
+++ b/ld/testsuite/ld-aarch64/protections/bti-and-memory-seal-plt-1-a.d
@@ -0,0 +1,45 @@
+#name: No '-z force-bti' with '-z memory-seal' with feature properties (BTI) forces the generation of BTI PLT (shared)
+#source: bti-plt-1.s
+#source: bti-plt-2.s
+#target: [check_shared_lib_support]
+#as: -mabi=lp64 -defsym __property_bti__=1
+#ld: -shared -z memory-seal -T bti-plt.ld -L./tmpdir -lbti-plt-so
+#objdump: -dr -j .plt
+
+[^:]*: *file format elf64-.*aarch64
+
+Disassembly of section \.plt:
+
+[0-9]+ <\.plt>:
+.*: d503245f bti c
+.*: a9bf7bf0 stp x16, x30, \[sp, #-16\]!
+.*: 90000090 adrp x16, 28000 <_GLOBAL_OFFSET_TABLE_>
+.*: f9400e11 ldr x17, \[x16, #24\]
+.*: 91006210 add x16, x16, #0x18
+.*: d61f0220 br x17
+.*: d503201f nop
+.*: d503201f nop
+
+[0-9]+ <.*>:
+.*: 90000090 adrp x16, 28000 <_GLOBAL_OFFSET_TABLE_>
+.*: f9401211 ldr x17, \[x16, #32\]
+.*: 91008210 add x16, x16, #0x20
+.*: d61f0220 br x17
+
+[0-9]+ <.*>:
+.*: 90000090 adrp x16, 28000 <_GLOBAL_OFFSET_TABLE_>
+.*: f9401611 ldr x17, \[x16, #40\]
+.*: 9100a210 add x16, x16, #0x28
+.*: d61f0220 br x17
+
+[0-9]+ <.*>:
+.*: 90000090 adrp x16, 28000 <_GLOBAL_OFFSET_TABLE_>
+.*: f9401a11 ldr x17, \[x16, #48\]
+.*: 9100c210 add x16, x16, #0x30
+.*: d61f0220 br x17
+
+[0-9]+ <.*>:
+.*: 90000090 adrp x16, 28000 <_GLOBAL_OFFSET_TABLE_>
+.*: f9401e11 ldr x17, \[x16, #56\]
+.*: 9100e210 add x16, x16, #0x38
+.*: d61f0220 br x17
diff --git a/ld/testsuite/ld-aarch64/protections/bti-and-memory-seal-plt-1-b.d b/ld/testsuite/ld-aarch64/protections/bti-and-memory-seal-plt-1-b.d
new file mode 100644
index 0000000..0dadcc9
--- /dev/null
+++ b/ld/testsuite/ld-aarch64/protections/bti-and-memory-seal-plt-1-b.d
@@ -0,0 +1,14 @@
+#name: No '-z force-bti' with '-z memory-seal' all input objects have BTI emits BTI feature (shared)
+#source: bti-plt-1.s
+#source: bti-plt-2.s
+#target: [check_shared_lib_support]
+#as: -mabi=lp64 -defsym __property_bti__=1
+#ld: -z memory-seal -shared -T bti-plt.ld
+#readelf: -n
+
+Displaying notes found in: .note.gnu.property
+[ ]+Owner[ ]+Data size[ ]+Description
+ GNU 0x00000018 NT_GNU_PROPERTY_TYPE_0
+ Properties: memory seal\s
+\s+AArch64 feature: BTI
+#pass
diff --git a/ld/testsuite/ld-aarch64/protections/bti-plt-1-b.d b/ld/testsuite/ld-aarch64/protections/bti-plt-1-b.d
index 1bf956c..4b0e424 100644
--- a/ld/testsuite/ld-aarch64/protections/bti-plt-1-b.d
+++ b/ld/testsuite/ld-aarch64/protections/bti-plt-1-b.d
@@ -2,7 +2,7 @@
#source: bti-plt-1.s
#target: [check_shared_lib_support]
#as: -mabi=lp64 -defsym __property_bti__=1
-#ld: -shared -z force-bti -T bti-plt.ld -L./tmpdir -lbti-plt-so
+#ld: -shared -T bti-plt.ld -L./tmpdir -lbti-plt-so
#objdump: -dr -j .plt
[^:]*: *file format elf64-.*aarch64
diff --git a/ld/testsuite/ld-elf/tbss4.d b/ld/testsuite/ld-elf/tbss4.d
new file mode 100644
index 0000000..336ed8f
--- /dev/null
+++ b/ld/testsuite/ld-elf/tbss4.d
@@ -0,0 +1,13 @@
+#ld: -e _start -Ttext=0x1000 -z max-page-size=0x1000 -z common-page-size=0x1000 -z noseparate-code
+#readelf: -lSW
+#target: *-linux* *-gnu*
+#notarget: hppa64-*-* ia64-*-*
+
+#...
+.* \.tbss +NOBITS +0+1014 +0+1014 +0+4 +0+ +WAT +0 +0 +4
+
+#...
+ +TLS +0x0*1014 +0x0+1014 +0x0+1014 +0x0+ +0x0+4 R +0x4
+#...
+.* \.tbss
+#pass
diff --git a/ld/testsuite/ld-elf/tbss4.s b/ld/testsuite/ld-elf/tbss4.s
new file mode 100644
index 0000000..f49491e
--- /dev/null
+++ b/ld/testsuite/ld-elf/tbss4.s
@@ -0,0 +1,25 @@
+# Writeable gcc_except_table is required in order to put this section after
+# the DATA_SEGMENT_ALIGN directive in the default linker script (and hence
+# in the same PT_LOAD as the PT_TLS segment, and hence so that the
+# gcc_except_table can affect the .tbss section location).
+ .section .gcc_except_table,"aw",%progbits
+# Alignment is needed -- otherwise gcc_except_table start position seems to
+# be adjusted so that the tbss section is fully aligned.
+ .balign 4
+ .ascii "Odd number of chars"
+
+ .section .tbss,"awT",%nobits
+ .balign 4
+ .type xyz, %object
+ .size xyz, 4
+xyz:
+ .zero 4
+
+ .data
+dataval:
+ .balign 4
+ .ascii "x"
+
+ .text
+ .global _start
+_start:
diff --git a/ld/testsuite/ld-plugin/lto.exp b/ld/testsuite/ld-plugin/lto.exp
index 9349190..3a56fb5 100644
--- a/ld/testsuite/ld-plugin/lto.exp
+++ b/ld/testsuite/ld-plugin/lto.exp
@@ -1212,6 +1212,38 @@ if { [is_elf_format] } {
if { [is_elf_format] && [check_lto_shared_available] } {
run_ld_link_exec_tests $lto_run_elf_shared_tests
+ if { [check_lto_fat_available] } {
+ run_cc_link_tests [list \
+ [list \
+ "Build libpr32846a.a" \
+ "$plug_opt" "-fPIC -O2 -flto $lto_no_fat" \
+ {pr32846a.c pr32846b.c} {} "libpr32846a.a" \
+ ] \
+ [list \
+ "Build libpr32846b.a" \
+ "$plug_opt" "-fPIC -O2 -flto $lto_no_fat" \
+ {pr32846a.c pr32846b.c pr32846c.c} {} "libpr32846b.a" \
+ ] \
+ [list \
+ "Build pr32846d.o" \
+ "$plug_opt" "-fPIC -O2 -flto $lto_no_fat" \
+ {pr32846d.c} {} \
+ ] \
+ [list \
+ "Build pr32846e.o" \
+ "$plug_opt" "-fPIC -O2 -flto $lto_no_fat" \
+ {pr32846e.c} {} \
+ ] \
+ [list \
+ "Build pr32846" \
+ "-shared -fPIC -O2 -flto $lto_no_fat -Wl,--no-undefined \
+ tmpdir/pr32846d.o tmpdir/libpr32846a.a \
+ tmpdir/libpr32846b.a tmpdir/pr32846e.o" \
+ "-O2 -fPIC -flto $lto_no_fat" \
+ {dummy.c} {} "pr32846" \
+ ] \
+ ] \
+ }
}
proc pr20103 {cflags libs} {
diff --git a/ld/testsuite/ld-plugin/pr32846a.c b/ld/testsuite/ld-plugin/pr32846a.c
new file mode 100644
index 0000000..8c16171
--- /dev/null
+++ b/ld/testsuite/ld-plugin/pr32846a.c
@@ -0,0 +1,6 @@
+extern void mkdir_p (void);
+void
+mkdir_parents (void)
+{
+ mkdir_p ();
+}
diff --git a/ld/testsuite/ld-plugin/pr32846b.c b/ld/testsuite/ld-plugin/pr32846b.c
new file mode 100644
index 0000000..9776a37
--- /dev/null
+++ b/ld/testsuite/ld-plugin/pr32846b.c
@@ -0,0 +1,4 @@
+void
+hash_new (void)
+{
+}
diff --git a/ld/testsuite/ld-plugin/pr32846c.c b/ld/testsuite/ld-plugin/pr32846c.c
new file mode 100644
index 0000000..f87cffb
--- /dev/null
+++ b/ld/testsuite/ld-plugin/pr32846c.c
@@ -0,0 +1,6 @@
+extern void hash_new (void);
+void
+kmod_new (void)
+{
+ hash_new();
+}
diff --git a/ld/testsuite/ld-plugin/pr32846d.c b/ld/testsuite/ld-plugin/pr32846d.c
new file mode 100644
index 0000000..c6f4102
--- /dev/null
+++ b/ld/testsuite/ld-plugin/pr32846d.c
@@ -0,0 +1,12 @@
+extern void kmod_new (void);
+extern void mkdir_parents (void);
+void
+do_lsmod (void)
+{
+ kmod_new ();
+}
+void
+do_static_nodes (void)
+{
+ mkdir_parents();
+}
diff --git a/ld/testsuite/ld-plugin/pr32846e.c b/ld/testsuite/ld-plugin/pr32846e.c
new file mode 100644
index 0000000..c4e5e56
--- /dev/null
+++ b/ld/testsuite/ld-plugin/pr32846e.c
@@ -0,0 +1,4 @@
+void
+mkdir_p (void)
+{
+}
diff --git a/ld/testsuite/ld-x86-64/dwarf4.s b/ld/testsuite/ld-x86-64/dwarf4.s
new file mode 100644
index 0000000..7f1a90d
--- /dev/null
+++ b/ld/testsuite/ld-x86-64/dwarf4.s
@@ -0,0 +1,346 @@
+/* Assembly outputs of
+
+extern void bar();
+
+void foo(int p) {
+ int local = p;
+ bar();
+ local = 123;
+ bar();
+ local = 456;
+}
+
+compiled by GCC 14.2.1 with -O2 -g -dA -gdwarf-4. */
+
+ .file "dwarf4.c"
+ .text
+.Ltext0:
+ .file 1 "dwarf4.c"
+ .p2align 4
+ .globl foo
+ .type foo, @function
+foo:
+.LVL0:
+ # DEBUG p => di
+.LFB0:
+ # dwarf4.c:3:17
+ .loc 1 3 17 view -0
+ .cfi_startproc
+# BLOCK 2, count:1073741824 (estimated locally) seq:0
+# PRED: ENTRY [always] count:1073741824 (estimated locally, freq 1.0000) (FALLTHRU)
+ # dwarf4.c:4:3
+ .loc 1 4 3 view .LVU1
+ # DEBUG local => di
+ # dwarf4.c:5:3
+ .loc 1 5 3 view .LVU2
+ # dwarf4.c:3:17
+ .loc 1 3 17 is_stmt 0 view .LVU3
+ subq $8, %rsp
+ .cfi_def_cfa_offset 16
+ # dwarf4.c:5:3
+ .loc 1 5 3 view .LVU4
+ xorl %eax, %eax
+ call bar
+.LVL1:
+ # DEBUG local => entry_value#0
+ # DEBUG p => entry_value#0
+ # dwarf4.c:6:3
+ .loc 1 6 3 is_stmt 1 view .LVU5
+ # DEBUG local => 0x7b
+ # dwarf4.c:7:3
+ .loc 1 7 3 view .LVU6
+ xorl %eax, %eax
+ # dwarf4.c:9:1
+ .loc 1 9 1 is_stmt 0 view .LVU7
+ addq $8, %rsp
+ .cfi_def_cfa_offset 8
+# SUCC: EXIT [always] count:1073741824 (estimated locally, freq 1.0000) (ABNORMAL,SIBCALL)
+ # dwarf4.c:7:3
+ .loc 1 7 3 view .LVU8
+ jmp bar
+.LVL2:
+ .cfi_endproc
+.LFE0:
+ .size foo, .-foo
+.Letext0:
+ .section .debug_info,"",@progbits
+.Ldebug_info0:
+ .long 0x9e # Length of Compilation Unit Info
+ .value 0x4 # DWARF version number
+ .long .Ldebug_abbrev0 # Offset Into Abbrev. Section
+ .byte 0x8 # Pointer Size (in bytes)
+ .uleb128 0x1 # (DIE (0xb) DW_TAG_compile_unit)
+ .long .LASF0 # DW_AT_producer: "GNU C17 14.2.1 20240906 [releases/gcc-14 r14-10649-gaedf6f810ee] -mtune=generic -march=x86-64 -g -gdwarf-4 -O2"
+ .byte 0xc # DW_AT_language
+ .long .LASF1 # DW_AT_name: "dwarf4.c"
+ .long .LASF2 # DW_AT_comp_dir: "."
+ .quad .Ltext0 # DW_AT_low_pc
+ .quad .Letext0-.Ltext0 # DW_AT_high_pc
+ .long .Ldebug_line0 # DW_AT_stmt_list
+ .uleb128 0x2 # (DIE (0x2d) DW_TAG_subprogram)
+ # DW_AT_external
+ .ascii "bar\0" # DW_AT_name
+ .byte 0x1 # DW_AT_decl_file (dwarf4.c)
+ .byte 0x1 # DW_AT_decl_line
+ .byte 0xd # DW_AT_decl_column
+ # DW_AT_declaration
+ .long 0x3b # DW_AT_sibling
+ .uleb128 0x3 # (DIE (0x39) DW_TAG_unspecified_parameters)
+ .byte 0 # end of children of DIE 0x2d
+ .uleb128 0x4 # (DIE (0x3b) DW_TAG_subprogram)
+ # DW_AT_external
+ .ascii "foo\0" # DW_AT_name
+ .byte 0x1 # DW_AT_decl_file (dwarf4.c)
+ .byte 0x3 # DW_AT_decl_line
+ .byte 0x6 # DW_AT_decl_column
+ # DW_AT_prototyped
+ .quad .LFB0 # DW_AT_low_pc
+ .quad .LFE0-.LFB0 # DW_AT_high_pc
+ .uleb128 0x1 # DW_AT_frame_base
+ .byte 0x9c # DW_OP_call_frame_cfa
+ # DW_AT_GNU_all_call_sites
+ .long 0x9a # DW_AT_sibling
+ .uleb128 0x5 # (DIE (0x59) DW_TAG_formal_parameter)
+ .ascii "p\0" # DW_AT_name
+ .byte 0x1 # DW_AT_decl_file (dwarf4.c)
+ .byte 0x3 # DW_AT_decl_line
+ .byte 0xe # DW_AT_decl_column
+ .long 0x9a # DW_AT_type
+ .long .LLST0 # DW_AT_location
+ .long .LVUS0 # DW_AT_GNU_locviews
+ .uleb128 0x6 # (DIE (0x6b) DW_TAG_variable)
+ .long .LASF3 # DW_AT_name: "local"
+ .byte 0x1 # DW_AT_decl_file (dwarf4.c)
+ .byte 0x4 # DW_AT_decl_line
+ .byte 0x7 # DW_AT_decl_column
+ .long 0x9a # DW_AT_type
+ .long .LLST1 # DW_AT_location
+ .long .LVUS1 # DW_AT_GNU_locviews
+ .uleb128 0x7 # (DIE (0x7f) DW_TAG_GNU_call_site)
+ .quad .LVL1 # DW_AT_low_pc
+ .long 0x2d # DW_AT_abstract_origin
+ .uleb128 0x8 # (DIE (0x8c) DW_TAG_GNU_call_site)
+ .quad .LVL2 # DW_AT_low_pc
+ # DW_AT_GNU_tail_call
+ .long 0x2d # DW_AT_abstract_origin
+ .byte 0 # end of children of DIE 0x3b
+ .uleb128 0x9 # (DIE (0x9a) DW_TAG_base_type)
+ .byte 0x4 # DW_AT_byte_size
+ .byte 0x5 # DW_AT_encoding
+ .ascii "int\0" # DW_AT_name
+ .byte 0 # end of children of DIE 0xb
+ .section .debug_abbrev,"",@progbits
+.Ldebug_abbrev0:
+ .uleb128 0x1 # (abbrev code)
+ .uleb128 0x11 # (TAG: DW_TAG_compile_unit)
+ .byte 0x1 # DW_children_yes
+ .uleb128 0x25 # (DW_AT_producer)
+ .uleb128 0xe # (DW_FORM_strp)
+ .uleb128 0x13 # (DW_AT_language)
+ .uleb128 0xb # (DW_FORM_data1)
+ .uleb128 0x3 # (DW_AT_name)
+ .uleb128 0xe # (DW_FORM_strp)
+ .uleb128 0x1b # (DW_AT_comp_dir)
+ .uleb128 0xe # (DW_FORM_strp)
+ .uleb128 0x11 # (DW_AT_low_pc)
+ .uleb128 0x1 # (DW_FORM_addr)
+ .uleb128 0x12 # (DW_AT_high_pc)
+ .uleb128 0x7 # (DW_FORM_data8)
+ .uleb128 0x10 # (DW_AT_stmt_list)
+ .uleb128 0x17 # (DW_FORM_sec_offset)
+ .byte 0
+ .byte 0
+ .uleb128 0x2 # (abbrev code)
+ .uleb128 0x2e # (TAG: DW_TAG_subprogram)
+ .byte 0x1 # DW_children_yes
+ .uleb128 0x3f # (DW_AT_external)
+ .uleb128 0x19 # (DW_FORM_flag_present)
+ .uleb128 0x3 # (DW_AT_name)
+ .uleb128 0x8 # (DW_FORM_string)
+ .uleb128 0x3a # (DW_AT_decl_file)
+ .uleb128 0xb # (DW_FORM_data1)
+ .uleb128 0x3b # (DW_AT_decl_line)
+ .uleb128 0xb # (DW_FORM_data1)
+ .uleb128 0x39 # (DW_AT_decl_column)
+ .uleb128 0xb # (DW_FORM_data1)
+ .uleb128 0x3c # (DW_AT_declaration)
+ .uleb128 0x19 # (DW_FORM_flag_present)
+ .uleb128 0x1 # (DW_AT_sibling)
+ .uleb128 0x13 # (DW_FORM_ref4)
+ .byte 0
+ .byte 0
+ .uleb128 0x3 # (abbrev code)
+ .uleb128 0x18 # (TAG: DW_TAG_unspecified_parameters)
+ .byte 0 # DW_children_no
+ .byte 0
+ .byte 0
+ .uleb128 0x4 # (abbrev code)
+ .uleb128 0x2e # (TAG: DW_TAG_subprogram)
+ .byte 0x1 # DW_children_yes
+ .uleb128 0x3f # (DW_AT_external)
+ .uleb128 0x19 # (DW_FORM_flag_present)
+ .uleb128 0x3 # (DW_AT_name)
+ .uleb128 0x8 # (DW_FORM_string)
+ .uleb128 0x3a # (DW_AT_decl_file)
+ .uleb128 0xb # (DW_FORM_data1)
+ .uleb128 0x3b # (DW_AT_decl_line)
+ .uleb128 0xb # (DW_FORM_data1)
+ .uleb128 0x39 # (DW_AT_decl_column)
+ .uleb128 0xb # (DW_FORM_data1)
+ .uleb128 0x27 # (DW_AT_prototyped)
+ .uleb128 0x19 # (DW_FORM_flag_present)
+ .uleb128 0x11 # (DW_AT_low_pc)
+ .uleb128 0x1 # (DW_FORM_addr)
+ .uleb128 0x12 # (DW_AT_high_pc)
+ .uleb128 0x7 # (DW_FORM_data8)
+ .uleb128 0x40 # (DW_AT_frame_base)
+ .uleb128 0x18 # (DW_FORM_exprloc)
+ .uleb128 0x2117 # (DW_AT_GNU_all_call_sites)
+ .uleb128 0x19 # (DW_FORM_flag_present)
+ .uleb128 0x1 # (DW_AT_sibling)
+ .uleb128 0x13 # (DW_FORM_ref4)
+ .byte 0
+ .byte 0
+ .uleb128 0x5 # (abbrev code)
+ .uleb128 0x5 # (TAG: DW_TAG_formal_parameter)
+ .byte 0 # DW_children_no
+ .uleb128 0x3 # (DW_AT_name)
+ .uleb128 0x8 # (DW_FORM_string)
+ .uleb128 0x3a # (DW_AT_decl_file)
+ .uleb128 0xb # (DW_FORM_data1)
+ .uleb128 0x3b # (DW_AT_decl_line)
+ .uleb128 0xb # (DW_FORM_data1)
+ .uleb128 0x39 # (DW_AT_decl_column)
+ .uleb128 0xb # (DW_FORM_data1)
+ .uleb128 0x49 # (DW_AT_type)
+ .uleb128 0x13 # (DW_FORM_ref4)
+ .uleb128 0x2 # (DW_AT_location)
+ .uleb128 0x17 # (DW_FORM_sec_offset)
+ .uleb128 0x2137 # (DW_AT_GNU_locviews)
+ .uleb128 0x17 # (DW_FORM_sec_offset)
+ .byte 0
+ .byte 0
+ .uleb128 0x6 # (abbrev code)
+ .uleb128 0x34 # (TAG: DW_TAG_variable)
+ .byte 0 # DW_children_no
+ .uleb128 0x3 # (DW_AT_name)
+ .uleb128 0xe # (DW_FORM_strp)
+ .uleb128 0x3a # (DW_AT_decl_file)
+ .uleb128 0xb # (DW_FORM_data1)
+ .uleb128 0x3b # (DW_AT_decl_line)
+ .uleb128 0xb # (DW_FORM_data1)
+ .uleb128 0x39 # (DW_AT_decl_column)
+ .uleb128 0xb # (DW_FORM_data1)
+ .uleb128 0x49 # (DW_AT_type)
+ .uleb128 0x13 # (DW_FORM_ref4)
+ .uleb128 0x2 # (DW_AT_location)
+ .uleb128 0x17 # (DW_FORM_sec_offset)
+ .uleb128 0x2137 # (DW_AT_GNU_locviews)
+ .uleb128 0x17 # (DW_FORM_sec_offset)
+ .byte 0
+ .byte 0
+ .uleb128 0x7 # (abbrev code)
+ .uleb128 0x4109 # (TAG: DW_TAG_GNU_call_site)
+ .byte 0 # DW_children_no
+ .uleb128 0x11 # (DW_AT_low_pc)
+ .uleb128 0x1 # (DW_FORM_addr)
+ .uleb128 0x31 # (DW_AT_abstract_origin)
+ .uleb128 0x13 # (DW_FORM_ref4)
+ .byte 0
+ .byte 0
+ .uleb128 0x8 # (abbrev code)
+ .uleb128 0x4109 # (TAG: DW_TAG_GNU_call_site)
+ .byte 0 # DW_children_no
+ .uleb128 0x11 # (DW_AT_low_pc)
+ .uleb128 0x1 # (DW_FORM_addr)
+ .uleb128 0x2115 # (DW_AT_GNU_tail_call)
+ .uleb128 0x19 # (DW_FORM_flag_present)
+ .uleb128 0x31 # (DW_AT_abstract_origin)
+ .uleb128 0x13 # (DW_FORM_ref4)
+ .byte 0
+ .byte 0
+ .uleb128 0x9 # (abbrev code)
+ .uleb128 0x24 # (TAG: DW_TAG_base_type)
+ .byte 0 # DW_children_no
+ .uleb128 0xb # (DW_AT_byte_size)
+ .uleb128 0xb # (DW_FORM_data1)
+ .uleb128 0x3e # (DW_AT_encoding)
+ .uleb128 0xb # (DW_FORM_data1)
+ .uleb128 0x3 # (DW_AT_name)
+ .uleb128 0x8 # (DW_FORM_string)
+ .byte 0
+ .byte 0
+ .byte 0
+ .section .debug_loc,"",@progbits
+.Ldebug_loc0:
+.LVUS0:
+ .uleb128 0 # View list begin (*.LVUS0)
+ .uleb128 .LVU5 # View list end (*.LVUS0)
+ .uleb128 .LVU5 # View list begin (*.LVUS0)
+ .uleb128 0 # View list end (*.LVUS0)
+.LLST0:
+ .quad .LVL0-.Ltext0 # Location list begin address (*.LLST0)
+ .quad .LVL1-1-.Ltext0 # Location list end address (*.LLST0)
+ .value 0x1 # Location expression size
+ .byte 0x55 # DW_OP_reg5
+ .quad .LVL1-1-.Ltext0 # Location list begin address (*.LLST0)
+ .quad .LFE0-.Ltext0 # Location list end address (*.LLST0)
+ .value 0x4 # Location expression size
+ .byte 0xf3 # DW_OP_GNU_entry_value
+ .uleb128 0x1
+ .byte 0x55 # DW_OP_reg5
+ .byte 0x9f # DW_OP_stack_value
+ .quad 0 # Location list terminator begin (*.LLST0)
+ .quad 0 # Location list terminator end (*.LLST0)
+.LVUS1:
+ .uleb128 .LVU2 # View list begin (*.LVUS1)
+ .uleb128 .LVU5 # View list end (*.LVUS1)
+ .uleb128 .LVU5 # View list begin (*.LVUS1)
+ .uleb128 .LVU6 # View list end (*.LVUS1)
+ .uleb128 .LVU6 # View list begin (*.LVUS1)
+ .uleb128 0 # View list end (*.LVUS1)
+.LLST1:
+ .quad .LVL0-.Ltext0 # Location list begin address (*.LLST1)
+ .quad .LVL1-1-.Ltext0 # Location list end address (*.LLST1)
+ .value 0x1 # Location expression size
+ .byte 0x55 # DW_OP_reg5
+ .quad .LVL1-1-.Ltext0 # Location list begin address (*.LLST1)
+ .quad .LVL1-.Ltext0 # Location list end address (*.LLST1)
+ .value 0x4 # Location expression size
+ .byte 0xf3 # DW_OP_GNU_entry_value
+ .uleb128 0x1
+ .byte 0x55 # DW_OP_reg5
+ .byte 0x9f # DW_OP_stack_value
+ .quad .LVL1-.Ltext0 # Location list begin address (*.LLST1)
+ .quad .LFE0-.Ltext0 # Location list end address (*.LLST1)
+ .value 0x3 # Location expression size
+ .byte 0x8 # DW_OP_const1u
+ .byte 0x7b
+ .byte 0x9f # DW_OP_stack_value
+ .quad 0 # Location list terminator begin (*.LLST1)
+ .quad 0 # Location list terminator end (*.LLST1)
+ .section .debug_aranges,"",@progbits
+ .long 0x2c # Length of Address Ranges Info
+ .value 0x2 # DWARF aranges version
+ .long .Ldebug_info0 # Offset of Compilation Unit Info
+ .byte 0x8 # Size of Address
+ .byte 0 # Size of Segment Descriptor
+ .value 0 # Pad to 16 byte boundary
+ .value 0
+ .quad .Ltext0 # Address
+ .quad .Letext0-.Ltext0 # Length
+ .quad 0
+ .quad 0
+ .section .debug_line,"",@progbits
+.Ldebug_line0:
+ .section .debug_str,"MS",@progbits,1
+.LASF0:
+ .string "GNU C17 14.2.1 20240906 [releases/gcc-14 r14-10649-gaedf6f810ee] -mtune=generic -march=x86-64 -g -gdwarf-4 -O2"
+.LASF1:
+ .string "dwarf4.c"
+.LASF3:
+ .string "local"
+.LASF2:
+ .string "."
+ .ident "GCC: (GNU) 14.2.1 20240906 [releases/gcc-14 r14-10649-gaedf6f810ee]"
+ .section .note.GNU-stack,"",@progbits
diff --git a/ld/testsuite/ld-x86-64/dwarf5a.s b/ld/testsuite/ld-x86-64/dwarf5a.s
new file mode 100644
index 0000000..eefaaf4
--- /dev/null
+++ b/ld/testsuite/ld-x86-64/dwarf5a.s
@@ -0,0 +1,400 @@
+/* Assembly outputs of
+
+extern void foo(int);
+
+int global;
+
+int main() {
+ int local = global;
+ foo(1);
+ local = 123;
+ foo(2);
+ local = 456;
+ return 0;
+}
+
+compiled by GCC 14.2.1 with -O2 -g -dA -gdwarf-5. */
+
+ .file "dwarf5a.c"
+ .text
+.Ltext0:
+ .file 0 "." "dwarf5a.c"
+ .section .text.startup,"ax",@progbits
+ .p2align 4
+ .globl main
+ .type main, @function
+main:
+.LFB0:
+ .file 1 "dwarf5a.c"
+ # dwarf5a.c:5:12
+ .loc 1 5 12 view -0
+ .cfi_startproc
+# BLOCK 2, count:1073741824 (estimated locally) seq:0
+# PRED: ENTRY [always] count:1073741824 (estimated locally, freq 1.0000) (FALLTHRU)
+ # dwarf5a.c:6:3
+ .loc 1 6 3 view .LVU1
+.LVL0:
+ # DEBUG local => [`global']
+ # dwarf5a.c:7:3
+ .loc 1 7 3 view .LVU2
+ # dwarf5a.c:5:12
+ .loc 1 5 12 is_stmt 0 view .LVU3
+ subq $8, %rsp
+ .cfi_def_cfa_offset 16
+ # dwarf5a.c:7:3
+ .loc 1 7 3 view .LVU4
+ movl $1, %edi
+ call foo
+.LVL1:
+ # DEBUG local RESET
+ # dwarf5a.c:8:3
+ .loc 1 8 3 is_stmt 1 view .LVU5
+ # DEBUG local => 0x7b
+ # dwarf5a.c:9:3
+ .loc 1 9 3 view .LVU6
+ movl $2, %edi
+ call foo
+.LVL2:
+ # dwarf5a.c:10:3
+ .loc 1 10 3 view .LVU7
+ # DEBUG local => 0x1c8
+ # dwarf5a.c:11:3
+ .loc 1 11 3 view .LVU8
+ # dwarf5a.c:12:1
+ .loc 1 12 1 is_stmt 0 view .LVU9
+ xorl %eax, %eax
+ addq $8, %rsp
+ .cfi_def_cfa_offset 8
+# SUCC: EXIT [always] count:1073741824 (estimated locally, freq 1.0000)
+ ret
+ .cfi_endproc
+.LFE0:
+ .size main, .-main
+ .globl global
+ .bss
+ .align 4
+ .type global, @object
+ .size global, 4
+global:
+ .zero 4
+ .text
+.Letext0:
+ .section .debug_info,"",@progbits
+.Ldebug_info0:
+ .long 0xb3 # Length of Compilation Unit Info
+ .value 0x5 # DWARF version number
+ .byte 0x1 # DW_UT_compile
+ .byte 0x8 # Pointer Size (in bytes)
+ .long .Ldebug_abbrev0 # Offset Into Abbrev. Section
+ .uleb128 0x2 # (DIE (0xc) DW_TAG_compile_unit)
+ .long .LASF4 # DW_AT_producer: "GNU C17 14.2.1 20240906 [releases/gcc-14 r14-10649-gaedf6f810ee] -mtune=generic -march=x86-64 -g -gdwarf-5 -O2"
+ .byte 0x1d # DW_AT_language
+ .long .LASF0 # DW_AT_name: "dwarf5a.c"
+ .long .LASF1 # DW_AT_comp_dir: "."
+ .long .LLRL1 # DW_AT_ranges
+ .quad 0 # DW_AT_low_pc
+ .long .Ldebug_line0 # DW_AT_stmt_list
+ .uleb128 0x3 # (DIE (0x2a) DW_TAG_variable)
+ .long .LASF2 # DW_AT_name: "global"
+ .byte 0x1 # DW_AT_decl_file (dwarf5a.c)
+ .byte 0x3 # DW_AT_decl_line
+ .byte 0x5 # DW_AT_decl_column
+ .long 0x40 # DW_AT_type
+ # DW_AT_external
+ .uleb128 0x9 # DW_AT_location
+ .byte 0x3 # DW_OP_addr
+ .quad global
+ .uleb128 0x4 # (DIE (0x40) DW_TAG_base_type)
+ .byte 0x4 # DW_AT_byte_size
+ .byte 0x5 # DW_AT_encoding
+ .ascii "int\0" # DW_AT_name
+ .uleb128 0x5 # (DIE (0x47) DW_TAG_subprogram)
+ # DW_AT_external
+ .ascii "foo\0" # DW_AT_name
+ .byte 0x1 # DW_AT_decl_file (dwarf5a.c)
+ .byte 0x1 # DW_AT_decl_line
+ .byte 0xd # DW_AT_decl_column
+ # DW_AT_prototyped
+ # DW_AT_declaration
+ .long 0x59 # DW_AT_sibling
+ .uleb128 0x6 # (DIE (0x53) DW_TAG_formal_parameter)
+ .long 0x40 # DW_AT_type
+ .byte 0 # end of children of DIE 0x47
+ .uleb128 0x7 # (DIE (0x59) DW_TAG_subprogram)
+ # DW_AT_external
+ .long .LASF5 # DW_AT_name: "main"
+ .byte 0x1 # DW_AT_decl_file (dwarf5a.c)
+ .byte 0x5 # DW_AT_decl_line
+ .byte 0x5 # DW_AT_decl_column
+ .long 0x40 # DW_AT_type
+ .quad .LFB0 # DW_AT_low_pc
+ .quad .LFE0-.LFB0 # DW_AT_high_pc
+ .uleb128 0x1 # DW_AT_frame_base
+ .byte 0x9c # DW_OP_call_frame_cfa
+ # DW_AT_call_all_calls
+ .uleb128 0x8 # (DIE (0x77) DW_TAG_variable)
+ .long .LASF3 # DW_AT_name: "local"
+ .byte 0x1 # DW_AT_decl_file (dwarf5a.c)
+ .byte 0x6 # DW_AT_decl_line
+ .byte 0x7 # DW_AT_decl_column
+ .long 0x40 # DW_AT_type
+ .long .LLST0 # DW_AT_location
+ .long .LVUS0 # DW_AT_GNU_locviews
+ .uleb128 0x9 # (DIE (0x8b) DW_TAG_call_site)
+ .quad .LVL1 # DW_AT_call_return_pc
+ .long 0x47 # DW_AT_call_origin
+ .long 0xa2 # DW_AT_sibling
+ .uleb128 0x1 # (DIE (0x9c) DW_TAG_call_site_parameter)
+ .uleb128 0x1 # DW_AT_location
+ .byte 0x55 # DW_OP_reg5
+ .uleb128 0x1 # DW_AT_call_value
+ .byte 0x31 # DW_OP_lit1
+ .byte 0 # end of children of DIE 0x8b
+ .uleb128 0xa # (DIE (0xa2) DW_TAG_call_site)
+ .quad .LVL2 # DW_AT_call_return_pc
+ .long 0x47 # DW_AT_call_origin
+ .uleb128 0x1 # (DIE (0xaf) DW_TAG_call_site_parameter)
+ .uleb128 0x1 # DW_AT_location
+ .byte 0x55 # DW_OP_reg5
+ .uleb128 0x1 # DW_AT_call_value
+ .byte 0x32 # DW_OP_lit2
+ .byte 0 # end of children of DIE 0xa2
+ .byte 0 # end of children of DIE 0x59
+ .byte 0 # end of children of DIE 0xc
+ .section .debug_abbrev,"",@progbits
+.Ldebug_abbrev0:
+ .uleb128 0x1 # (abbrev code)
+ .uleb128 0x49 # (TAG: DW_TAG_call_site_parameter)
+ .byte 0 # DW_children_no
+ .uleb128 0x2 # (DW_AT_location)
+ .uleb128 0x18 # (DW_FORM_exprloc)
+ .uleb128 0x7e # (DW_AT_call_value)
+ .uleb128 0x18 # (DW_FORM_exprloc)
+ .byte 0
+ .byte 0
+ .uleb128 0x2 # (abbrev code)
+ .uleb128 0x11 # (TAG: DW_TAG_compile_unit)
+ .byte 0x1 # DW_children_yes
+ .uleb128 0x25 # (DW_AT_producer)
+ .uleb128 0xe # (DW_FORM_strp)
+ .uleb128 0x13 # (DW_AT_language)
+ .uleb128 0xb # (DW_FORM_data1)
+ .uleb128 0x3 # (DW_AT_name)
+ .uleb128 0x1f # (DW_FORM_line_strp)
+ .uleb128 0x1b # (DW_AT_comp_dir)
+ .uleb128 0x1f # (DW_FORM_line_strp)
+ .uleb128 0x55 # (DW_AT_ranges)
+ .uleb128 0x17 # (DW_FORM_sec_offset)
+ .uleb128 0x11 # (DW_AT_low_pc)
+ .uleb128 0x1 # (DW_FORM_addr)
+ .uleb128 0x10 # (DW_AT_stmt_list)
+ .uleb128 0x17 # (DW_FORM_sec_offset)
+ .byte 0
+ .byte 0
+ .uleb128 0x3 # (abbrev code)
+ .uleb128 0x34 # (TAG: DW_TAG_variable)
+ .byte 0 # DW_children_no
+ .uleb128 0x3 # (DW_AT_name)
+ .uleb128 0xe # (DW_FORM_strp)
+ .uleb128 0x3a # (DW_AT_decl_file)
+ .uleb128 0xb # (DW_FORM_data1)
+ .uleb128 0x3b # (DW_AT_decl_line)
+ .uleb128 0xb # (DW_FORM_data1)
+ .uleb128 0x39 # (DW_AT_decl_column)
+ .uleb128 0xb # (DW_FORM_data1)
+ .uleb128 0x49 # (DW_AT_type)
+ .uleb128 0x13 # (DW_FORM_ref4)
+ .uleb128 0x3f # (DW_AT_external)
+ .uleb128 0x19 # (DW_FORM_flag_present)
+ .uleb128 0x2 # (DW_AT_location)
+ .uleb128 0x18 # (DW_FORM_exprloc)
+ .byte 0
+ .byte 0
+ .uleb128 0x4 # (abbrev code)
+ .uleb128 0x24 # (TAG: DW_TAG_base_type)
+ .byte 0 # DW_children_no
+ .uleb128 0xb # (DW_AT_byte_size)
+ .uleb128 0xb # (DW_FORM_data1)
+ .uleb128 0x3e # (DW_AT_encoding)
+ .uleb128 0xb # (DW_FORM_data1)
+ .uleb128 0x3 # (DW_AT_name)
+ .uleb128 0x8 # (DW_FORM_string)
+ .byte 0
+ .byte 0
+ .uleb128 0x5 # (abbrev code)
+ .uleb128 0x2e # (TAG: DW_TAG_subprogram)
+ .byte 0x1 # DW_children_yes
+ .uleb128 0x3f # (DW_AT_external)
+ .uleb128 0x19 # (DW_FORM_flag_present)
+ .uleb128 0x3 # (DW_AT_name)
+ .uleb128 0x8 # (DW_FORM_string)
+ .uleb128 0x3a # (DW_AT_decl_file)
+ .uleb128 0xb # (DW_FORM_data1)
+ .uleb128 0x3b # (DW_AT_decl_line)
+ .uleb128 0xb # (DW_FORM_data1)
+ .uleb128 0x39 # (DW_AT_decl_column)
+ .uleb128 0xb # (DW_FORM_data1)
+ .uleb128 0x27 # (DW_AT_prototyped)
+ .uleb128 0x19 # (DW_FORM_flag_present)
+ .uleb128 0x3c # (DW_AT_declaration)
+ .uleb128 0x19 # (DW_FORM_flag_present)
+ .uleb128 0x1 # (DW_AT_sibling)
+ .uleb128 0x13 # (DW_FORM_ref4)
+ .byte 0
+ .byte 0
+ .uleb128 0x6 # (abbrev code)
+ .uleb128 0x5 # (TAG: DW_TAG_formal_parameter)
+ .byte 0 # DW_children_no
+ .uleb128 0x49 # (DW_AT_type)
+ .uleb128 0x13 # (DW_FORM_ref4)
+ .byte 0
+ .byte 0
+ .uleb128 0x7 # (abbrev code)
+ .uleb128 0x2e # (TAG: DW_TAG_subprogram)
+ .byte 0x1 # DW_children_yes
+ .uleb128 0x3f # (DW_AT_external)
+ .uleb128 0x19 # (DW_FORM_flag_present)
+ .uleb128 0x3 # (DW_AT_name)
+ .uleb128 0xe # (DW_FORM_strp)
+ .uleb128 0x3a # (DW_AT_decl_file)
+ .uleb128 0xb # (DW_FORM_data1)
+ .uleb128 0x3b # (DW_AT_decl_line)
+ .uleb128 0xb # (DW_FORM_data1)
+ .uleb128 0x39 # (DW_AT_decl_column)
+ .uleb128 0xb # (DW_FORM_data1)
+ .uleb128 0x49 # (DW_AT_type)
+ .uleb128 0x13 # (DW_FORM_ref4)
+ .uleb128 0x11 # (DW_AT_low_pc)
+ .uleb128 0x1 # (DW_FORM_addr)
+ .uleb128 0x12 # (DW_AT_high_pc)
+ .uleb128 0x7 # (DW_FORM_data8)
+ .uleb128 0x40 # (DW_AT_frame_base)
+ .uleb128 0x18 # (DW_FORM_exprloc)
+ .uleb128 0x7a # (DW_AT_call_all_calls)
+ .uleb128 0x19 # (DW_FORM_flag_present)
+ .byte 0
+ .byte 0
+ .uleb128 0x8 # (abbrev code)
+ .uleb128 0x34 # (TAG: DW_TAG_variable)
+ .byte 0 # DW_children_no
+ .uleb128 0x3 # (DW_AT_name)
+ .uleb128 0xe # (DW_FORM_strp)
+ .uleb128 0x3a # (DW_AT_decl_file)
+ .uleb128 0xb # (DW_FORM_data1)
+ .uleb128 0x3b # (DW_AT_decl_line)
+ .uleb128 0xb # (DW_FORM_data1)
+ .uleb128 0x39 # (DW_AT_decl_column)
+ .uleb128 0xb # (DW_FORM_data1)
+ .uleb128 0x49 # (DW_AT_type)
+ .uleb128 0x13 # (DW_FORM_ref4)
+ .uleb128 0x2 # (DW_AT_location)
+ .uleb128 0x17 # (DW_FORM_sec_offset)
+ .uleb128 0x2137 # (DW_AT_GNU_locviews)
+ .uleb128 0x17 # (DW_FORM_sec_offset)
+ .byte 0
+ .byte 0
+ .uleb128 0x9 # (abbrev code)
+ .uleb128 0x48 # (TAG: DW_TAG_call_site)
+ .byte 0x1 # DW_children_yes
+ .uleb128 0x7d # (DW_AT_call_return_pc)
+ .uleb128 0x1 # (DW_FORM_addr)
+ .uleb128 0x7f # (DW_AT_call_origin)
+ .uleb128 0x13 # (DW_FORM_ref4)
+ .uleb128 0x1 # (DW_AT_sibling)
+ .uleb128 0x13 # (DW_FORM_ref4)
+ .byte 0
+ .byte 0
+ .uleb128 0xa # (abbrev code)
+ .uleb128 0x48 # (TAG: DW_TAG_call_site)
+ .byte 0x1 # DW_children_yes
+ .uleb128 0x7d # (DW_AT_call_return_pc)
+ .uleb128 0x1 # (DW_FORM_addr)
+ .uleb128 0x7f # (DW_AT_call_origin)
+ .uleb128 0x13 # (DW_FORM_ref4)
+ .byte 0
+ .byte 0
+ .byte 0
+ .section .debug_loclists,"",@progbits
+ .long .Ldebug_loc3-.Ldebug_loc2 # Length of Location Lists
+.Ldebug_loc2:
+ .value 0x5 # DWARF version number
+ .byte 0x8 # Address Size
+ .byte 0 # Segment Size
+ .long 0 # Offset Entry Count
+.Ldebug_loc0:
+.LVUS0:
+ .uleb128 .LVU2 # View list begin (*.LVUS0)
+ .uleb128 .LVU5 # View list end (*.LVUS0)
+ .uleb128 .LVU6 # View list begin (*.LVUS0)
+ .uleb128 .LVU8 # View list end (*.LVUS0)
+ .uleb128 .LVU8 # View list begin (*.LVUS0)
+ .uleb128 0 # View list end (*.LVUS0)
+.LLST0:
+ .byte 0x6 # DW_LLE_base_address (*.LLST0)
+ .quad .LVL0 # Base address (*.LLST0)
+ .byte 0x4 # DW_LLE_offset_pair (*.LLST0)
+ .uleb128 .LVL0-.LVL0 # Location list begin address (*.LLST0)
+ .uleb128 .LVL1-1-.LVL0 # Location list end address (*.LLST0)
+ .uleb128 0x9 # Location expression size
+ .byte 0x3 # DW_OP_addr
+ .quad global
+ .byte 0x4 # DW_LLE_offset_pair (*.LLST0)
+ .uleb128 .LVL1-.LVL0 # Location list begin address (*.LLST0)
+ .uleb128 .LVL2-.LVL0 # Location list end address (*.LLST0)
+ .uleb128 0x3 # Location expression size
+ .byte 0x8 # DW_OP_const1u
+ .byte 0x7b
+ .byte 0x9f # DW_OP_stack_value
+ .byte 0x4 # DW_LLE_offset_pair (*.LLST0)
+ .uleb128 .LVL2-.LVL0 # Location list begin address (*.LLST0)
+ .uleb128 .LFE0-.LVL0 # Location list end address (*.LLST0)
+ .uleb128 0x4 # Location expression size
+ .byte 0xa # DW_OP_const2u
+ .value 0x1c8
+ .byte 0x9f # DW_OP_stack_value
+ .byte 0 # DW_LLE_end_of_list (*.LLST0)
+.Ldebug_loc3:
+ .section .debug_aranges,"",@progbits
+ .long 0x2c # Length of Address Ranges Info
+ .value 0x2 # DWARF aranges version
+ .long .Ldebug_info0 # Offset of Compilation Unit Info
+ .byte 0x8 # Size of Address
+ .byte 0 # Size of Segment Descriptor
+ .value 0 # Pad to 16 byte boundary
+ .value 0
+ .quad .LFB0 # Address
+ .quad .LFE0-.LFB0 # Length
+ .quad 0
+ .quad 0
+ .section .debug_rnglists,"",@progbits
+.Ldebug_ranges0:
+ .long .Ldebug_ranges3-.Ldebug_ranges2 # Length of Range Lists
+.Ldebug_ranges2:
+ .value 0x5 # DWARF version number
+ .byte 0x8 # Address Size
+ .byte 0 # Segment Size
+ .long 0 # Offset Entry Count
+.LLRL1:
+ .byte 0x7 # DW_RLE_start_length (*.LLRL1)
+ .quad .LFB0 # Range begin address (*.LLRL1)
+ .uleb128 .LFE0-.LFB0 # Range length (*.LLRL1)
+ .byte 0 # DW_RLE_end_of_list (*.LLRL1)
+.Ldebug_ranges3:
+ .section .debug_line,"",@progbits
+.Ldebug_line0:
+ .section .debug_str,"MS",@progbits,1
+.LASF3:
+ .string "local"
+.LASF4:
+ .string "GNU C17 14.2.1 20240906 [releases/gcc-14 r14-10649-gaedf6f810ee] -mtune=generic -march=x86-64 -g -gdwarf-5 -O2"
+.LASF2:
+ .string "global"
+.LASF5:
+ .string "main"
+ .section .debug_line_str,"MS",@progbits,1
+.LASF0:
+ .string "dwarf5a.c"
+.LASF1:
+ .string "."
+ .ident "GCC: (GNU) 14.2.1 20240906 [releases/gcc-14 r14-10649-gaedf6f810ee]"
+ .section .note.GNU-stack,"",@progbits
diff --git a/ld/testsuite/ld-x86-64/dwarf5b.s b/ld/testsuite/ld-x86-64/dwarf5b.s
new file mode 100644
index 0000000..4d34469
--- /dev/null
+++ b/ld/testsuite/ld-x86-64/dwarf5b.s
@@ -0,0 +1,345 @@
+/* Assembly outputs of
+
+extern void foo(int);
+
+extern int global;
+
+void
+bar (void)
+{
+ int local = global;
+ foo(local);
+ local = 123;
+ foo(local);
+ local = 456;
+}
+
+compiled by GCC 14.2.1 with -O2 -g -dA -gdwarf-5. */
+
+ .file "dwarf5b.c"
+ .text
+.Ltext0:
+ .file 0 "." "dwarf5b.c"
+ .p2align 4
+ .globl bar
+ .type bar, @function
+bar:
+.LFB0:
+ .file 1 "dwarf5b.c"
+ # dwarf5b.c:7:1
+ .loc 1 7 1 view -0
+ .cfi_startproc
+# BLOCK 2, count:1073741824 (estimated locally) seq:0
+# PRED: ENTRY [always] count:1073741824 (estimated locally, freq 1.0000) (FALLTHRU)
+ # dwarf5b.c:8:3
+ .loc 1 8 3 view .LVU1
+.LVL0:
+ # DEBUG local => [`global']
+ # dwarf5b.c:9:3
+ .loc 1 9 3 view .LVU2
+ # dwarf5b.c:7:1
+ .loc 1 7 1 is_stmt 0 view .LVU3
+ subq $8, %rsp
+ .cfi_def_cfa_offset 16
+ # dwarf5b.c:9:3
+ .loc 1 9 3 view .LVU4
+ movl global(%rip), %edi
+ call foo
+.LVL1:
+ # DEBUG local RESET
+ # dwarf5b.c:10:3
+ .loc 1 10 3 is_stmt 1 view .LVU5
+ # DEBUG local => 0x7b
+ # dwarf5b.c:11:3
+ .loc 1 11 3 view .LVU6
+ movl $123, %edi
+ # dwarf5b.c:13:1
+ .loc 1 13 1 is_stmt 0 view .LVU7
+ addq $8, %rsp
+ .cfi_def_cfa_offset 8
+# SUCC: EXIT [always] count:1073741824 (estimated locally, freq 1.0000) (ABNORMAL,SIBCALL)
+ # dwarf5b.c:11:3
+ .loc 1 11 3 view .LVU8
+ jmp foo
+.LVL2:
+ .cfi_endproc
+.LFE0:
+ .size bar, .-bar
+.Letext0:
+ .section .debug_info,"",@progbits
+.Ldebug_info0:
+ .long 0xa0 # Length of Compilation Unit Info
+ .value 0x5 # DWARF version number
+ .byte 0x1 # DW_UT_compile
+ .byte 0x8 # Pointer Size (in bytes)
+ .long .Ldebug_abbrev0 # Offset Into Abbrev. Section
+ .uleb128 0x1 # (DIE (0xc) DW_TAG_compile_unit)
+ .long .LASF4 # DW_AT_producer: "GNU C17 14.2.1 20240906 [releases/gcc-14 r14-10649-gaedf6f810ee] -mtune=generic -march=x86-64 -g -gdwarf-5 -O2"
+ .byte 0x1d # DW_AT_language
+ .long .LASF0 # DW_AT_name: "dwarf5b.c"
+ .long .LASF1 # DW_AT_comp_dir: "."
+ .quad .Ltext0 # DW_AT_low_pc
+ .quad .Letext0-.Ltext0 # DW_AT_high_pc
+ .long .Ldebug_line0 # DW_AT_stmt_list
+ .uleb128 0x2 # (DIE (0x2e) DW_TAG_variable)
+ .long .LASF2 # DW_AT_name: "global"
+ .byte 0x1 # DW_AT_decl_file (dwarf5b.c)
+ .byte 0x3 # DW_AT_decl_line
+ .byte 0xc # DW_AT_decl_column
+ .long 0x3a # DW_AT_type
+ # DW_AT_external
+ # DW_AT_declaration
+ .uleb128 0x3 # (DIE (0x3a) DW_TAG_base_type)
+ .byte 0x4 # DW_AT_byte_size
+ .byte 0x5 # DW_AT_encoding
+ .ascii "int\0" # DW_AT_name
+ .uleb128 0x4 # (DIE (0x41) DW_TAG_subprogram)
+ # DW_AT_external
+ .ascii "foo\0" # DW_AT_name
+ .byte 0x1 # DW_AT_decl_file (dwarf5b.c)
+ .byte 0x1 # DW_AT_decl_line
+ .byte 0xd # DW_AT_decl_column
+ # DW_AT_prototyped
+ # DW_AT_declaration
+ .long 0x53 # DW_AT_sibling
+ .uleb128 0x5 # (DIE (0x4d) DW_TAG_formal_parameter)
+ .long 0x3a # DW_AT_type
+ .byte 0 # end of children of DIE 0x41
+ .uleb128 0x6 # (DIE (0x53) DW_TAG_subprogram)
+ # DW_AT_external
+ .ascii "bar\0" # DW_AT_name
+ .byte 0x1 # DW_AT_decl_file (dwarf5b.c)
+ .byte 0x6 # DW_AT_decl_line
+ .byte 0x1 # DW_AT_decl_column
+ # DW_AT_prototyped
+ .quad .LFB0 # DW_AT_low_pc
+ .quad .LFE0-.LFB0 # DW_AT_high_pc
+ .uleb128 0x1 # DW_AT_frame_base
+ .byte 0x9c # DW_OP_call_frame_cfa
+ # DW_AT_call_all_calls
+ .uleb128 0x7 # (DIE (0x6d) DW_TAG_variable)
+ .long .LASF3 # DW_AT_name: "local"
+ .byte 0x1 # DW_AT_decl_file (dwarf5b.c)
+ .byte 0x8 # DW_AT_decl_line
+ .byte 0x7 # DW_AT_decl_column
+ .long 0x3a # DW_AT_type
+ .long .LLST0 # DW_AT_location
+ .long .LVUS0 # DW_AT_GNU_locviews
+ .uleb128 0x8 # (DIE (0x81) DW_TAG_call_site)
+ .quad .LVL1 # DW_AT_call_return_pc
+ .long 0x41 # DW_AT_call_origin
+ .uleb128 0x9 # (DIE (0x8e) DW_TAG_call_site)
+ .quad .LVL2 # DW_AT_call_return_pc
+ # DW_AT_call_tail_call
+ .long 0x41 # DW_AT_call_origin
+ .uleb128 0xa # (DIE (0x9b) DW_TAG_call_site_parameter)
+ .uleb128 0x1 # DW_AT_location
+ .byte 0x55 # DW_OP_reg5
+ .uleb128 0x2 # DW_AT_call_value
+ .byte 0x8 # DW_OP_const1u
+ .byte 0x7b
+ .byte 0 # end of children of DIE 0x8e
+ .byte 0 # end of children of DIE 0x53
+ .byte 0 # end of children of DIE 0xc
+ .section .debug_abbrev,"",@progbits
+.Ldebug_abbrev0:
+ .uleb128 0x1 # (abbrev code)
+ .uleb128 0x11 # (TAG: DW_TAG_compile_unit)
+ .byte 0x1 # DW_children_yes
+ .uleb128 0x25 # (DW_AT_producer)
+ .uleb128 0xe # (DW_FORM_strp)
+ .uleb128 0x13 # (DW_AT_language)
+ .uleb128 0xb # (DW_FORM_data1)
+ .uleb128 0x3 # (DW_AT_name)
+ .uleb128 0x1f # (DW_FORM_line_strp)
+ .uleb128 0x1b # (DW_AT_comp_dir)
+ .uleb128 0x1f # (DW_FORM_line_strp)
+ .uleb128 0x11 # (DW_AT_low_pc)
+ .uleb128 0x1 # (DW_FORM_addr)
+ .uleb128 0x12 # (DW_AT_high_pc)
+ .uleb128 0x7 # (DW_FORM_data8)
+ .uleb128 0x10 # (DW_AT_stmt_list)
+ .uleb128 0x17 # (DW_FORM_sec_offset)
+ .byte 0
+ .byte 0
+ .uleb128 0x2 # (abbrev code)
+ .uleb128 0x34 # (TAG: DW_TAG_variable)
+ .byte 0 # DW_children_no
+ .uleb128 0x3 # (DW_AT_name)
+ .uleb128 0xe # (DW_FORM_strp)
+ .uleb128 0x3a # (DW_AT_decl_file)
+ .uleb128 0xb # (DW_FORM_data1)
+ .uleb128 0x3b # (DW_AT_decl_line)
+ .uleb128 0xb # (DW_FORM_data1)
+ .uleb128 0x39 # (DW_AT_decl_column)
+ .uleb128 0xb # (DW_FORM_data1)
+ .uleb128 0x49 # (DW_AT_type)
+ .uleb128 0x13 # (DW_FORM_ref4)
+ .uleb128 0x3f # (DW_AT_external)
+ .uleb128 0x19 # (DW_FORM_flag_present)
+ .uleb128 0x3c # (DW_AT_declaration)
+ .uleb128 0x19 # (DW_FORM_flag_present)
+ .byte 0
+ .byte 0
+ .uleb128 0x3 # (abbrev code)
+ .uleb128 0x24 # (TAG: DW_TAG_base_type)
+ .byte 0 # DW_children_no
+ .uleb128 0xb # (DW_AT_byte_size)
+ .uleb128 0xb # (DW_FORM_data1)
+ .uleb128 0x3e # (DW_AT_encoding)
+ .uleb128 0xb # (DW_FORM_data1)
+ .uleb128 0x3 # (DW_AT_name)
+ .uleb128 0x8 # (DW_FORM_string)
+ .byte 0
+ .byte 0
+ .uleb128 0x4 # (abbrev code)
+ .uleb128 0x2e # (TAG: DW_TAG_subprogram)
+ .byte 0x1 # DW_children_yes
+ .uleb128 0x3f # (DW_AT_external)
+ .uleb128 0x19 # (DW_FORM_flag_present)
+ .uleb128 0x3 # (DW_AT_name)
+ .uleb128 0x8 # (DW_FORM_string)
+ .uleb128 0x3a # (DW_AT_decl_file)
+ .uleb128 0xb # (DW_FORM_data1)
+ .uleb128 0x3b # (DW_AT_decl_line)
+ .uleb128 0xb # (DW_FORM_data1)
+ .uleb128 0x39 # (DW_AT_decl_column)
+ .uleb128 0xb # (DW_FORM_data1)
+ .uleb128 0x27 # (DW_AT_prototyped)
+ .uleb128 0x19 # (DW_FORM_flag_present)
+ .uleb128 0x3c # (DW_AT_declaration)
+ .uleb128 0x19 # (DW_FORM_flag_present)
+ .uleb128 0x1 # (DW_AT_sibling)
+ .uleb128 0x13 # (DW_FORM_ref4)
+ .byte 0
+ .byte 0
+ .uleb128 0x5 # (abbrev code)
+ .uleb128 0x5 # (TAG: DW_TAG_formal_parameter)
+ .byte 0 # DW_children_no
+ .uleb128 0x49 # (DW_AT_type)
+ .uleb128 0x13 # (DW_FORM_ref4)
+ .byte 0
+ .byte 0
+ .uleb128 0x6 # (abbrev code)
+ .uleb128 0x2e # (TAG: DW_TAG_subprogram)
+ .byte 0x1 # DW_children_yes
+ .uleb128 0x3f # (DW_AT_external)
+ .uleb128 0x19 # (DW_FORM_flag_present)
+ .uleb128 0x3 # (DW_AT_name)
+ .uleb128 0x8 # (DW_FORM_string)
+ .uleb128 0x3a # (DW_AT_decl_file)
+ .uleb128 0xb # (DW_FORM_data1)
+ .uleb128 0x3b # (DW_AT_decl_line)
+ .uleb128 0xb # (DW_FORM_data1)
+ .uleb128 0x39 # (DW_AT_decl_column)
+ .uleb128 0xb # (DW_FORM_data1)
+ .uleb128 0x27 # (DW_AT_prototyped)
+ .uleb128 0x19 # (DW_FORM_flag_present)
+ .uleb128 0x11 # (DW_AT_low_pc)
+ .uleb128 0x1 # (DW_FORM_addr)
+ .uleb128 0x12 # (DW_AT_high_pc)
+ .uleb128 0x7 # (DW_FORM_data8)
+ .uleb128 0x40 # (DW_AT_frame_base)
+ .uleb128 0x18 # (DW_FORM_exprloc)
+ .uleb128 0x7a # (DW_AT_call_all_calls)
+ .uleb128 0x19 # (DW_FORM_flag_present)
+ .byte 0
+ .byte 0
+ .uleb128 0x7 # (abbrev code)
+ .uleb128 0x34 # (TAG: DW_TAG_variable)
+ .byte 0 # DW_children_no
+ .uleb128 0x3 # (DW_AT_name)
+ .uleb128 0xe # (DW_FORM_strp)
+ .uleb128 0x3a # (DW_AT_decl_file)
+ .uleb128 0xb # (DW_FORM_data1)
+ .uleb128 0x3b # (DW_AT_decl_line)
+ .uleb128 0xb # (DW_FORM_data1)
+ .uleb128 0x39 # (DW_AT_decl_column)
+ .uleb128 0xb # (DW_FORM_data1)
+ .uleb128 0x49 # (DW_AT_type)
+ .uleb128 0x13 # (DW_FORM_ref4)
+ .uleb128 0x2 # (DW_AT_location)
+ .uleb128 0x17 # (DW_FORM_sec_offset)
+ .uleb128 0x2137 # (DW_AT_GNU_locviews)
+ .uleb128 0x17 # (DW_FORM_sec_offset)
+ .byte 0
+ .byte 0
+ .uleb128 0x8 # (abbrev code)
+ .uleb128 0x48 # (TAG: DW_TAG_call_site)
+ .byte 0 # DW_children_no
+ .uleb128 0x7d # (DW_AT_call_return_pc)
+ .uleb128 0x1 # (DW_FORM_addr)
+ .uleb128 0x7f # (DW_AT_call_origin)
+ .uleb128 0x13 # (DW_FORM_ref4)
+ .byte 0
+ .byte 0
+ .uleb128 0x9 # (abbrev code)
+ .uleb128 0x48 # (TAG: DW_TAG_call_site)
+ .byte 0x1 # DW_children_yes
+ .uleb128 0x7d # (DW_AT_call_return_pc)
+ .uleb128 0x1 # (DW_FORM_addr)
+ .uleb128 0x82 # (DW_AT_call_tail_call)
+ .uleb128 0x19 # (DW_FORM_flag_present)
+ .uleb128 0x7f # (DW_AT_call_origin)
+ .uleb128 0x13 # (DW_FORM_ref4)
+ .byte 0
+ .byte 0
+ .uleb128 0xa # (abbrev code)
+ .uleb128 0x49 # (TAG: DW_TAG_call_site_parameter)
+ .byte 0 # DW_children_no
+ .uleb128 0x2 # (DW_AT_location)
+ .uleb128 0x18 # (DW_FORM_exprloc)
+ .uleb128 0x7e # (DW_AT_call_value)
+ .uleb128 0x18 # (DW_FORM_exprloc)
+ .byte 0
+ .byte 0
+ .byte 0
+ .section .debug_loclists,"",@progbits
+ .long .Ldebug_loc3-.Ldebug_loc2 # Length of Location Lists
+.Ldebug_loc2:
+ .value 0x5 # DWARF version number
+ .byte 0x8 # Address Size
+ .byte 0 # Segment Size
+ .long 0 # Offset Entry Count
+.Ldebug_loc0:
+.LVUS0:
+ .uleb128 .LVU6 # View list begin (*.LVUS0)
+ .uleb128 0 # View list end (*.LVUS0)
+.LLST0:
+ .byte 0x4 # DW_LLE_offset_pair (*.LLST0)
+ .uleb128 .LVL1-.Ltext0 # Location list begin address (*.LLST0)
+ .uleb128 .LFE0-.Ltext0 # Location list end address (*.LLST0)
+ .uleb128 0x3 # Location expression size
+ .byte 0x8 # DW_OP_const1u
+ .byte 0x7b
+ .byte 0x9f # DW_OP_stack_value
+ .byte 0 # DW_LLE_end_of_list (*.LLST0)
+.Ldebug_loc3:
+ .section .debug_aranges,"",@progbits
+ .long 0x2c # Length of Address Ranges Info
+ .value 0x2 # DWARF aranges version
+ .long .Ldebug_info0 # Offset of Compilation Unit Info
+ .byte 0x8 # Size of Address
+ .byte 0 # Size of Segment Descriptor
+ .value 0 # Pad to 16 byte boundary
+ .value 0
+ .quad .Ltext0 # Address
+ .quad .Letext0-.Ltext0 # Length
+ .quad 0
+ .quad 0
+ .section .debug_line,"",@progbits
+.Ldebug_line0:
+ .section .debug_str,"MS",@progbits,1
+.LASF3:
+ .string "local"
+.LASF4:
+ .string "GNU C17 14.2.1 20240906 [releases/gcc-14 r14-10649-gaedf6f810ee] -mtune=generic -march=x86-64 -g -gdwarf-5 -O2"
+.LASF2:
+ .string "global"
+ .section .debug_line_str,"MS",@progbits,1
+.LASF1:
+ .string "."
+.LASF0:
+ .string "dwarf5b.c"
+ .ident "GCC: (GNU) 14.2.1 20240906 [releases/gcc-14 r14-10649-gaedf6f810ee]"
+ .section .note.GNU-stack,"",@progbits
diff --git a/ld/testsuite/ld-x86-64/pr32809.d b/ld/testsuite/ld-x86-64/pr32809.d
new file mode 100644
index 0000000..3affc23
--- /dev/null
+++ b/ld/testsuite/ld-x86-64/pr32809.d
@@ -0,0 +1,71 @@
+#source: dwarf5a.s
+#source: dwarf4.s
+#source: dwarf5b.s
+#as: --64
+#ld: -r -m elf_x86_64
+#readelf: --wide --debug-dump=loc
+
+Contents of the .*ebug_loc section:
+
+ Offset Begin End Expression
+
+ 00000000 v000000000000000 v000000000000000 location view pair
+ 00000002 v000000000000000 v000000000000000 location view pair
+
+ 00000004 v000000000000000 v000000000000000 views at 00000000 for:
+ 0000000000000000 000000000000000a \(DW_OP_reg5 \(rdi\)\)
+ 00000017 v000000000000000 v000000000000000 views at 00000002 for:
+ 000000000000000a 0000000000000016 \(DW_OP_GNU_entry_value: \(DW_OP_reg5 \(rdi\)\); DW_OP_stack_value\)
+ 0000002d <End of list>
+
+ 0000003d v000000000000002 v000000000000000 location view pair
+ 0000003f v000000000000000 v000000000000001 location view pair
+ 00000041 v000000000000001 v000000000000000 location view pair
+
+ 00000043 v000000000000002 v000000000000000 views at 0000003d for:
+ 0000000000000000 000000000000000a \(DW_OP_reg5 \(rdi\)\)
+ 00000056 v000000000000000 v000000000000001 views at 0000003f for:
+ 000000000000000a 000000000000000b \(DW_OP_GNU_entry_value: \(DW_OP_reg5 \(rdi\)\); DW_OP_stack_value\)
+ 0000006c v000000000000001 v000000000000000 views at 00000041 for:
+ 000000000000000b 0000000000000016 \(DW_OP_const1u: 123; DW_OP_stack_value\)
+ 00000081 <End of list>
+
+Contents of the .*ebug_loclists section:
+
+Table at Offset 0
+ Length: 0x34
+ DWARF version: 5
+ Address size: 8
+ Segment size: 0
+ Offset entries: 0
+
+ Offset Begin End Expression
+
+ 0000000c v000000000000002 v000000000000000 location view pair
+ 0000000e v000000000000001 v000000000000001 location view pair
+ 00000010 v000000000000001 v000000000000000 location view pair
+
+ 00000012 0000000000000000 \(base address\)
+ 0000001b v000000000000002 v000000000000000 views at 0000000c for:
+ 0000000000000000 000000000000000d \(DW_OP_addr: 0\)
+ 00000028 v000000000000001 v000000000000001 views at 0000000e for:
+ 000000000000000e 0000000000000018 \(DW_OP_const1u: 123; DW_OP_stack_value\)
+ 0000002f v000000000000001 v000000000000000 views at 00000010 for:
+ 0000000000000018 000000000000001f \(DW_OP_const2u: 456; DW_OP_stack_value\)
+ 00000037 <End of list>
+Table at Offset 0x38
+ Length: 0x12
+ DWARF version: 5
+ Address size: 8
+ Segment size: 0
+ Offset entries: 0
+
+ Offset Begin End Expression
+
+ 00000044 v000000000000001 v000000000000000 location view pair
+
+ 00000046 v000000000000001 v000000000000000 views at 00000044 for:
+ 000000000000002f 000000000000003d \(DW_OP_const1u: 123; DW_OP_stack_value\)
+ 0000004d <End of list>
+
+#pass
diff --git a/ld/testsuite/ld-x86-64/x86-64.exp b/ld/testsuite/ld-x86-64/x86-64.exp
index 52c4d5e..3bb88ff 100644
--- a/ld/testsuite/ld-x86-64/x86-64.exp
+++ b/ld/testsuite/ld-x86-64/x86-64.exp
@@ -563,6 +563,7 @@ run_dump_test "pr32591-3"
run_dump_test "pr32591-3-x32"
run_dump_test "pr32591-4"
run_dump_test "pr32591-4-x32"
+run_dump_test "pr32809"
if { ![skip_sframe_tests] } {
run_dump_test "sframe-simple-1"