diff options
author | Xi Ruoyao <xry111@mengyan1223.wang> | 2022-04-29 01:25:20 +0800 |
---|---|---|
committer | liuzhensong <liuzhensong@loongson.cn> | 2022-05-05 16:00:34 +0800 |
commit | 83c5f3aea9a0d55be73e6d5dedd653fc32f0d6d3 (patch) | |
tree | 95d4cdb6ed514118d9580fa08e032ae38fcb3d8d /bfd | |
parent | c54a62119afd6d1e25ae9b708ccd44b441891d76 (diff) | |
download | gdb-83c5f3aea9a0d55be73e6d5dedd653fc32f0d6d3.zip gdb-83c5f3aea9a0d55be73e6d5dedd653fc32f0d6d3.tar.gz gdb-83c5f3aea9a0d55be73e6d5dedd653fc32f0d6d3.tar.bz2 |
loongarch: Don't check ABI flags if no code section
Various packages (glib and gtk4 for example) produces data-only objects
using `ld -r -b binary` or `objcopy`, with no elf header flags set. But
these files also have no code sections, so they should be compatible
with all ABIs.
bfd/
* elfnn-loongarch.c (elfNN_loongarch_merge_private_bfd_data):
Skip ABI checks if the input has no code sections.
Reported-by: Wu Xiaotian <yetist@gmail.com>
Suggested-by: Wang Xuerui <i@xen0n.name>
Signed-off-by: Xi Ruoyao <xry111@mengyan1223.wang>
Diffstat (limited to 'bfd')
-rw-r--r-- | bfd/elfnn-loongarch.c | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/bfd/elfnn-loongarch.c b/bfd/elfnn-loongarch.c index 3c7268c..307757f 100644 --- a/bfd/elfnn-loongarch.c +++ b/bfd/elfnn-loongarch.c @@ -389,6 +389,27 @@ elfNN_loongarch_merge_private_bfd_data (bfd *ibfd, struct bfd_link_info *info) if (!_bfd_elf_merge_object_attributes (ibfd, info)) return false; + /* If the input BFD is not a dynamic object and it does not contain any + non-data sections, do not account its ABI. For example, various + packages produces such data-only relocatable objects with + `ld -r -b binary` or `objcopy`, and these objects have zero e_flags. + But they are compatible with all ABIs. */ + if (!(ibfd->flags & DYNAMIC)) + { + asection *sec; + bool have_code_sections = false; + for (sec = ibfd->sections; sec != NULL; sec = sec->next) + if ((bfd_section_flags (sec) + & (SEC_LOAD | SEC_CODE | SEC_HAS_CONTENTS)) + == (SEC_LOAD | SEC_CODE | SEC_HAS_CONTENTS)) + { + have_code_sections = true; + break; + } + if (!have_code_sections) + return true; + } + if (!elf_flags_init (obfd)) { elf_flags_init (obfd) = true; |