mirror of
https://github.com/bminor/binutils-gdb.git
synced 2025-11-16 12:34:43 +00:00
sframe: Allow input R_*_NONE relocations
"ld -r" generates R_*_NONE relocations in sframe section if input
relocations in sframe section are against discarded section. Allow
input R_*_NONE relocations if there are more relocation entries than
SFrame entries, instead of assuming number of SFrame entries == number
of relocation entries.
bfd/
PR ld/33127
* elf-sframe.c (sframe_decoder_init_func_bfdinfo): Allow input
R_*_NONE relocations if there are more relocation entries than
SFrame entries.
ld/
PR ld/33127
* testsuite/ld-x86-64/sframe-reloc-2a.s: New file.
* testsuite/ld-x86-64/sframe-reloc-2b.s: Likewise.
* testsuite/ld-x86-64/x86-64.exp: Run PR ld/33127 tests.
Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
(cherry picked from commit 5f9bf0cf71)
This commit is contained in:
@@ -120,7 +120,6 @@ sframe_decoder_init_func_bfdinfo (bfd *abfd,
|
||||
if ((sec->flags & SEC_LINKER_CREATED) && cookie->rels == NULL)
|
||||
return true;
|
||||
|
||||
BFD_ASSERT (cookie->rels + fde_count == cookie->relend);
|
||||
rel = cookie->rels;
|
||||
for (i = 0; i < fde_count; i++)
|
||||
{
|
||||
@@ -132,6 +131,14 @@ sframe_decoder_init_func_bfdinfo (bfd *abfd,
|
||||
rel++;
|
||||
}
|
||||
|
||||
/* If there are more relocation entries, they must be R_*_NONE which
|
||||
may be generated from relocations against discarded sections by
|
||||
ld -r. */
|
||||
for (; rel < cookie->relend; rel++)
|
||||
if (rel->r_info != 0)
|
||||
break;
|
||||
BFD_ASSERT (rel == cookie->relend);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
7
ld/testsuite/ld-x86-64/sframe-reloc-2a.s
Normal file
7
ld/testsuite/ld-x86-64/sframe-reloc-2a.s
Normal file
@@ -0,0 +1,7 @@
|
||||
.section sect, "axG", @progbits, sectgroup, comdat
|
||||
.global _start
|
||||
_start:
|
||||
.cfi_startproc
|
||||
call foo
|
||||
.cfi_endproc
|
||||
.section .note.GNU-stack,"",@progbits
|
||||
31
ld/testsuite/ld-x86-64/sframe-reloc-2b.s
Normal file
31
ld/testsuite/ld-x86-64/sframe-reloc-2b.s
Normal file
@@ -0,0 +1,31 @@
|
||||
.section sect, "axG", @progbits, sectgroup, comdat
|
||||
.cfi_startproc
|
||||
# Test intention is that LSDA must be provided by the discarded FDE.
|
||||
# DW_EH_PE_udata8 = 4
|
||||
# DW_EH_PE_udata4 = 3
|
||||
.ifdef ELF64
|
||||
.cfi_lsda 4, lsda
|
||||
.else
|
||||
.cfi_lsda 3, lsda
|
||||
.endif
|
||||
.skip 16
|
||||
.cfi_endproc
|
||||
|
||||
.text
|
||||
.globl foo
|
||||
.type foo, @function
|
||||
foo:
|
||||
.cfi_startproc
|
||||
pushq %rbp
|
||||
.cfi_def_cfa_offset 16
|
||||
.cfi_offset 6, -16
|
||||
movq %rsp, %rbp
|
||||
.cfi_def_cfa_register 6
|
||||
popq %rbp
|
||||
.cfi_def_cfa 7, 8
|
||||
ret
|
||||
.cfi_endproc
|
||||
|
||||
.section .gcc_except_table, "a", @progbits
|
||||
lsda:
|
||||
.section .note.GNU-stack,"",@progbits
|
||||
@@ -572,6 +572,27 @@ if { ![skip_sframe_tests] } {
|
||||
run_dump_test "sframe-ibt-plt-1"
|
||||
run_dump_test "sframe-pltgot-1"
|
||||
run_dump_test "sframe-pltgot-2"
|
||||
|
||||
run_ld_link_tests [list \
|
||||
[list \
|
||||
"Build sframe-reloc-2.o" \
|
||||
"-m elf_x86_64 -r" \
|
||||
"" \
|
||||
"--64 --gsframe" \
|
||||
{sframe-reloc-2a.s sframe-reloc-2b.s} \
|
||||
"" \
|
||||
"sframe-reloc-2.o" \
|
||||
] \
|
||||
[list \
|
||||
"Build sframe-reloc-2" \
|
||||
"-m elf_x86_64 tmpdir/sframe-reloc-2.o" \
|
||||
"" \
|
||||
"--64 --gsframe" \
|
||||
{dummy.s} \
|
||||
"" \
|
||||
"sframe-reloc-2" \
|
||||
] \
|
||||
]
|
||||
}
|
||||
|
||||
if ![istarget "x86_64-*-linux*"] {
|
||||
|
||||
Reference in New Issue
Block a user