This is the mail archive of the mailing list for the GDB project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[commit] Fix incorrect relocation of blockvector address maps


objfile_relocate handles relocation of blockvector address maps incorrectly.

The current code calls addrmap_relocate in a loop, once for every block.
However, the address map is located at the block *vector*, which means
the same map is being relocated multiple times by that loop.  As the
relocation consists of adding a delta, doing this multiple times leads
to an incorrect result.

The following patch fixes this by applying the relocation only once.

Tested on powerpc64-linux, applied to mainline.



	* objfiles.c (objfile_relocate): Do not relocate the same
	BLOCKVECTOR_MAP address map multiple times.

Index: src/gdb/objfiles.c
--- src.orig/gdb/objfiles.c
+++ src/gdb/objfiles.c
@@ -570,6 +570,10 @@ objfile_relocate (struct objfile *objfil
       bv = BLOCKVECTOR (s);
+      if (BLOCKVECTOR_MAP (bv))
+	addrmap_relocate (BLOCKVECTOR_MAP (bv),
+			  ANOFFSET (delta, s->block_line_section));
       for (i = 0; i < BLOCKVECTOR_NBLOCKS (bv); ++i)
 	  struct block *b;
@@ -579,9 +583,6 @@ objfile_relocate (struct objfile *objfil
 	  b = BLOCKVECTOR_BLOCK (bv, i);
 	  BLOCK_START (b) += ANOFFSET (delta, s->block_line_section);
 	  BLOCK_END (b) += ANOFFSET (delta, s->block_line_section);
-          if (BLOCKVECTOR_MAP (bv))
-            addrmap_relocate (BLOCKVECTOR_MAP (bv),
-                              ANOFFSET (delta, s->block_line_section));
 	  ALL_BLOCK_SYMBOLS (b, iter, sym)
  Dr. Ulrich Weigand
  GNU Toolchain for Linux on System z and Cell BE

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]