aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLulu Cai <cailulu@loongson.cn>2024-04-19 10:24:52 +0800
committerliuzhensong <liuzhensong@loongson.cn>2024-04-25 09:21:19 +0800
commitb221bff7c7ca20d961a7e6b663a545384054a5be (patch)
tree9361adbb9a69bfac735f564f8ef34e60545cd92c
parent59462de44399d4db57fa12b75108caec578b816a (diff)
downloadgdb-b221bff7c7ca20d961a7e6b663a545384054a5be.zip
gdb-b221bff7c7ca20d961a7e6b663a545384054a5be.tar.gz
gdb-b221bff7c7ca20d961a7e6b663a545384054a5be.tar.bz2
LoongArch: The symbol got type can only be obtained after initialization
When scanning relocations and determining whether TLS type transition is possible, it will try to obtain the symbol got type. If the symbol got type record has not yet been allocated space and initialized, it will cause ld to crash. So when uninitialized, the symbol is set to GOT_UNKNOWN.
-rw-r--r--bfd/elfnn-loongarch.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/bfd/elfnn-loongarch.c b/bfd/elfnn-loongarch.c
index 7b493f6..fe780e3 100644
--- a/bfd/elfnn-loongarch.c
+++ b/bfd/elfnn-loongarch.c
@@ -683,7 +683,14 @@ loongarch_can_trans_tls (bfd *input_bfd,
if (! IS_LOONGARCH_TLS_TRANS_RELOC (r_type))
return false;
- symbol_tls_type = _bfd_loongarch_elf_tls_type (input_bfd, h, r_symndx);
+ /* Obtaining tls got type here may occur before
+ loongarch_elf_record_tls_and_got_reference, so it is necessary
+ to ensure that tls got type has been initialized, otherwise it
+ is set to GOT_UNKNOWN. */
+ symbol_tls_type = GOT_UNKNOWN;
+ if (_bfd_loongarch_elf_local_got_tls_type (input_bfd) || h)
+ symbol_tls_type = _bfd_loongarch_elf_tls_type (input_bfd, h, r_symndx);
+
reloc_got_type = loongarch_reloc_got_type (r_type);
if (symbol_tls_type == GOT_TLS_IE && GOT_TLS_GD_ANY_P (reloc_got_type))