diff options
author | Mark Kettenis <kettenis@cvs.openbsd.org> | 2020-07-18 16:41:44 +0000 |
---|---|---|
committer | Mark Kettenis <kettenis@cvs.openbsd.org> | 2020-07-18 16:41:44 +0000 |
commit | c5a866409242bf683ad655a4a2a8a614ab8d0084 (patch) | |
tree | 5ca3ceea1f07de1376fa6ad1d7c50ff480885d24 | |
parent | c38db0b38ae639cf72d378fceee28ed7d9d6bf55 (diff) |
Use the same names as the 64-bit PowerPC ELF ABI for the relocations.
-rw-r--r-- | libexec/ld.so/powerpc64/archdep.h | 8 | ||||
-rw-r--r-- | libexec/ld.so/powerpc64/rtld_machine.c | 20 | ||||
-rw-r--r-- | sys/arch/powerpc64/include/reloc.h | 258 |
3 files changed, 156 insertions, 130 deletions
diff --git a/libexec/ld.so/powerpc64/archdep.h b/libexec/ld.so/powerpc64/archdep.h index 953c93c77d9..0f38a2402ac 100644 --- a/libexec/ld.so/powerpc64/archdep.h +++ b/libexec/ld.so/powerpc64/archdep.h @@ -1,4 +1,4 @@ -/* $OpenBSD: archdep.h,v 1.1 2020/06/25 04:00:58 drahn Exp $ */ +/* $OpenBSD: archdep.h,v 1.2 2020/07/18 16:41:43 kettenis Exp $ */ /* * Copyright (c) 1998 Per Fogelstrom, Opsycon AB @@ -57,9 +57,9 @@ _dl_dcbf(Elf_Addr *addr) static inline void RELOC_DYN(Elf_RelA *r, const Elf_Sym *s, Elf_Addr *p, unsigned long v) { - if (ELF_R_TYPE(r->r_info) == RELOC_RELATIVE) { + if (ELF_R_TYPE(r->r_info) == R_PPC64_RELATIVE) { *p = v + r->r_addend; - } else if (ELF_R_TYPE(r->r_info) == RELOC_JMP_SLOT) { + } else if (ELF_R_TYPE(r->r_info) == R_PPC64_JMP_SLOT) { Elf_Addr val = v + s->st_value + r->r_addend - (Elf_Addr)(p); if (((val & 0xfe000000) != 0) && @@ -71,7 +71,7 @@ RELOC_DYN(Elf_RelA *r, const Elf_Sym *s, Elf_Addr *p, unsigned long v) val |= 0x48000000; *p = val; _dl_dcbf(p); - } else if (ELF_R_TYPE((r)->r_info) == RELOC_GLOB_DAT) { + } else if (ELF_R_TYPE((r)->r_info) == R_PPC64_GLOB_DAT) { *p = v + s->st_value + r->r_addend; } else { _dl_exit(6); diff --git a/libexec/ld.so/powerpc64/rtld_machine.c b/libexec/ld.so/powerpc64/rtld_machine.c index 7a862a81916..859b4166db3 100644 --- a/libexec/ld.so/powerpc64/rtld_machine.c +++ b/libexec/ld.so/powerpc64/rtld_machine.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rtld_machine.c,v 1.4 2020/07/16 21:26:18 kettenis Exp $ */ +/* $OpenBSD: rtld_machine.c,v 1.5 2020/07/18 16:41:43 kettenis Exp $ */ /* * Copyright (c) 1999 Dale Rahn @@ -93,7 +93,7 @@ _dl_md_reloc(elf_object_t *object, int rel, int relasz) type = ELF_R_TYPE(relas->r_info); - if (type == RELOC_JMP_SLOT && rel != DT_JMPREL) + if (type == R_PPC64_JMP_SLOT && rel != DT_JMPREL) continue; sym = object->dyn.symtab; @@ -108,7 +108,7 @@ _dl_md_reloc(elf_object_t *object, int rel, int relasz) sr = _dl_find_symbol(symn, SYM_SEARCH_ALL|SYM_WARNNOTFOUND| - ((type == RELOC_JMP_SLOT) ? + ((type == R_PPC64_JMP_SLOT) ? SYM_PLT:SYM_NOTPLT), sym, object); if (sr.sym == NULL) { @@ -122,7 +122,7 @@ _dl_md_reloc(elf_object_t *object, int rel, int relasz) } switch (type) { - case RELOC_ADDR64: //RELOC_64: + case R_PPC64_ADDR64: if (ELF_ST_BIND(sym->st_info) == STB_LOCAL && (ELF_ST_TYPE(sym->st_info) == STT_SECTION || ELF_ST_TYPE(sym->st_info) == STT_NOTYPE) ) { @@ -132,7 +132,7 @@ _dl_md_reloc(elf_object_t *object, int rel, int relasz) relas->r_addend; } break; - case RELOC_RELATIVE: + case R_PPC64_RELATIVE: if (ELF_ST_BIND(sym->st_info) == STB_LOCAL && (ELF_ST_TYPE(sym->st_info) == STT_SECTION || ELF_ST_TYPE(sym->st_info) == STT_NOTYPE) ) { @@ -147,8 +147,8 @@ _dl_md_reloc(elf_object_t *object, int rel, int relasz) * slots similarly to how RELOC_GLOB_DAT updates GOT * slots. */ - case RELOC_JMP_SLOT: - case RELOC_GLOB_DAT: + case R_PPC64_JMP_SLOT: + case R_PPC64_GLOB_DAT: *r_addr = prev_ooff + prev_value + relas->r_addend; break; #if 0 @@ -207,6 +207,7 @@ _dl_md_reloc(elf_object_t *object, int rel, int relasz) } break; #endif +#if 0 case RELOC_REL14_TAKEN: /* val |= 1 << (31-10) XXX? */ case RELOC_REL14: @@ -227,7 +228,8 @@ _dl_md_reloc(elf_object_t *object, int rel, int relasz) _dl_dcbf(r_addr); } break; - case RELOC_COPY: +#endif + case R_PPC64_COPY: { struct sym_res sr; /* @@ -246,7 +248,7 @@ _dl_md_reloc(elf_object_t *object, int rel, int relasz) fails++; } break; - case RELOC_NONE: + case R_PPC64_NONE: break; default: diff --git a/sys/arch/powerpc64/include/reloc.h b/sys/arch/powerpc64/include/reloc.h index 1bcee2d796d..b71841a8a6a 100644 --- a/sys/arch/powerpc64/include/reloc.h +++ b/sys/arch/powerpc64/include/reloc.h @@ -1,124 +1,148 @@ -/* $OpenBSD: reloc.h,v 1.1 2020/06/25 04:21:25 drahn Exp $ */ -/* $NetBSD: reloc.h,v 1.1 1996/09/30 16:34:33 ws Exp $ */ +/* $OpenBSD: reloc.h,v 1.2 2020/07/18 16:41:43 kettenis Exp $ */ -/*- - * Copyright (C) 1995, 1996 Wolfgang Solfrank. - * Copyright (C) 1995, 1996 TooLs GmbH. - * All rights reserved. +/* + * Copyright (c) 2020 Mark Kettenis <kettenis@openbsd.org> * - * 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. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by TooLs GmbH. - * 4. The name of TooLs GmbH may not be used to endorse or promote products - * derived from this software without specific prior written permission. + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. * - * THIS SOFTWARE IS PROVIDED BY TOOLS GMBH ``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 TOOLS GMBH 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. + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -#ifndef _POWERPC64_RELOC_H_ -#define _POWERPC64_RELOC_H_ -/* - * Quite a number of relocation types - */ -enum reloc_type { - RELOC_NONE, - RELOC_32, - RELOC_24, - RELOC_16, - RELOC_16_LO, - RELOC_16_HI, /* RELOC_ADDIS = 5 */ - RELOC_16_HA, - RELOC_14, - RELOC_14_TAKEN, - RELOC_14_NTAKEN, - RELOC_REL24, /* RELOC_BRANCH = 10 */ - RELOC_REL14, - RELOC_REL14_TAKEN, - RELOC_REL14_NTAKEN, - RELOC_GOT16, - RELOC_GOT16_LO, - RELOC_GOT16_HI, - RELOC_GOT16_HA, - RELOC_PLT24, - RELOC_COPY, - RELOC_GLOB_DAT, - RELOC_JMP_SLOT, - RELOC_RELATIVE, - RELOC_LOCAL24PC, - RELOC_U32, - RELOC_U16, - RELOC_REL32, - RELOC_PLT32, - RELOC_PLTREL32, - RELOC_PLT16_LO, - RELOC_PLT16_HI, - RELOC_PLT16_HA, - RELOC_SDAREL, /* ABI defines this as 32nd entry, but we ignore this, at least for now */ - RELOC_SECTOFF, - RELOC_SECTOFF_LO, - RELOC_SECTOFF_HI, - RELOC_SECTOFF_HA, - RELOC_ADDR30, - RELOC_ADDR64, - RELOC_ADDR16_HIGHER, - RELOC_ADDR16_HIGHERA, - RELOC_ADDR16_HIGHEST, - RELOC_ADDR16_HIGHESTA, - RELOC_UADDR64, - RELOC_REL64, - RELOC_PLT64, - RELOC_PLTREL64, - RELOC_TOC16, - RELOC_TOC16_LO, - RELOC_TOC16_HI, - RELOC_TOC16_HA, - RELOC_TOC, - RELOC_PLTGOT16, - RELOC_PLTGOT16_LO, - RELOC_PLTGOT16_HI, - RELOC_PLTGOT16_HA, - RELOC_ADDR16_DS, - RELOC_ADDR16_LO_DS, - RELOC_GOT16_DS, - RELOC_GOT16_LO_DS, - RELOC_PLT16_LO_DS, - RELOC_SECTOFF_DS, - RELOC_SECTOFF_LO_DS, - RELOC_TOC16_DS, - RELOC_TOC16_LO_DS, - RELOC_PLTGOT16_DS, - RELOC_PLTGOT16_LO_DS, +#ifndef _MACHINE_RELOC_H_ +#define _MACHINE_RELOC_H_ + +#define R_PPC64_NONE 0 +#define R_PPC64_ADDR32 1 +#define R_PPC64_ADDR24 2 +#define R_PPC64_ADDR16 3 +#define R_PPC64_ADDR16_LO 4 +#define R_PPC64_ADDR16_HI 5 +#define R_PPC64_ADDR16_HA 6 +#define R_PPC64_ADDR14 7 + +#define R_PPC64_REL24 10 +#define R_PPC64_REL14 11 + +#define R_PPC64_GOT16 14 +#define R_PPC64_GOT16_LO 15 +#define R_PPC64_GOT16_HI 16 +#define R_PPC64_GOT16_HA 17 + +#define R_PPC64_COPY 19 +#define R_PPC64_GLOB_DAT 20 +#define R_PPC64_JMP_SLOT 21 +#define R_PPC64_RELATIVE 22 + +#define R_PPC64_UADDR32 24 +#define R_PPC64_UADDR16 25 +#define R_PPC64_REL32 26 +#define R_PPC64_PLT32 27 +#define R_PPC64_PLTREL32 28 +#define R_PPC64_PLT16_LO 29 +#define R_PPC64_PLT16_HI 30 +#define R_PPC64_PLT16_HA 31 + +#define R_PPC64_SECTOFF 33 +#define R_PPC64_SECTOFF_LO 34 +#define R_PPC64_SECTOFF_HI 35 +#define R_PPC64_SECTOFF_HA 36 +#define R_PPC64_REL30 37 +#define R_PPC64_ADDR64 38 +#define R_PPC64_ADDR16_HIGHER 39 +#define R_PPC64_ADDR16_HIGHERA 40 +#define R_PPC64_ADDR16_HIGHEST 41 +#define R_PPC64_ADDR16_HIGHESTA 42 +#define R_PPC64_UADDR64 43 +#define R_PPC64_REL64 44 +#define R_PPC64_PLT64 45 +#define R_PPC64_PLTREL64 46 +#define R_PPC64_TOC16 47 +#define R_PPC64_TOC16_LO 48 +#define R_PPC64_TOC16_HI 49 +#define R_PPC64_TOC16_HA 50 +#define R_PPC64_TOC 51 +#define R_PPC64_PLTGOT16 52 +#define R_PPC64_PLTGOT16_LO 53 +#define R_PPC64_PLTGOT16_HI 54 +#define R_PPC64_PLTGOT16_HA 55 +#define R_PPC64_ADDR16_DS 56 +#define R_PPC64_ADDR16_LO_DS 57 +#define R_PPC64_GOT16_DS 58 +#define R_PPC64_GOT16_LO_DS 59 +#define R_PPC64_PLT16_LO_DS 60 +#define R_PPC64_SECTOFF_DS 61 +#define R_PPC64_SECTOFF_LO_DS 62 +#define R_PPC64_TOC16_DS 63 +#define R_PPC64_TOC16_LO_DS 64 +#define R_PPC64_PLTGOT16_DS 65 +#define R_PPC64_PLTGOT16_LO_DS 66 +#define R_PPC64_TLS 67 +#define R_PPC64_DTPMOD64 68 +#define R_PPC64_TPREL16 69 +#define R_PPC64_TPREL16_LO 70 +#define R_PPC64_TPREL16_HI 71 +#define R_PPC64_TPREL16_HA 72 +#define R_PPC64_TPREL64 73 +#define R_PPC64_DTPREL16 74 +#define R_PPC64_DTPREL16_LO 75 +#define R_PPC64_DTPREL16_HI 76 +#define R_PPC64_DTPREL16_HA 77 +#define R_PPC64_DTPREL64 78 +#define R_PPC64_GOT_TLSGD16 79 +#define R_PPC64_GOT_TLSGD16_LO 80 +#define R_PPC64_GOT_TLSGD16_HI 81 +#define R_PPC64_GOT_TLSGD16_HA 82 +#define R_PPC64_GOT_TLSD16 83 +#define R_PPC64_GOT_TLSD16_LO 84 +#define R_PPC64_GOT_TLSD16_HI 85 +#define R_PPC64_GOT_TLSD16_HA 86 +#define R_PPC64_GOT_TPREL16_DS 87 +#define R_PPC64_GOT_TPREL16_LO_DS 88 +#define R_PPC64_GOT_TPREL16_HI 89 +#define R_PPC64_GOT_TPREL16_HA 90 +#define R_PPC64_GOT_DTPREL16_DS 91 +#define R_PPC64_GOT_DTPREL16_LO_DS 92 +#define R_PPC64_GOT_DTPREL16_HI 93 +#define R_PPC64_GOT_DTPREL16_HA 94 +#define R_PPC64_TPREL16_DS 95 +#define R_PPC64_TPREL16_LO_DS 96 +#define R_PPC64_TPREL16_HIGHER 97 +#define R_PPC64_TPREL16_HIGHERA 98 +#define R_PPC64_TPREL16_HIGHEST 99 +#define R_PPC64_TPREL16_HIGHESTA 100 +#define R_PPC64_DTPREL16_DS 101 +#define R_PPC64_DTPREL16_LO_DS 102 +#define R_PPC64_DTPREL16_HIGHER 103 +#define R_PPC64_DTPREL16_HIGHERA 104 +#define R_PPC64_DTPREL16_HIGHEST 105 +#define R_PPC64_DTPREL16_HIGHESTA 106 +#define R_PPC64_TLSGD 107 +#define R_PPC64_TLSLD 108 +#define R_PPC64_TOCSAVE 109 +#define R_PPC64_ADDR16_HIGH 110 +#define R_PPC64_ADDR16_HIGHA 111 +#define R_PPC64_TPREL16_HIGH 112 +#define R_PPC64_TPREL16_HIGHA 113 +#define R_PPC64_DTPREL16_HIGH 114 +#define R_PPC64_DTPREL16_HIGHA 115 +#define R_PPC64_REL24_NOTOC 116 +#define R_PPC64_ADDR64_LOCAL 117 +#define R_PPC64_ENTRY 118 - RELOC_TLSC = 67, - RELOC_DTPMOD32, - RELOC_TPREL16, - RELOC_TPREL16_LO, - RELOC_TPREL16_HI, - RELOC_TPREL16_HA, - RELOC_TPREL32, - RELOC_DTPREL16, - RELOC_DTPREL16_LO, - RELOC_DTPREL16_HI, - RELOC_DTPREL16_HA, - RELOC_DTPREL32, - RELOC_MAX -}; +#define R_PPC64_IRELATIVE 248 +#define R_PPC64_REL16 249 +#define R_PPC64_REL16_LO 250 +#define R_PPC64_REL16_HI 251 +#define R_PPC64_REL16_HA 252 +#define R_PPC64_GNU_VTINHERIT 253 +#define R_PPC64_GNU_VTENTRY 254 -#endif /* _POWERPC64_RELOC_H_ */ +#endif /* _MACHINE_RELOC_H_ */ |