--- /dev/null
+#as: --gsframe-3
+#source: pr32769-2.s
+#readelf: --sframe
+#ld: --gc-sections -shared
+#name: GC Multiple .text sections, remove unused
+
+#...
+\s+Num FDEs: 1
+#...
--- /dev/null
+ .section .text.foo
+ .globl foo
+ .type foo, @function
+foo:
+ .cfi_startproc
+ .byte 0
+
+ .section .text.foo.cold
+coldx:
+ .cfi_startproc
+ .cfi_def_cfa_offset 16
+ .byte 0
+ .cfi_endproc
+
+ .section .text.foo
+ .byte 0
+ .cfi_def_cfa_offset 16
+ .cfi_endproc
+ .size foo, .-foo
--- /dev/null
+#as: --gsframe-3
+#source: pr32769-2.s
+#readelf: -j .rela.sframe
+#ld: --gc-sections -r -e foo
+#name: GC Multiple .text sections, check relas
+
+Relocation section '.rela.sframe' at offset 0x[0-9a-f]+ contains 1 entry:
+\s+Offset\s+Info\s+Type\s+Sym.\s+Value\s+Sym.\s+Name\s\+\sAddend
+[0-9a-f]+\s+[0-9a-f]+\s+R_[_\w\d]+\s+[0-9a-f]+\s\.text\.foo \+ 0
\ No newline at end of file
--- /dev/null
+#as: --gsframe-3
+#source: pr32769-3.s
+#readelf: --sframe
+#ld: --gc-sections -e foo
+#name: GC Multiple .text sections, keep all
+
+#...
+\s+Num FDEs: 2
+\s+Num FREs: 3
+#...
--- /dev/null
+ .section .text.foo
+ .globl foo
+ .type foo, @function
+foo:
+ .cfi_startproc
+ .byte 0
+ .long coldx
+
+ .section .text.foo.cold
+ .type coldx, @function
+coldx:
+ .cfi_startproc
+ .cfi_def_cfa_offset 16
+ .byte 0
+ .cfi_endproc
+
+ .section .text.foo
+1: .byte 0
+ .cfi_def_cfa_offset 16
+ .cfi_endproc
+ .size foo, .-foo
--- /dev/null
+Contents of the SFrame section .sframe:
+ Header :
+
+ Version: SFRAME_VERSION_3
+#...
+ Num FDEs: 1
+ Num FREs: 1
+
+ Function Index :
+
+ func idx \[0\]: pc = 0x[0-9a-f]+, size = 1 bytes
+ STARTPC\s+CFA\s+FP\s+RA\s+
+ [0-9a-f]+\s+sp.*
+#pass
--- /dev/null
+ .text
+ .globl foo
+ .type foo, @function
+foo:
+ .cfi_startproc
+ .byte 0
+ .cfi_endproc
+ .size foo, .-foo
]
}
+set sframe_link_tests {
+ { "pr32769"
+ "--gc-sections -e foo" "" "--gsframe-3" {pr32769.s}
+ {{readelf --sframe pr32769.rd}}
+ "pr32769.x" }
+}
+
+run_ld_link_tests $sframe_link_tests
+
if {[info exists old_lc_all]} {
set env(LC_ALL) $old_lc_all
} else {
--- /dev/null
+ .text
+ .globl baz
+ .type baz, @function
+baz:
+ .cfi_startproc
+ pushq %rbp
+ .cfi_def_cfa_offset 16
+ .cfi_offset %rbp, -16
+ movq %rsp, %rbp
+ .cfi_def_cfa_register 6
+ call foo
+ popq %rbp
+ .cfi_def_cfa 7, 8
+ ret
+ .cfi_endproc
+ .size baz, .-baz
+
+ .global qux
+ .type qux, @function
+qux:
+ .cfi_startproc
+ nop
+ ret
+ .cfi_endproc
+ .size qux, .-qux
+
+ .global _start
+ .type _start,%function
+_start:
+ .cfi_startproc
+ mov bar@GOTPCREL(%rip), %rax
+ mov foo@GOTPCREL(%rip), %rax
+ .cfi_endproc
+ .size _start, . - _start
+
+ .section .note.GNU-stack,"",@progbits
--- /dev/null
+#as: --gsframe-3
+#source: sframe-foo.s
+#source: sframe-bar.s
+#source: sframe-baz.s
+#objdump: --sframe=.sframe
+#ld: --gc-sections -e _start
+#name: SFrame gc sections
+
+.*: +file format .*
+
+Contents of the SFrame section .sframe:
+ Header :
+
+ Version: SFRAME_VERSION_3
+ Flags: SFRAME_F_FDE_SORTED,
+ SFRAME_F_FDE_FUNC_START_PCREL
+ CFA fixed RA offset: -8
+ Num FDEs: 5
+ Num FREs: 14
+
+ Function Index :
+
+ func idx \[0\]: pc = 0x[0-9a-f]+, size = 53 bytes
+ STARTPC +CFA +FP +RA +
+ [0-9a-f]+ +sp\+8 +u +f +
+ [0-9a-f]+ +sp\+16 +c-16 +f +
+ [0-9a-f]+ +fp\+16 +c-16 +f +
+ [0-9a-f]+ +sp\+8 +c-16 +f +
+
+ func idx \[1\]: pc = 0x[0-9a-f]+, size = 37 bytes
+ STARTPC +CFA +FP +RA +
+ [0-9a-f]+ +sp\+8 +u +f +
+ [0-9a-f]+ +sp\+16 +c-16 +f +
+ [0-9a-f]+ +fp\+16 +c-16 +f +
+ [0-9a-f]+ +sp\+8 +c-16 +f +
+
+ func idx \[2\]: pc = 0x[0-9a-f]+, size = 11 bytes
+ STARTPC +CFA +FP +RA +
+ [0-9a-f]+ +sp\+8 +u +f +
+ [0-9a-f]+ +sp\+16 +c-16 +f +
+ [0-9a-f]+ +fp\+16 +c-16 +f +
+ [0-9a-f]+ +sp\+8 +c-16 +f +
+
+ func idx \[3\]: pc = 0x[0-9a-f]+, size = 2 bytes
+ STARTPC +CFA +FP +RA +
+ [0-9a-f]+ +sp\+8 +u +f +
+
+ func idx \[4\]: pc = 0x[0-9a-f]+, size = 14 bytes
+ STARTPC +CFA +FP +RA +
+ [0-9a-f]+ +sp\+8 +u +f +
--- /dev/null
+# --gc-sections will clean up .text.bar, and there should be no
+# SFrame stack trace information for it.
+ .section .text.start,"ax",@progbits
+ .globl start
+ .type start, @function
+start:
+ .cfi_startproc
+ jmp foo
+ .cfi_endproc
+ .size start, .-start
+
+ .section .text.foo,"ax",@progbits
+ .globl foo
+ .type foo, @function
+foo:
+ .cfi_startproc
+ pushq %rbp
+ .cfi_def_cfa_offset 16
+ .cfi_offset %rbp, -16
+ movq %rsp, %rbp
+ .cfi_def_cfa_register %rbp
+ leave
+ .cfi_def_cfa %rsp, 8
+ ret
+ .cfi_endproc
+ .size foo, .-foo
+
+ .section .text.bar,"ax",@progbits
+ .globl bar
+ .type bar, @function
+bar:
+ .cfi_startproc
+ ret
+ .cfi_endproc
+ .size bar, .-bar
--- /dev/null
+#as: --gsframe-3
+#source: sframe-gc-sections-2.s
+#objdump: --sframe=.sframe
+#ld: -r --gc-sections
+#name: SFrame gc sections II
+
+.*: +file format .*
+
+Contents of the SFrame section .sframe:
+ Header :
+
+ Version: SFRAME_VERSION_3
+#...
+ CFA fixed RA offset: -8
+ Num FDEs: 2
+ Num FREs: 5
+
+ Function Index :
+
+ func idx \[0\]: pc = 0x[0-9a-f]+, size = 5 bytes
+ STARTPC +CFA +FP +RA +
+ [0-9a-f]+ +sp\+8 +u +f +
+
+ func idx \[1\]: pc = 0x[0-9a-f]+, size = 6 bytes
+ STARTPC +CFA +FP +RA +
+ [0-9a-f]+ +sp\+8 +u +f +
+ [0-9a-f]+ +sp\+16 +c-16 +f +
+ [0-9a-f]+ +fp\+16 +c-16 +f +
+ [0-9a-f]+ +sp\+8 +c-16 +f +
--- /dev/null
+#as: --gsframe-3
+#source: sframe-gc-sections-2.s
+#objdump: --sframe=.sframe
+#ld: -T sframe-gc-sections-2b.t --gc-sections -e start
+#name: SFrame gc sections with discard EH_Frame
+
+.*: +file format .*
+
+Contents of the SFrame section .sframe:
+ Header :
+
+ Version: SFRAME_VERSION_3
+ Flags: SFRAME_F_FDE_SORTED,
+ SFRAME_F_FDE_FUNC_START_PCREL
+ CFA fixed RA offset: -8
+ Num FDEs: 2
+ Num FREs: 5
+
+ Function Index :
+
+ func idx \[0\]: pc = 0x[0-9a-f]+, size = 5 bytes
+ STARTPC +CFA +FP +RA +
+ [0-9a-f]+ +sp\+8 +u +f +
+
+ func idx \[1\]: pc = 0x[0-9a-f]+, size = 6 bytes
+ STARTPC +CFA +FP +RA +
+ [0-9a-f]+ +sp\+8 +u +f +
+ [0-9a-f]+ +sp\+16 +c-16 +f +
+ [0-9a-f]+ +fp\+16 +c-16 +f +
+ [0-9a-f]+ +sp\+8 +c-16 +f +
--- /dev/null
+# sframe-gc-sections-2b.d checks the same behaviour as
+# sframe-gc-sections-2a.d, but with a linker script that discards
+# .eh_frame sections. This testcase is keep it ensured that the two
+# section's GC behaviours are not unnecessarily inter-twined.
+
+ENTRY(_start)
+SECTIONS
+{
+ . = SIZEOF_HEADERS;
+ .text : { *(.text) }
+ .sframe : { KEEP (*(.sframe)) }
+ /* Sections to be discarded */
+ /DISCARD/ : {
+ *(.eh_frame)
+ }
+}
# Test --no-ld-generated-unwind-info
run_dump_test "sframe-command-line-2"
run_dump_test "sframe-reloc-1"
+ run_dump_test "sframe-gc-sections-1"
+ run_dump_test "sframe-gc-sections-2a"
+ run_dump_test "sframe-gc-sections-2b"
run_dump_test "sframe-plt-1"
run_dump_test "sframe-ibt-plt-1"
run_dump_test "sframe-pltgot-1"