gold: powerpc: Test whether sym is not a plugin in do_gc_mark_symbol

Message ID 20200513204726.2660-1-coffe92@gmail.com
State New
Headers show
Series
  • gold: powerpc: Test whether sym is not a plugin in do_gc_mark_symbol
Related show

Commit Message

sym->object() could be either a Plugin or Powerpc_relobj. There could
be a situation when Pluginobj would be proccessed in
ppc_object->get_opd_ent(dst_off) as Powerpc_relobj and it leads to the
segmentation fault.
---
 gold/powerpc.cc | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

-- 
2.26.0

Comments

On Wed, May 13, 2020 at 11:47:26PM +0300, Nikita Ermakov via Binutils wrote:
> --- a/gold/powerpc.cc

> +++ b/gold/powerpc.cc

> @@ -9056,7 +9056,7 @@ Target_powerpc<size, big_endian>::do_gc_mark_symbol(

>      Symbol_table* symtab,

>      Symbol* sym) const

>  {

> -  if (size == 64)

> +  if (size == 64 && sym->object()->pluginobj() == NULL)

>      {

>        Powerpc_relobj<size, big_endian>* ppc_object

>  	= static_cast<Powerpc_relobj<size, big_endian>*>(sym->object());


Thanks for the patch.  Pushed.

-- 
Alan Modra
Australia Development Lab, IBM

Patch

diff --git a/gold/powerpc.cc b/gold/powerpc.cc
index eae483212b..2010c1e3d2 100644
--- a/gold/powerpc.cc
+++ b/gold/powerpc.cc
@@ -9056,7 +9056,7 @@  Target_powerpc<size, big_endian>::do_gc_mark_symbol(
     Symbol_table* symtab,
     Symbol* sym) const
 {
-  if (size == 64)
+  if (size == 64 && sym->object()->pluginobj() == NULL)
     {
       Powerpc_relobj<size, big_endian>* ppc_object
 	= static_cast<Powerpc_relobj<size, big_endian>*>(sym->object());