aboutsummaryrefslogtreecommitdiff
path: root/bfd/elf32-i386.c
diff options
context:
space:
mode:
authorH.J. Lu <hjl.tools@gmail.com>2022-08-22 10:26:17 -0700
committerH.J. Lu <hjl.tools@gmail.com>2022-08-25 09:10:45 -0700
commit2c43d202aefb2b6f202a44bbb8a0baf251aae845 (patch)
treee5d552e5fb64a5d21202c0501d7b0780f65f140b /bfd/elf32-i386.c
parent5578fbf672ee497ea19826edeb509f4cc3e825a8 (diff)
downloadgdb-2c43d202aefb2b6f202a44bbb8a0baf251aae845.zip
gdb-2c43d202aefb2b6f202a44bbb8a0baf251aae845.tar.gz
gdb-2c43d202aefb2b6f202a44bbb8a0baf251aae845.tar.bz2
x86: Ignore protected visibility in shared libraries on Solaris
On x86, the PLT entry in executable may be used as function address for functions in shared libraries. If functions are protected, the function address used in executable can be different from the function address used in shared library. This will lead to incorrect run-time behavior if function pointer equality is needed. By default, x86 linker issues an error in this case. On Solaris, linker issued an error for struct tm *tb = (kind == CPP_time_kind::FIXED ? gmtime : localtime) (&tt); where gmtime is a protected function in libc.so. Use gmtime's PLT entry in executable as function address is safe since function pointer equality isn't needed. Ignore protected visibility in shared libraries on Solaris to disable linker error. If function pointer equality is needed, linker will silently generate executable with incorrect run-time behavior on Solaris. PR ld/29512 * elf32-i386.c (elf_i386_scan_relocs): Ignore protected visibility in shared libraries on Solaris. * elf64-x86-64.c (elf_x86_64_scan_relocs): Likewise.
Diffstat (limited to 'bfd/elf32-i386.c')
-rw-r--r--bfd/elf32-i386.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/bfd/elf32-i386.c b/bfd/elf32-i386.c
index 52b1db4..9717e2c 100644
--- a/bfd/elf32-i386.c
+++ b/bfd/elf32-i386.c
@@ -1808,7 +1808,8 @@ elf_i386_scan_relocs (bfd *abfd,
|| (sec->flags & (SEC_CODE | SEC_READONLY)) != 0)
h->plt.refcount = 1;
- if (h->pointer_equality_needed
+ if (htab->elf.target_os != is_solaris
+ && h->pointer_equality_needed
&& h->type == STT_FUNC
&& eh->def_protected
&& !SYMBOL_DEFINED_NON_SHARED_P (h)