This is the mail archive of the prelink@sourceware.org mailing list for the prelink 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]

Fix prelink bug with small data on PowerPC


This patch fixes a prelinker bug that appears on PowerPC with small
data.

I do not have a reduced testcase for this bug, only a large
filesystem.  The failure involves uninitialized memory reads so
reducing tests is likely to be difficult.

A binary that exemplifies the problem has exactly two copy
relocations:

10017bec R_PPC_COPY        stderr
10017bf0 R_PPC_COPY        optarg

which relate to words in successive sections:

 23 .sbss         00000004  10017bec  10017bec  00007bec  2**2
                  ALLOC
 24 .bss          00000130  10017bf0  10017bf0  00007bec  2**3
                  ALLOC

The logic for handling multiple BSS sections looks for the first copy
relocation, in a sorted list, that is outside the first section.
Because this logic uses > instead of >=, it fails to detect a
relocation pointing immediately after the end of the first section.
In this case, there are no copy relocations pointing later in the
second section, so the loop ends with i == 2 rather than with a break
and then the code starts looking at the uninitialized
cr.rela[i].r_offset value.  The fix simply makes the code use >=.

Please commit if OK.

2009-01-15  Joseph Myers  <joseph@codesourcery.com>

	* src/conflict.c (prelink_build_conflicts): Use >= not > to
	determine whether a relocation points outside the first bss
	section.

Index: src/conflict.c
===================================================================
--- src/conflict.c	(revision 164)
+++ src/conflict.c	(working copy)
@@ -651,7 +651,7 @@
 	{
 	  for (i = 1; i < cr.count; ++i)
 	    if (cr.rela[i].r_offset
-		> dso->shdr[bss1].sh_addr + dso->shdr[bss1].sh_size)
+		>= dso->shdr[bss1].sh_addr + dso->shdr[bss1].sh_size)
 	      break;
 	  if (cr.rela[i].r_offset < dso->shdr[bss2].sh_addr)
 	    {

-- 
Joseph S. Myers
joseph@codesourcery.com


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