diff options
-rw-r--r-- | bfd/elf-bfd.h | 17 | ||||
-rw-r--r-- | bfd/elf-s390-common.c | 2 | ||||
-rw-r--r-- | bfd/elf32-arm.c | 2 | ||||
-rw-r--r-- | bfd/elf32-i386.c | 10 | ||||
-rw-r--r-- | bfd/elf32-m68k.c | 2 | ||||
-rw-r--r-- | bfd/elf32-ppc.c | 2 | ||||
-rw-r--r-- | bfd/elf32-sparc.c | 2 | ||||
-rw-r--r-- | bfd/elf64-ppc.c | 2 | ||||
-rw-r--r-- | bfd/elf64-sparc.c | 2 | ||||
-rw-r--r-- | bfd/elf64-x86-64.c | 10 | ||||
-rw-r--r-- | bfd/elfxx-aarch64.c | 2 | ||||
-rw-r--r-- | ld/testsuite/ld-i386/i386.exp | 1 | ||||
-rw-r--r-- | ld/testsuite/ld-i386/pr18815.d | 9 | ||||
-rw-r--r-- | ld/testsuite/ld-i386/pr18815.s | 15 | ||||
-rw-r--r-- | ld/testsuite/ld-x86-64/pr18815.d | 9 | ||||
-rw-r--r-- | ld/testsuite/ld-x86-64/pr18815.s | 15 | ||||
-rw-r--r-- | ld/testsuite/ld-x86-64/x86-64.exp | 1 |
17 files changed, 85 insertions, 18 deletions
diff --git a/bfd/elf-bfd.h b/bfd/elf-bfd.h index c92671a..d8d11b7 100644 --- a/bfd/elf-bfd.h +++ b/bfd/elf-bfd.h @@ -1641,6 +1641,18 @@ struct output_elf_obj_tdata bfd_boolean flags_init; }; +/* Indicate if the bfd contains symbols that have the STT_GNU_IFUNC + symbol type or STB_GNU_UNIQUE binding. Used to set the osabi + field in the ELF header structure. */ +enum elf_gnu_symbols + { + elf_gnu_symbol_none = 0, + elf_gnu_symbol_any = 1 << 0, + elf_gnu_symbol_ifunc = (elf_gnu_symbol_any | 1 << 1), + elf_gnu_symbol_unique = (elf_gnu_symbol_any | 1 << 2), + elf_gnu_symbol_all = (elf_gnu_symbol_ifunc | elf_gnu_symbol_unique) + }; + /* Some private data is stashed away for future use using the tdata pointer in the bfd structure. */ @@ -1751,10 +1763,7 @@ struct elf_obj_tdata symbols. */ bfd_boolean bad_symtab; - /* True if the bfd contains symbols that have the STT_GNU_IFUNC - symbol type or STB_GNU_UNIQUE binding. Used to set the osabi - field in the ELF header structure. */ - bfd_boolean has_gnu_symbols; + enum elf_gnu_symbols has_gnu_symbols; /* Information grabbed from an elf core file. */ struct core_elf_obj_tdata *core; diff --git a/bfd/elf-s390-common.c b/bfd/elf-s390-common.c index dc6f55b..09d4e5c 100644 --- a/bfd/elf-s390-common.c +++ b/bfd/elf-s390-common.c @@ -238,7 +238,7 @@ elf_s390_add_symbol_hook (bfd *abfd, || ELF_ST_BIND (sym->st_info) == STB_GNU_UNIQUE) && (abfd->flags & DYNAMIC) == 0 && bfd_get_flavour (info->output_bfd) == bfd_target_elf_flavour) - elf_tdata (info->output_bfd)->has_gnu_symbols = TRUE; + elf_tdata (info->output_bfd)->has_gnu_symbols = elf_gnu_symbol_any; return TRUE; } diff --git a/bfd/elf32-arm.c b/bfd/elf32-arm.c index ff69728..d313de4 100644 --- a/bfd/elf32-arm.c +++ b/bfd/elf32-arm.c @@ -15928,7 +15928,7 @@ elf32_arm_add_symbol_hook (bfd *abfd, struct bfd_link_info *info, || ELF_ST_BIND (sym->st_info) == STB_GNU_UNIQUE) && (abfd->flags & DYNAMIC) == 0 && bfd_get_flavour (info->output_bfd) == bfd_target_elf_flavour) - elf_tdata (info->output_bfd)->has_gnu_symbols = TRUE; + elf_tdata (info->output_bfd)->has_gnu_symbols = elf_gnu_symbol_any; if (elf32_arm_hash_table (info) == NULL) return FALSE; diff --git a/bfd/elf32-i386.c b/bfd/elf32-i386.c index 98902ac..3063bed 100644 --- a/bfd/elf32-i386.c +++ b/bfd/elf32-i386.c @@ -1576,6 +1576,10 @@ elf_i386_check_relocs (bfd *abfd, /* It is referenced by a non-shared object. */ h->ref_regular = 1; h->root.non_ir_ref = 1; + + if (h->type == STT_GNU_IFUNC) + elf_tdata (info->output_bfd)->has_gnu_symbols + |= elf_gnu_symbol_ifunc; } if (! elf_i386_tls_transition (info, abfd, sec, NULL, @@ -5330,11 +5334,11 @@ elf_i386_add_symbol_hook (bfd * abfd, asection ** secp ATTRIBUTE_UNUSED, bfd_vma * valp ATTRIBUTE_UNUSED) { - if ((ELF_ST_TYPE (sym->st_info) == STT_GNU_IFUNC - || ELF_ST_BIND (sym->st_info) == STB_GNU_UNIQUE) + if (ELF_ST_BIND (sym->st_info) == STB_GNU_UNIQUE && (abfd->flags & DYNAMIC) == 0 && bfd_get_flavour (info->output_bfd) == bfd_target_elf_flavour) - elf_tdata (info->output_bfd)->has_gnu_symbols = TRUE; + elf_tdata (info->output_bfd)->has_gnu_symbols + |= elf_gnu_symbol_unique; return TRUE; } diff --git a/bfd/elf32-m68k.c b/bfd/elf32-m68k.c index db0d0da..07211b5 100644 --- a/bfd/elf32-m68k.c +++ b/bfd/elf32-m68k.c @@ -4846,7 +4846,7 @@ elf_m68k_add_symbol_hook (bfd *abfd, || ELF_ST_BIND (sym->st_info) == STB_GNU_UNIQUE) && (abfd->flags & DYNAMIC) == 0 && bfd_get_flavour (info->output_bfd) == bfd_target_elf_flavour) - elf_tdata (info->output_bfd)->has_gnu_symbols = TRUE; + elf_tdata (info->output_bfd)->has_gnu_symbols = elf_gnu_symbol_any; return TRUE; } diff --git a/bfd/elf32-ppc.c b/bfd/elf32-ppc.c index fc1a854..91942ec 100644 --- a/bfd/elf32-ppc.c +++ b/bfd/elf32-ppc.c @@ -3653,7 +3653,7 @@ ppc_elf_add_symbol_hook (bfd *abfd, || ELF_ST_BIND (sym->st_info) == STB_GNU_UNIQUE) && (abfd->flags & DYNAMIC) == 0 && bfd_get_flavour (info->output_bfd) == bfd_target_elf_flavour) - elf_tdata (info->output_bfd)->has_gnu_symbols = TRUE; + elf_tdata (info->output_bfd)->has_gnu_symbols = elf_gnu_symbol_any; return TRUE; } diff --git a/bfd/elf32-sparc.c b/bfd/elf32-sparc.c index 88efe9e..8b8b601 100644 --- a/bfd/elf32-sparc.c +++ b/bfd/elf32-sparc.c @@ -184,7 +184,7 @@ elf32_sparc_add_symbol_hook (bfd * abfd, || ELF_ST_BIND (sym->st_info) == STB_GNU_UNIQUE) && (abfd->flags & DYNAMIC) == 0 && bfd_get_flavour (info->output_bfd) == bfd_target_elf_flavour) - elf_tdata (info->output_bfd)->has_gnu_symbols = TRUE; + elf_tdata (info->output_bfd)->has_gnu_symbols = elf_gnu_symbol_any; return TRUE; } diff --git a/bfd/elf64-ppc.c b/bfd/elf64-ppc.c index ef08164..e153ee4 100644 --- a/bfd/elf64-ppc.c +++ b/bfd/elf64-ppc.c @@ -4821,7 +4821,7 @@ ppc64_elf_add_symbol_hook (bfd *ibfd, || ELF_ST_BIND (isym->st_info) == STB_GNU_UNIQUE) && (ibfd->flags & DYNAMIC) == 0 && bfd_get_flavour (info->output_bfd) == bfd_target_elf_flavour) - elf_tdata (info->output_bfd)->has_gnu_symbols = TRUE; + elf_tdata (info->output_bfd)->has_gnu_symbols = elf_gnu_symbol_any; if (*sec != NULL && strcmp ((*sec)->name, ".opd") == 0) diff --git a/bfd/elf64-sparc.c b/bfd/elf64-sparc.c index 26e664e..5413891 100644 --- a/bfd/elf64-sparc.c +++ b/bfd/elf64-sparc.c @@ -430,7 +430,7 @@ elf64_sparc_add_symbol_hook (bfd *abfd, struct bfd_link_info *info, || ELF_ST_BIND (sym->st_info) == STB_GNU_UNIQUE) && (abfd->flags & DYNAMIC) == 0 && bfd_get_flavour (info->output_bfd) == bfd_target_elf_flavour) - elf_tdata (info->output_bfd)->has_gnu_symbols = TRUE; + elf_tdata (info->output_bfd)->has_gnu_symbols = elf_gnu_symbol_any; if (ELF_ST_TYPE (sym->st_info) == STT_REGISTER) { diff --git a/bfd/elf64-x86-64.c b/bfd/elf64-x86-64.c index b3c8522..2d3c55e 100644 --- a/bfd/elf64-x86-64.c +++ b/bfd/elf64-x86-64.c @@ -1723,6 +1723,10 @@ elf_x86_64_check_relocs (bfd *abfd, struct bfd_link_info *info, /* It is referenced by a non-shared object. */ h->ref_regular = 1; h->root.non_ir_ref = 1; + + if (h->type == STT_GNU_IFUNC) + elf_tdata (info->output_bfd)->has_gnu_symbols + |= elf_gnu_symbol_ifunc; } if (! elf_x86_64_tls_transition (info, abfd, sec, NULL, @@ -5873,11 +5877,11 @@ elf_x86_64_add_symbol_hook (bfd *abfd, return TRUE; } - if ((ELF_ST_TYPE (sym->st_info) == STT_GNU_IFUNC - || ELF_ST_BIND (sym->st_info) == STB_GNU_UNIQUE) + if (ELF_ST_BIND (sym->st_info) == STB_GNU_UNIQUE && (abfd->flags & DYNAMIC) == 0 && bfd_get_flavour (info->output_bfd) == bfd_target_elf_flavour) - elf_tdata (info->output_bfd)->has_gnu_symbols = TRUE; + elf_tdata (info->output_bfd)->has_gnu_symbols + |= elf_gnu_symbol_unique; return TRUE; } diff --git a/bfd/elfxx-aarch64.c b/bfd/elfxx-aarch64.c index a861773..69dac6d 100644 --- a/bfd/elfxx-aarch64.c +++ b/bfd/elfxx-aarch64.c @@ -494,7 +494,7 @@ _bfd_aarch64_elf_add_symbol_hook (bfd *abfd, struct bfd_link_info *info, || ELF_ST_BIND (sym->st_info) == STB_GNU_UNIQUE) && (abfd->flags & DYNAMIC) == 0 && bfd_get_flavour (info->output_bfd) == bfd_target_elf_flavour) - elf_tdata (info->output_bfd)->has_gnu_symbols = TRUE; + elf_tdata (info->output_bfd)->has_gnu_symbols = elf_gnu_symbol_any; return TRUE; } diff --git a/ld/testsuite/ld-i386/i386.exp b/ld/testsuite/ld-i386/i386.exp index 0dbdd1e..0a718cf 100644 --- a/ld/testsuite/ld-i386/i386.exp +++ b/ld/testsuite/ld-i386/i386.exp @@ -309,6 +309,7 @@ run_dump_test "pr14215" run_dump_test "pr17057" run_dump_test "pr17935-1" run_dump_test "pr17935-2" +run_dump_test "pr18815" # Add $PLT_CFLAGS if PLT is expected. global PLT_CFLAGS diff --git a/ld/testsuite/ld-i386/pr18815.d b/ld/testsuite/ld-i386/pr18815.d new file mode 100644 index 0000000..f49ecf7 --- /dev/null +++ b/ld/testsuite/ld-i386/pr18815.d @@ -0,0 +1,9 @@ +#name: PR ld/18815 +#as: --32 +#ld: -melf_i386 +#readelf: -h + +ELF Header: +#... + OS/ABI: UNIX - GNU +#pass diff --git a/ld/testsuite/ld-i386/pr18815.s b/ld/testsuite/ld-i386/pr18815.s new file mode 100644 index 0000000..ac3377d --- /dev/null +++ b/ld/testsuite/ld-i386/pr18815.s @@ -0,0 +1,15 @@ + .text + .type selector, %function +foo: + movl $0, %eax + ret +selector: + mov $foo, %eax + ret + .type selector, %gnu_indirect_function + .globl _start +_start: + mov $selector, %eax + call *%eax + ret + .section .note.GNU-stack,"",@progbits diff --git a/ld/testsuite/ld-x86-64/pr18815.d b/ld/testsuite/ld-x86-64/pr18815.d new file mode 100644 index 0000000..dd95b2a --- /dev/null +++ b/ld/testsuite/ld-x86-64/pr18815.d @@ -0,0 +1,9 @@ +#name: PR ld/18815 +#as: --64 +#ld: -melf_x86_64 +#readelf: -h + +ELF Header: +#... + OS/ABI: UNIX - GNU +#pass diff --git a/ld/testsuite/ld-x86-64/pr18815.s b/ld/testsuite/ld-x86-64/pr18815.s new file mode 100644 index 0000000..6ec79ba --- /dev/null +++ b/ld/testsuite/ld-x86-64/pr18815.s @@ -0,0 +1,15 @@ + .text + .type selector, %function +foo: + movl $0, %eax + ret +selector: + mov $foo, %eax + ret + .type selector, %gnu_indirect_function + .globl _start +_start: + mov $selector, %rax + call *%rax + ret + .section .note.GNU-stack,"",@progbits diff --git a/ld/testsuite/ld-x86-64/x86-64.exp b/ld/testsuite/ld-x86-64/x86-64.exp index d67ff2a..bd48cd3 100644 --- a/ld/testsuite/ld-x86-64/x86-64.exp +++ b/ld/testsuite/ld-x86-64/x86-64.exp @@ -325,6 +325,7 @@ run_dump_test "pr17935-1" run_dump_test "pr17935-2" run_dump_test "pr18160" run_dump_test "pr18176" +run_dump_test "pr18815" # Add $PLT_CFLAGS if PLT is expected. global PLT_CFLAGS |