summaryrefslogtreecommitdiffstats
path: root/libexec
diff options
context:
space:
mode:
authorimp <imp@FreeBSD.org>2008-10-13 20:24:03 +0000
committerimp <imp@FreeBSD.org>2008-10-13 20:24:03 +0000
commit0d1110647354e7b0e9df7ad73bb933f29d3eb194 (patch)
treec433969e73387c6a96b5252e00f8222b100670bc /libexec
parent3226c137788c6c0c6b82bd1b88fd42a2a8ea4cb8 (diff)
downloadFreeBSD-src-0d1110647354e7b0e9df7ad73bb933f29d3eb194.zip
FreeBSD-src-0d1110647354e7b0e9df7ad73bb933f29d3eb194.tar.gz
This code has no copyright. It is fairly obvious to me that we're a
derivitive of NetBSD's mips_reloc.c, so pull in the copyright notice from there. Also, a minor tweak to load/store pointers. Other changes from NetBSD likely would be useful too... Obtained from: NetBSD
Diffstat (limited to 'libexec')
-rw-r--r--libexec/rtld-elf/mips/reloc.c62
1 files changed, 48 insertions, 14 deletions
diff --git a/libexec/rtld-elf/mips/reloc.c b/libexec/rtld-elf/mips/reloc.c
index 60003cc..dd64644 100644
--- a/libexec/rtld-elf/mips/reloc.c
+++ b/libexec/rtld-elf/mips/reloc.c
@@ -1,4 +1,33 @@
/* $NetBSD: mdreloc.c,v 1.23 2003/07/26 15:04:38 mrg Exp $ */
+/* $NetBSD: mips_reloc.c,v 1.53 2008/07/24 04:39:25 matt Exp $ */
+
+/*
+ * Copyright 1997 Michael L. Hitch <mhitch@montana.edu>
+ * Portions copyright 2002 Charles M. Hannum <root@ihack.net>
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. The name of the author may not be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
@@ -35,21 +64,33 @@ void _rtld_relocate_nonplt_self(Elf_Dyn *, Elf_Addr);
int open();
int _open();
+/*
+ * It is possible for the compiler to emit relocations for unaligned data.
+ * We handle this situation with these inlines.
+ */
+#define RELOC_ALIGNED_P(x) \
+ (((uintptr_t)(x) & (sizeof(void *) - 1)) == 0)
+
static __inline Elf_Addr
load_ptr(void *where)
{
- Elf_Addr res;
-
- memcpy(&res, where, sizeof(res));
+ if (__predict_true(RELOC_ALIGNED_P(where)))
+ return *(Elf_Addr *)where;
+ else {
+ Elf_Addr res;
- return (res);
+ (void)memcpy(&res, where, sizeof(res));
+ return res;
+ }
}
-void
+static __inline void
store_ptr(void *where, Elf_Addr val)
{
-
- memcpy(where, &val, sizeof(val));
+ if (__predict_true(RELOC_ALIGNED_P(where)))
+ *(Elf_Addr *)where = val;
+ else
+ (void)memcpy(where, &val, sizeof(val));
}
void
@@ -149,13 +190,6 @@ _mips_rtld_bind(Obj_Entry *obj, Elf_Size reloff)
}
/*
- * It is possible for the compiler to emit relocations for unaligned data.
- * We handle this situation with these inlines.
- */
-#define RELOC_ALIGNED_P(x) \
- (((uintptr_t)(x) & (sizeof(void *) - 1)) == 0)
-
-/*
* Process non-PLT relocations
*/
int
OpenPOWER on IntegriCloud