diff options
author | Jinyang He <hejinyang@loongson.cn> | 2024-07-08 11:27:52 +0800 |
---|---|---|
committer | liuzhensong <liuzhensong@loongson.cn> | 2024-07-11 09:27:22 +0800 |
commit | b357aca7494f96cf3cb95f401f1614806b7071c6 (patch) | |
tree | 875111b450444bb049804f1213cd2041f1566832 /bfd | |
parent | 82ed416538c5b06bb9249ab315e3ce93deb39ad8 (diff) | |
download | binutils-b357aca7494f96cf3cb95f401f1614806b7071c6.zip binutils-b357aca7494f96cf3cb95f401f1614806b7071c6.tar.gz binutils-b357aca7494f96cf3cb95f401f1614806b7071c6.tar.bz2 |
LoongArch: Not alloc dynamic relocs if symbol is absolute
The absolute symbol should be resolved to const when link to dso or exe.
Alloc dynamic relocs will cause extra space and R_LARCH_NONE finally.
Diffstat (limited to 'bfd')
-rw-r--r-- | bfd/elfnn-loongarch.c | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/bfd/elfnn-loongarch.c b/bfd/elfnn-loongarch.c index 06eec0d..db6d419 100644 --- a/bfd/elfnn-loongarch.c +++ b/bfd/elfnn-loongarch.c @@ -899,6 +899,7 @@ loongarch_elf_check_relocs (bfd *abfd, struct bfd_link_info *info, unsigned int r_type; unsigned int r_symndx; struct elf_link_hash_entry *h; + bool is_abs_symbol = false; Elf_Internal_Sym *isym = NULL; r_symndx = ELFNN_R_SYM (rel->r_info); @@ -917,6 +918,7 @@ loongarch_elf_check_relocs (bfd *abfd, struct bfd_link_info *info, if (isym == NULL) return false; + is_abs_symbol = isym->st_shndx == SHN_ABS; if (ELF_ST_TYPE (isym->st_info) == STT_GNU_IFUNC) { h = elfNN_loongarch_get_local_sym_hash (htab, abfd, rel, true); @@ -935,6 +937,7 @@ loongarch_elf_check_relocs (bfd *abfd, struct bfd_link_info *info, while (h->root.type == bfd_link_hash_indirect || h->root.type == bfd_link_hash_warning) h = (struct elf_link_hash_entry *) h->root.u.i.link; + is_abs_symbol = bfd_is_abs_symbol (&h->root); } /* It is referenced by a non-shared object. */ @@ -1142,13 +1145,6 @@ loongarch_elf_check_relocs (bfd *abfd, struct bfd_link_info *info, && bfd_link_pic (info) && (sec->flags & SEC_ALLOC) != 0) { - bool is_abs_symbol = false; - - if (r_symndx < symtab_hdr->sh_info) - is_abs_symbol = isym->st_shndx == SHN_ABS; - else - is_abs_symbol = bfd_is_abs_symbol (&h->root); - if (!is_abs_symbol) { _bfd_error_handler @@ -1165,6 +1161,10 @@ loongarch_elf_check_relocs (bfd *abfd, struct bfd_link_info *info, case R_LARCH_JUMP_SLOT: case R_LARCH_64: + /* Resolved to const. */ + if (is_abs_symbol) + break; + need_dynreloc = 1; /* If resolved symbol is defined in this object, |