| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | /* $NetBSD: mdreloc.c,v 1.32 2008/07/24 04:39:26 matt Exp $ */ | | 1 | /* $NetBSD: mdreloc.c,v 1.33 2009/03/15 23:53:03 lukem Exp $ */ |
2 | | | 2 | |
3 | /* | | 3 | /* |
4 | * Copyright (c) 2001 Wasabi Systems, Inc. | | 4 | * Copyright (c) 2001 Wasabi Systems, Inc. |
5 | * All rights reserved. | | 5 | * All rights reserved. |
6 | * | | 6 | * |
7 | * Written by Frank van der Linden for Wasabi Systems, Inc. | | 7 | * Written by Frank van der Linden for Wasabi Systems, Inc. |
8 | * | | 8 | * |
9 | * Redistribution and use in source and binary forms, with or without | | 9 | * Redistribution and use in source and binary forms, with or without |
10 | * modification, are permitted provided that the following conditions | | 10 | * modification, are permitted provided that the following conditions |
11 | * are met: | | 11 | * are met: |
12 | * 1. Redistributions of source code must retain the above copyright | | 12 | * 1. Redistributions of source code must retain the above copyright |
13 | * notice, this list of conditions and the following disclaimer. | | 13 | * notice, this list of conditions and the following disclaimer. |
14 | * 2. Redistributions in binary form must reproduce the above copyright | | 14 | * 2. Redistributions in binary form must reproduce the above copyright |
| @@ -58,32 +58,31 @@ | | | @@ -58,32 +58,31 @@ |
58 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES | | 58 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES |
59 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. | | 59 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. |
60 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, | | 60 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, |
61 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT | | 61 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT |
62 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | | 62 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
63 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | | 63 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
64 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | | 64 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
65 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | | 65 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
66 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | | 66 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
67 | */ | | 67 | */ |
68 | | | 68 | |
69 | #include <sys/cdefs.h> | | 69 | #include <sys/cdefs.h> |
70 | #ifndef lint | | 70 | #ifndef lint |
71 | __RCSID("$NetBSD: mdreloc.c,v 1.32 2008/07/24 04:39:26 matt Exp $"); | | 71 | __RCSID("$NetBSD: mdreloc.c,v 1.33 2009/03/15 23:53:03 lukem Exp $"); |
72 | #endif /* not lint */ | | 72 | #endif /* not lint */ |
73 | | | 73 | |
74 | #include <sys/types.h> | | 74 | #include <sys/types.h> |
75 | #include <sys/mman.h> | | 75 | #include <sys/mman.h> |
76 | #include <err.h> | | | |
77 | #include <errno.h> | | 76 | #include <errno.h> |
78 | #include <fcntl.h> | | 77 | #include <fcntl.h> |
79 | #include <stdarg.h> | | 78 | #include <stdarg.h> |
80 | #include <stdio.h> | | 79 | #include <stdio.h> |
81 | #include <stdlib.h> | | 80 | #include <stdlib.h> |
82 | #include <string.h> | | 81 | #include <string.h> |
83 | #include <unistd.h> | | 82 | #include <unistd.h> |
84 | #include <elf.h> | | 83 | #include <elf.h> |
85 | | | 84 | |
86 | #include "debug.h" | | 85 | #include "debug.h" |
87 | #include "rtld.h" | | 86 | #include "rtld.h" |
88 | | | 87 | |
89 | void _rtld_bind_start(void); | | 88 | void _rtld_bind_start(void); |
| @@ -274,32 +273,32 @@ _rtld_relocate_plt_object(const Obj_Entr | | | @@ -274,32 +273,32 @@ _rtld_relocate_plt_object(const Obj_Entr |
274 | *where = new_value; | | 273 | *where = new_value; |
275 | | | 274 | |
276 | if (tp) | | 275 | if (tp) |
277 | *tp = new_value - rela->r_addend; | | 276 | *tp = new_value - rela->r_addend; |
278 | | | 277 | |
279 | return 0; | | 278 | return 0; |
280 | } | | 279 | } |
281 | | | 280 | |
282 | caddr_t | | 281 | caddr_t |
283 | _rtld_bind(const Obj_Entry *obj, Elf_Word reloff) | | 282 | _rtld_bind(const Obj_Entry *obj, Elf_Word reloff) |
284 | { | | 283 | { |
285 | const Elf_Rela *rela = obj->pltrela + reloff; | | 284 | const Elf_Rela *rela = obj->pltrela + reloff; |
286 | Elf_Addr new_value; | | 285 | Elf_Addr new_value; |
287 | int err; | | 286 | int error; |
288 | | | 287 | |
289 | new_value = 0; /* XXX GCC4 */ | | 288 | new_value = 0; /* XXX GCC4 */ |
290 | | | 289 | |
291 | err = _rtld_relocate_plt_object(obj, rela, &new_value); | | 290 | error = _rtld_relocate_plt_object(obj, rela, &new_value); |
292 | if (err || new_value == 0) | | 291 | if (error || new_value == 0) |
293 | _rtld_die(); | | 292 | _rtld_die(); |
294 | | | 293 | |
295 | return (caddr_t)new_value; | | 294 | return (caddr_t)new_value; |
296 | } | | 295 | } |
297 | | | 296 | |
298 | int | | 297 | int |
299 | _rtld_relocate_plt_objects(const Obj_Entry *obj) | | 298 | _rtld_relocate_plt_objects(const Obj_Entry *obj) |
300 | { | | 299 | { |
301 | const Elf_Rela *rela; | | 300 | const Elf_Rela *rela; |
302 | | | 301 | |
303 | for (rela = obj->pltrela; rela < obj->pltrelalim; rela++) | | 302 | for (rela = obj->pltrela; rela < obj->pltrelalim; rela++) |
304 | if (_rtld_relocate_plt_object(obj, rela, NULL) < 0) | | 303 | if (_rtld_relocate_plt_object(obj, rela, NULL) < 0) |
305 | return -1; | | 304 | return -1; |