xref: /openbsd/libexec/ld.so/i386/archdep.h (revision 1e43641e)
1*1e43641eSderaadt /*	$OpenBSD: archdep.h,v 1.24 2023/11/18 16:26:17 deraadt Exp $ */
203b27513Sdrahn 
303b27513Sdrahn /*
403b27513Sdrahn  * Copyright (c) 1998 Per Fogelstrom, Opsycon AB
503b27513Sdrahn  *
603b27513Sdrahn  * Redistribution and use in source and binary forms, with or without
703b27513Sdrahn  * modification, are permitted provided that the following conditions
803b27513Sdrahn  * are met:
903b27513Sdrahn  * 1. Redistributions of source code must retain the above copyright
1003b27513Sdrahn  *    notice, this list of conditions and the following disclaimer.
1103b27513Sdrahn  * 2. Redistributions in binary form must reproduce the above copyright
1203b27513Sdrahn  *    notice, this list of conditions and the following disclaimer in the
1303b27513Sdrahn  *    documentation and/or other materials provided with the distribution.
1403b27513Sdrahn  *
1503b27513Sdrahn  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
1603b27513Sdrahn  * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
1703b27513Sdrahn  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
1803b27513Sdrahn  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
1903b27513Sdrahn  * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
2003b27513Sdrahn  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
2103b27513Sdrahn  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
2203b27513Sdrahn  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
2303b27513Sdrahn  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
2403b27513Sdrahn  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2503b27513Sdrahn  * SUCH DAMAGE.
2603b27513Sdrahn  *
2703b27513Sdrahn  */
2803b27513Sdrahn 
2903b27513Sdrahn #ifndef _I386_ARCHDEP_H_
3003b27513Sdrahn #define _I386_ARCHDEP_H_
3103b27513Sdrahn 
3201804a41Sguenther #define	RELOC_TAG	DT_REL
3303b27513Sdrahn #define	MACHID		EM_386		/* ELF e_machine ID value checked */
3403b27513Sdrahn 
35246ef78eSguenther /* Only used in lib/csu/boot.h */
36b0714f38Sguenther #ifdef RCRT0
37b0714f38Sguenther 
3803b27513Sdrahn static inline void
RELOC_DYN(const Elf_Rel * r,const Elf_Sym * s,Elf_Addr * p,unsigned long v)39b0714f38Sguenther RELOC_DYN(const Elf_Rel *r, const Elf_Sym *s, Elf_Addr *p, unsigned long v)
4003b27513Sdrahn {
4103b27513Sdrahn 
42e3b0f1d9Sguenther 	if (ELF_R_TYPE(r->r_info) == RELOC_RELATIVE) {
4303b27513Sdrahn 		*p += v;
44e3b0f1d9Sguenther 	} else if (ELF_R_TYPE(r->r_info) == RELOC_GLOB_DAT) {
4503b27513Sdrahn 		*p += v + s->st_value;
46e3b0f1d9Sguenther 	} else if (ELF_R_TYPE(r->r_info) == RELOC_32) {
47f67a8cacSkurt 		*p += v + s->st_value;
4803b27513Sdrahn 	} else {
49*1e43641eSderaadt 		_csu_abort();
5003b27513Sdrahn 	}
5103b27513Sdrahn }
5203b27513Sdrahn 
53b0714f38Sguenther #endif /* RCRT0 */
5403b27513Sdrahn #endif /* _I386_ARCHDEP_H_ */
55