mirror of
https://sourceware.org/git/binutils-gdb.git
synced 2024-11-25 19:14:52 +08:00
LoongArch: ld: Fix bug not generate plt when link a dso
Fix the bug that can not generate func@plt when linking a undefined function with cmodel=medium. Add testcase. bfd/ * elfnn-loongarch.c ld/testsuite/ld-loongarch-elf/ * cmodel-libjirl.dd * cmodel.exp * libjirl.s
This commit is contained in:
parent
044193ebf6
commit
42bd5254fb
@ -746,6 +746,12 @@ loongarch_elf_check_relocs (bfd *abfd, struct bfd_link_info *info,
|
||||
case R_LARCH_PCALA_HI20:
|
||||
if (h != NULL)
|
||||
{
|
||||
/* For pcalau12i + jirl. */
|
||||
h->needs_plt = 1;
|
||||
if (h->plt.refcount < 0)
|
||||
h->plt.refcount = 0;
|
||||
h->plt.refcount++;
|
||||
|
||||
h->non_got_ref = 1;
|
||||
h->pointer_equality_needed = 1;
|
||||
}
|
||||
|
4
ld/testsuite/ld-loongarch-elf/cmodel-libjirl.dd
Normal file
4
ld/testsuite/ld-loongarch-elf/cmodel-libjirl.dd
Normal file
@ -0,0 +1,4 @@
|
||||
.*file format.*loongarch
|
||||
#...
|
||||
[0-9a-f]+ <func@plt>:
|
||||
#pass
|
37
ld/testsuite/ld-loongarch-elf/cmodel.exp
Normal file
37
ld/testsuite/ld-loongarch-elf/cmodel.exp
Normal file
@ -0,0 +1,37 @@
|
||||
# Expect script for LoongArch ELF linker tests
|
||||
# Copyright (C) 2022 Free Software Foundation, Inc.
|
||||
#
|
||||
# This file is part of the GNU Binutils.
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation; either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
|
||||
# MA 02110-1301, USA.
|
||||
#
|
||||
|
||||
if ![istarget loongarch*-*-*] {
|
||||
return
|
||||
}
|
||||
|
||||
run_ld_link_tests [list \
|
||||
[list \
|
||||
"medium jirl plt" \
|
||||
"-shared" "" \
|
||||
"" \
|
||||
{libjirl.s} \
|
||||
[list \
|
||||
[list objdump -d cmodel-libjirl.dd] \
|
||||
] \
|
||||
"libjirl.so" \
|
||||
] \
|
||||
]
|
2
ld/testsuite/ld-loongarch-elf/libjirl.s
Normal file
2
ld/testsuite/ld-loongarch-elf/libjirl.s
Normal file
@ -0,0 +1,2 @@
|
||||
pcalau12i $r12, %pc_hi20(func)
|
||||
jirl $r1,$r12, %pc_lo12(func)
|
Loading…
Reference in New Issue
Block a user