From: Jakub Jelinek <jakub@redhat.com>
To: Glibc hackers <libc-hacker@sources.redhat.com>, geoffk@geoffk.org
Subject: PPC32 dl-machine.c bugs
Date: Mon, 07 Oct 2002 00:50:00 -0000 [thread overview]
Message-ID: <20021006222444.F3451@sunsite.ms.mff.cuni.cz> (raw)
Hi!
While looking at ppc64 dl-machine.h and comparing it
with ppc32 dl-machine.[ch], I stopped on the following two issues:
a) from ppc64/dl-machine.h I understand ppc is strict alignment machine,
ie. unaligned stores should be done one byte at a time, right?
b) finaladdr > 0x7fff && finaladdr < 0x8000 where finaladdr is uint32_t
is bogus test (always 0). It should be finaladdr > 0x7fff
&& finaladdr < 0xffff8000 (or (finaladdr + 0x8000) < 0x10000).
And __builtin_expect certainly won't hurt.
2002-10-06 Jakub Jelinek <jakub@redhat.com>
* sysdeps/powerpc/powerpc32/dl-machine.c (__process_machine_rela):
Store R_PPC_UADDR32 and R_PPC_UADDR16 one byte at a time.
Use __builtin_expect for R_PPC_ADDR24 overflow check. Fix
R_PPC_ADDR16, R_PPC_UADDR16 and R_PPC_ADDR14* overflow check, use
__builtin_expect.
--- libc/sysdeps/powerpc/powerpc32/dl-machine.c.jj 2002-09-05 10:24:12.000000000 +0200
+++ libc/sysdeps/powerpc/powerpc32/dl-machine.c 2002-10-06 22:24:41.000000000 +0200
@@ -409,25 +409,37 @@ __process_machine_rela (struct link_map
return;
case R_PPC_ADDR32:
- case R_PPC_UADDR32:
case R_PPC_GLOB_DAT:
case R_PPC_RELATIVE:
*reloc_addr = finaladdr;
return;
+ case R_PPC_UADDR32:
+ ((char *) reloc_addr)[0] = value >> 24;
+ ((char *) reloc_addr)[1] = value >> 16;
+ ((char *) reloc_addr)[2] = value >> 8;
+ ((char *) reloc_addr)[3] = value;
+ break;
+
case R_PPC_ADDR24:
- if (finaladdr > 0x01fffffc && finaladdr < 0xfe000000)
+ if (__builtin_expect (finaladdr > 0x01fffffc && finaladdr < 0xfe000000, 0))
dl_reloc_overflow (map, "R_PPC_ADDR24", reloc_addr, sym, refsym);
*reloc_addr = (*reloc_addr & 0xfc000003) | (finaladdr & 0x3fffffc);
break;
case R_PPC_ADDR16:
- case R_PPC_UADDR16:
- if (finaladdr > 0x7fff && finaladdr < 0x8000)
+ if (__builtin_expect (finaladdr > 0x7fff && finaladdr < 0xffff8000, 0))
dl_reloc_overflow (map, "R_PPC_ADDR16", reloc_addr, sym, refsym);
*(Elf32_Half*) reloc_addr = finaladdr;
break;
+ case R_PPC_UADDR16:
+ if (__builtin_expect (finaladdr > 0x7fff && finaladdr < 0xffff8000, 0))
+ dl_reloc_overflow (map, "R_PPC_UADDR16", reloc_addr, sym, refsym);
+ ((char *) reloc_addr)[0] = value >> 8;
+ ((char *) reloc_addr)[1] = value;
+ break;
+
case R_PPC_ADDR16_LO:
*(Elf32_Half*) reloc_addr = finaladdr;
break;
@@ -443,7 +455,7 @@ __process_machine_rela (struct link_map
case R_PPC_ADDR14:
case R_PPC_ADDR14_BRTAKEN:
case R_PPC_ADDR14_BRNTAKEN:
- if (finaladdr > 0x7fff && finaladdr < 0x8000)
+ if (__builtin_expect (finaladdr > 0x7fff && finaladdr < 0xffff8000, 0))
dl_reloc_overflow (map, "R_PPC_ADDR14", reloc_addr, sym, refsym);
*reloc_addr = (*reloc_addr & 0xffff0003) | (finaladdr & 0xfffc);
if (rinfo != R_PPC_ADDR14)
Jakub
reply other threads:[~2002-10-06 20:24 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20021006222444.F3451@sunsite.ms.mff.cuni.cz \
--to=jakub@redhat.com \
--cc=geoffk@geoffk.org \
--cc=libc-hacker@sources.redhat.com \
/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).