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
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]
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>
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.
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
54 kobj_addrcheck(void *xmp
, caddr_t adr
)
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
))
63 if (mp
->bss
&& adr
>= (caddr_t
)mp
->bss
&&
64 adr
< (caddr_t
)mp
->bss
+ mp
->bss_size
)
71 * Flush instruction cache after updating text
72 * This is a nop for this machine arch.
76 kobj_sync_instruction_memory(caddr_t addr
, size_t len
)
80 * Calculate memory image required for relocable object.
84 get_progbits_size(struct module
*mp
, struct proginfo
*tp
, struct proginfo
*dp
,
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
))
99 if (shp
->sh_addr
!= 0) {
101 "%s non-zero sect addr in input file\n",
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);