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
This commit is contained in:
parent
373bbe25ff
commit
1d178313cc
@ -1,4 +1,33 @@
|
|||||||
/* $NetBSD: mdreloc.c,v 1.23 2003/07/26 15:04:38 mrg Exp $ */
|
/* $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>
|
#include <sys/cdefs.h>
|
||||||
__FBSDID("$FreeBSD$");
|
__FBSDID("$FreeBSD$");
|
||||||
@ -35,21 +64,33 @@ void _rtld_relocate_nonplt_self(Elf_Dyn *, Elf_Addr);
|
|||||||
int open();
|
int open();
|
||||||
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
|
static __inline Elf_Addr
|
||||||
load_ptr(void *where)
|
load_ptr(void *where)
|
||||||
{
|
{
|
||||||
Elf_Addr res;
|
if (__predict_true(RELOC_ALIGNED_P(where)))
|
||||||
|
return *(Elf_Addr *)where;
|
||||||
|
else {
|
||||||
|
Elf_Addr res;
|
||||||
|
|
||||||
memcpy(&res, where, sizeof(res));
|
(void)memcpy(&res, where, sizeof(res));
|
||||||
|
return res;
|
||||||
return (res);
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
static __inline void
|
||||||
store_ptr(void *where, Elf_Addr val)
|
store_ptr(void *where, Elf_Addr val)
|
||||||
{
|
{
|
||||||
|
if (__predict_true(RELOC_ALIGNED_P(where)))
|
||||||
memcpy(where, &val, sizeof(val));
|
*(Elf_Addr *)where = val;
|
||||||
|
else
|
||||||
|
(void)memcpy(where, &val, sizeof(val));
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@ -148,13 +189,6 @@ _mips_rtld_bind(Obj_Entry *obj, Elf_Size reloff)
|
|||||||
return (Elf_Addr)target;
|
return (Elf_Addr)target;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* 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
|
* Process non-PLT relocations
|
||||||
*/
|
*/
|
||||||
|
Loading…
x
Reference in New Issue
Block a user