PATCH COMMITTED: Fix gold handling of relocations to discarded comdat sections

Cary Coutant ccoutant@google.com
Thu May 1 02:04:00 GMT 2008


One more fix -- I found a problem where I was using a pointer after
the object it pointed to had gone out of scope.

        * target-reloc.h (relocate_section): Fix dead-pointer bug.

Also approved off-list and committed.

-cary

Index: target-reloc.h
===================================================================
RCS file: /cvs/src/src/gold/target-reloc.h,v
retrieving revision 1.24
diff -u -p -r1.24 target-reloc.h
--- target-reloc.h	1 May 2008 01:23:21 -0000	1.24
+++ target-reloc.h	1 May 2008 01:59:17 -0000
@@ -227,9 +227,8 @@ relocate_section(
 	    {
 	      if (comdat_behavior == CB_UNDETERMINED)
 	        {
-	          const char* name =
-	            object->section_name(relinfo->data_shndx).c_str();
-	          comdat_behavior = get_comdat_behavior(name);
+	          std::string name = object->section_name(relinfo->data_shndx);
+	          comdat_behavior = get_comdat_behavior(name.c_str());
 	        }
 	      if (comdat_behavior == CB_PRETEND)
 	        {



More information about the Binutils mailing list