public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
* [Gold Patch] Fix Gdb Index Generation from pubnames
@ 2012-09-07 23:56 Sterling Augustine
  2012-09-10 18:05 ` Cary Coutant
  0 siblings, 1 reply; 4+ messages in thread
From: Sterling Augustine @ 2012-09-07 23:56 UTC (permalink / raw)
  To: binutils

[-- Attachment #1: Type: text/plain, Size: 818 bytes --]

The enclosed patch fixes a subtle problem with gdb_index generation
from pubnames. Currently, if the pubnames or pubtypes section of two
consecutive input relocatable objects just happen to have the same
section index and offset, Gold will silently drop the second set. This
results in an incomplete gdb index.

The enclosed patch fixes that by extending the "pub[names|types]_read"
functions to check if the object has changed as well as the section
index and field.d

OK for mainline?

Sterling


2012-09-07  Sterling Augustine  <saugustine@google.com>

	* gdb-index.cc (Gdb_index::pubnames_read): New parameter.
	(Gdb_index::pubtypes_read): New parameter.
	(Gdb_index_info_reader::read_pubnames_and_pubtypes): Add parameters
	to calls.
	* gdb-index.h (Gdb_index): New fields pubnames_object_ and
	pubtypes_object_.

[-- Attachment #2: gold.object.pubnames.patch --]
[-- Type: application/octet-stream, Size: 4184 bytes --]

2012-09-07  Sterling Augustine  <saugustine@google.com>

	* gdb-index.cc (Gdb_index::pubnames_read): New parameter.
	(Gdb_index::pubtypes_read): New parameter.
	(Gdb_index_info_reader::read_pubnames_and_pubtypes): Add parameters
	to calls.
	* gdb-index.h (Gdb_index): New fields pubnames_object_ and 
	pubtypes_object_.

Index: gdb-index.cc
===================================================================
RCS file: /cvs/src/src/gold/gdb-index.cc,v
retrieving revision 1.5
diff -d -u -r1.5 gdb-index.cc
--- gdb-index.cc	1 May 2012 19:12:21 -0000	1.5
+++ gdb-index.cc	7 Sep 2012 23:24:49 -0000
@@ -864,7 +864,8 @@
 					     &pubnames_shndx);
   if (pubnames_offset != -1)
     {
-      if (this->gdb_index_->pubnames_read(pubnames_shndx, pubnames_offset))
+      if (this->gdb_index_->pubnames_read(this->object(), pubnames_shndx,
+                                          pubnames_offset))
 	ret = true;
       else
 	{
@@ -890,7 +891,8 @@
 					     &pubtypes_shndx);
   if (pubtypes_offset != -1)
     {
-      if (this->gdb_index_->pubtypes_read(pubtypes_shndx, pubtypes_offset))
+      if (this->gdb_index_->pubtypes_read(this->object(),
+                                          pubtypes_shndx, pubtypes_offset))
 	ret = true;
       else
 	{
@@ -961,8 +963,10 @@
     symtab_offset_(0),
     cu_pool_offset_(0),
     stringpool_offset_(0),
+    pubnames_object_(NULL),
     pubnames_shndx_(0),
     pubnames_offset_(0),
+    pubtypes_object_(NULL),
     pubtypes_shndx_(0),
     pubtypes_offset_(0)
 {
@@ -1034,10 +1038,12 @@
 // OFFSET in section SHNDX
 
 bool
-Gdb_index::pubnames_read(unsigned int shndx, off_t offset)
+Gdb_index::pubnames_read(const Relobj* object, unsigned int shndx, off_t offset)
 {
-  bool ret = (this->pubnames_shndx_ == shndx
+  bool ret = (this->pubnames_object_ == object
+              && this->pubnames_shndx_ == shndx
 	      && this->pubnames_offset_ == offset);
+  this->pubnames_object_ = object;
   this->pubnames_shndx_ = shndx;
   this->pubnames_offset_ = offset;
   return ret;
@@ -1047,10 +1053,12 @@
 // OFFSET in section SHNDX
 
 bool
-Gdb_index::pubtypes_read(unsigned int shndx, off_t offset)
+Gdb_index::pubtypes_read(const Relobj* object, unsigned int shndx, off_t offset)
 {
-  bool ret = (this->pubtypes_shndx_ == shndx
+  bool ret = (this->pubtypes_object_ == object
+              && this->pubtypes_shndx_ == shndx
 	      && this->pubtypes_offset_ == offset);
+  this->pubtypes_object_ = object;
   this->pubtypes_shndx_ = shndx;
   this->pubtypes_offset_ = offset;
   return ret;
Index: gdb-index.h
===================================================================
RCS file: /cvs/src/src/gold/gdb-index.h,v
retrieving revision 1.1
diff -d -u -r1.1 gdb-index.h
--- gdb-index.h	21 Mar 2012 19:02:21 -0000	1.1
+++ gdb-index.h	7 Sep 2012 23:24:49 -0000
@@ -91,15 +91,15 @@
   void
   add_symbol(int cu_index, const char* sym_name);
 
-  // Return TRUE if we have already processed the pubnames set at
-  // OFFSET in section SHNDX
+  // Return TRUE if we have already processed the pubnames set for
+  // OBJECT at OFFSET in section SHNDX
   bool
-  pubnames_read(unsigned int shndx, off_t offset);
+  pubnames_read(const Relobj* object, unsigned int shndx, off_t offset);
 
-  // Return TRUE if we have already processed the pubtypes set at
-  // OFFSET in section SHNDX
+  // Return TRUE if we have already processed the pubtypes set for
+  // OBJECT at OFFSET in section SHNDX
   bool
-  pubtypes_read(unsigned int shndx, off_t offset);
+  pubtypes_read(const Relobj* object,  unsigned int shndx, off_t offset);
 
   // Print usage statistics.
   static void
@@ -200,10 +200,12 @@
   off_t symtab_offset_;
   off_t cu_pool_offset_;
   off_t stringpool_offset_;
-  // Section index and offset of last read pubnames section.
+  // Object, section index and offset of last read pubnames section.
+  const Relobj* pubnames_object_;
   unsigned int pubnames_shndx_;
   off_t pubnames_offset_;
-  // Section index and offset of last read pubtypes section.
+  // Object, section index and offset of last read pubtypes section.
+  const Relobj* pubtypes_object_;
   unsigned int pubtypes_shndx_;
   off_t pubtypes_offset_;
 };

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [Gold Patch] Fix Gdb Index Generation from pubnames
  2012-09-07 23:56 [Gold Patch] Fix Gdb Index Generation from pubnames Sterling Augustine
@ 2012-09-10 18:05 ` Cary Coutant
  2012-09-10 18:58   ` Ian Lance Taylor
  0 siblings, 1 reply; 4+ messages in thread
From: Cary Coutant @ 2012-09-10 18:05 UTC (permalink / raw)
  To: Sterling Augustine; +Cc: binutils

> 2012-09-07  Sterling Augustine  <saugustine@google.com>
>
>         * gdb-index.cc (Gdb_index::pubnames_read): New parameter.
>         (Gdb_index::pubtypes_read): New parameter.
>         (Gdb_index_info_reader::read_pubnames_and_pubtypes): Add parameters
>         to calls.
>         * gdb-index.h (Gdb_index): New fields pubnames_object_ and
>         pubtypes_object_.

This is fine with me. Ian needs to approve.

Thanks!

-cary

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [Gold Patch] Fix Gdb Index Generation from pubnames
  2012-09-10 18:05 ` Cary Coutant
@ 2012-09-10 18:58   ` Ian Lance Taylor
  2012-09-10 19:17     ` Sterling Augustine
  0 siblings, 1 reply; 4+ messages in thread
From: Ian Lance Taylor @ 2012-09-10 18:58 UTC (permalink / raw)
  To: Cary Coutant; +Cc: Sterling Augustine, binutils

On Mon, Sep 10, 2012 at 11:05 AM, Cary Coutant <ccoutant@google.com> wrote:
>> 2012-09-07  Sterling Augustine  <saugustine@google.com>
>>
>>         * gdb-index.cc (Gdb_index::pubnames_read): New parameter.
>>         (Gdb_index::pubtypes_read): New parameter.
>>         (Gdb_index_info_reader::read_pubnames_and_pubtypes): Add parameters
>>         to calls.
>>         * gdb-index.h (Gdb_index): New fields pubnames_object_ and
>>         pubtypes_object_.
>
> This is fine with me. Ian needs to approve.

This is OK.

Thanks.

Ian

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [Gold Patch] Fix Gdb Index Generation from pubnames
  2012-09-10 18:58   ` Ian Lance Taylor
@ 2012-09-10 19:17     ` Sterling Augustine
  0 siblings, 0 replies; 4+ messages in thread
From: Sterling Augustine @ 2012-09-10 19:17 UTC (permalink / raw)
  To: Ian Lance Taylor; +Cc: Cary Coutant, binutils

On Mon, Sep 10, 2012 at 11:57 AM, Ian Lance Taylor <iant@google.com> wrote:
> On Mon, Sep 10, 2012 at 11:05 AM, Cary Coutant <ccoutant@google.com> wrote:
>>> 2012-09-07  Sterling Augustine  <saugustine@google.com>
>>>
>>>         * gdb-index.cc (Gdb_index::pubnames_read): New parameter.
>>>         (Gdb_index::pubtypes_read): New parameter.
>>>         (Gdb_index_info_reader::read_pubnames_and_pubtypes): Add parameters
>>>         to calls.
>>>         * gdb-index.h (Gdb_index): New fields pubnames_object_ and
>>>         pubtypes_object_.
>>
>> This is fine with me. Ian needs to approve.
>
> This is OK.
>

Committed as posted.

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2012-09-10 19:17 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-09-07 23:56 [Gold Patch] Fix Gdb Index Generation from pubnames Sterling Augustine
2012-09-10 18:05 ` Cary Coutant
2012-09-10 18:58   ` Ian Lance Taylor
2012-09-10 19:17     ` Sterling Augustine

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).