dmake: do not set MAKEFLAGS=k
[unleashed/tickless.git] / arch / x86 / kernel / krtld / 64 / kobj_isa.c
blobbeac55523b0bad39672191c76c29578b8a4d277a
1 /*
2 * CDDL HEADER START
4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License, Version 1.0 only
6 * (the "License"). You may not use this file except in compliance
7 * with the License.
9 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10 * or http://www.opensolaris.org/os/licensing.
11 * See the License for the specific language governing permissions
12 * and limitations under the License.
14 * When distributing Covered Code, include this CDDL HEADER in each
15 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16 * If applicable, add the following below this CDDL HEADER, with the
17 * fields enclosed by brackets "[]" replaced with your own identifying
18 * information: Portions Copyright [yyyy] [name of copyright owner]
20 * CDDL HEADER END
23 * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
24 * Use is subject to license terms.
27 #pragma ident "%Z%%M% %I% %E% SMI"
30 * Miscellaneous ISA-specific code.
32 #include <sys/types.h>
33 #include <sys/elf.h>
34 #include <sys/kobj.h>
35 #include <sys/kobj_impl.h>
38 * Check that an ELF header corresponds to this machine's
39 * instruction set architecture. Used by kobj_load_module()
40 * to not get confused by a misplaced driver or kernel module
41 * built for a different ISA.
43 int
44 elf_mach_ok(Elf64_Ehdr *h)
46 return ((h->e_ident[EI_DATA] == ELFDATA2LSB) &&
47 (h->e_machine == EM_AMD64));
51 * return non-zero for a bad address
53 int
54 kobj_addrcheck(void *xmp, caddr_t adr)
56 struct module *mp;
58 mp = (struct module *)xmp;
60 if ((adr >= mp->text && adr < mp->text + mp->text_size) ||
61 (adr >= mp->data && adr < mp->data + mp->data_size))
62 return (0); /* ok */
63 if (mp->bss && adr >= (caddr_t)mp->bss &&
64 adr < (caddr_t)mp->bss + mp->bss_size)
65 return (0);
66 return (1);
71 * Flush instruction cache after updating text
72 * This is a nop for this machine arch.
74 /*ARGSUSED*/
75 void
76 kobj_sync_instruction_memory(caddr_t addr, size_t len)
80 * Calculate memory image required for relocable object.
82 /* ARGSUSED3 */
83 int
84 get_progbits_size(struct module *mp, struct proginfo *tp, struct proginfo *dp,
85 struct proginfo *sdp)
87 struct proginfo *pp;
88 uint_t shn;
89 Shdr *shp;
92 * loop through sections to find out how much space we need
93 * for text, data, (also bss that is already assigned)
95 for (shn = 1; shn < mp->hdr.e_shnum; shn++) {
96 shp = (Shdr *)(mp->shdrs + shn * mp->hdr.e_shentsize);
97 if (!(shp->sh_flags & SHF_ALLOC))
98 continue;
99 if (shp->sh_addr != 0) {
100 _kobj_printf(ops,
101 "%s non-zero sect addr in input file\n",
102 mp->filename);
103 return (-1);
105 pp = (shp->sh_flags & SHF_WRITE)? dp : tp;
107 if (shp->sh_addralign > pp->align)
108 pp->align = shp->sh_addralign;
109 pp->size = ALIGN(pp->size, shp->sh_addralign);
110 pp->size += ALIGN(shp->sh_size, 8);
112 tp->size = ALIGN(tp->size, 8);
113 dp->size = ALIGN(dp->size, 8);
114 return (0);