diff options
author | Nick Clifton <nickc@redhat.com> | 2021-04-28 11:49:09 +0100 |
---|---|---|
committer | Nick Clifton <nickc@redhat.com> | 2021-04-28 11:49:09 +0100 |
commit | 24aebc79b16a82faef4736f4abdc7e4d95d4cc67 (patch) | |
tree | ea49e9d39592b298a0ed0297a2163a77b98cbc1e /bfd/elf.c | |
parent | edeaceda7b2f33b2c3bf78c732e67f3188e7f0b9 (diff) | |
download | gdb-24aebc79b16a82faef4736f4abdc7e4d95d4cc67.zip gdb-24aebc79b16a82faef4736f4abdc7e4d95d4cc67.tar.gz gdb-24aebc79b16a82faef4736f4abdc7e4d95d4cc67.tar.bz2 |
Stop the BFD library from treating annobin symbols as potential function symbols.
bfd * elf.c (_bfd_elf_maybe_function_sym): Do not accept annobin
symbols as potential function symbols.
* elfnn-aarch64.c (elfNN_aarch64_maybe_function_sym): Likewise.
* elf64-ppc.c (ppc64_elf_maybe_function_sym): Likewise.
* elf32-arm.c (elf32_arm_maybe_function_sym): Likewise.
ld * testsuite/ld-elf/anno-sym.s: New test source file.
* testsuite/ld-elf/anno-sym.d: New test driver.
* testsuite/ld-elf/anno-sym.l: New test error output.
Diffstat (limited to 'bfd/elf.c')
-rw-r--r-- | bfd/elf.c | 23 |
1 files changed, 17 insertions, 6 deletions
@@ -12618,19 +12618,30 @@ _bfd_elf_maybe_function_sym (const asymbol *sym, asection *sec, bfd_vma *code_off) { bfd_size_type size; + elf_symbol_type * elf_sym = (elf_symbol_type *) sym; if ((sym->flags & (BSF_SECTION_SYM | BSF_FILE | BSF_OBJECT | BSF_THREAD_LOCAL | BSF_RELC | BSF_SRELC)) != 0 || sym->section != sec) return 0; + size = (sym->flags & BSF_SYNTHETIC) ? 0 : elf_sym->internal_elf_sym.st_size; + + /* In theory we should check that the symbol's type satisfies + _bfd_elf_is_function_type(), but there are some function-like + symbols which would fail this test. (eg _start). Instead + we check for hidden, local, notype symbols with zero size. + This type of symbol is generated by the annobin plugin for gcc + and clang, and should not be considered to be a function symbol. */ + if (size == 0 + && ((sym->flags & (BSF_SYNTHETIC | BSF_LOCAL)) == BSF_LOCAL) + && ELF_ST_TYPE (elf_sym->internal_elf_sym.st_info) == STT_NOTYPE + && ELF_ST_VISIBILITY (elf_sym->internal_elf_sym.st_other) == STV_HIDDEN) + return 0; + *code_off = sym->value; - size = 0; - if (!(sym->flags & BSF_SYNTHETIC)) - size = ((elf_symbol_type *) sym)->internal_elf_sym.st_size; - if (size == 0) - size = 1; - return size; + /* Do not return 0 for the function's size. */ + return size ? size : 1; } /* Set to non-zero to enable some debug messages. */ |