From: "Joseph S. Myers" <joseph@codesourcery.com>
To: prelink@sourceware.org
Subject: Fix prelink bug with small data on PowerPC
Date: Thu, 15 Jan 2009 20:35:00 -0000 [thread overview]
Message-ID: <Pine.LNX.4.64.0901152033310.15655@digraph.polyomino.org.uk> (raw)
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
next reply other threads:[~2009-01-15 20:35 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-01-15 20:35 Joseph S. Myers [this message]
2009-02-16 15:25 ` Ping " Joseph S. Myers
2009-03-02 15:21 ` Ping^2 " Joseph S. Myers
2009-04-14 14:44 ` Ping^3 " Joseph S. Myers
2009-06-01 14:04 ` Ping^4 " Joseph S. Myers
2009-10-12 14:05 ` Ping^5 " Joseph S. Myers
2009-10-19 19:07 ` Jakub Jelinek
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=Pine.LNX.4.64.0901152033310.15655@digraph.polyomino.org.uk \
--to=joseph@codesourcery.com \
--cc=prelink@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).