1# 2# CDDL HEADER START 3# 4# The contents of this file are subject to the terms of the 5# Common Development and Distribution License (the "License"). 6# You may not use this file except in compliance with the License. 7# 8# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 9# or http://www.opensolaris.org/os/licensing. 10# See the License for the specific language governing permissions 11# and limitations under the License. 12# 13# When distributing Covered Code, include this CDDL HEADER in each 14# file and include the License file at usr/src/OPENSOLARIS.LICENSE. 15# If applicable, add the following below this CDDL HEADER, with the 16# fields enclosed by brackets "[]" replaced with your own identifying 17# information: Portions Copyright [yyyy] [name of copyright owner] 18# 19# CDDL HEADER END 20# 21# 22# Copyright 2009 Sun Microsystems, Inc. All rights reserved. 23# Use is subject to license terms. 24# 25 26LIBRARY = s10_brand.a 27VERS = .1 28COBJS = s10_brand.o 29ASOBJS = s10_crt.o s10_handler.o s10_runexe.o 30OFFSETS_SRC = ../common/offsets.in 31OFFSETS_H = assym.h 32OBJECTS = $(COBJS) $(ASOBJS) 33CLOBBERFILES += $(OFFSETS_H) 34 35include ../../Makefile.s10 36include $(SRC)/lib/Makefile.lib 37 38SRCDIR = ../common 39UTSBASE = $(SRC)/uts 40 41LIBS = $(DYNLIB) 42CSRCS = $(COBJS:%o=../common/%c) 43ASSRCS = $(ASOBJS:%o=$(ISASRCDIR)/%s) 44SRCS = $(CSRCS) $(ASSRCS) 45 46# 47# Ugh, this is a gross hack. Our assembly routines uses lots of defines 48# to simplify variable access. All these defines work fine for amd64 49# compiles because when compiling for amd64 we use the GNU assembler, 50# gas. For 32-bit code we use the Sun assembler, as. Unfortunatly 51# as does not handle certian constructs that gas does. So rather than 52# make our code less readable, we'll just use gas to compile our 32-bit 53# code as well. 54# 55i386_AS = $(amd64_AS) 56 57# 58# Note that the architecture specific makefiles MUST update DYNFLAGS to 59# explicitly specify an interpreter for the brand emulation library so that we 60# use /lib/ld.so.1 or /lib/64/ld.so.1, which in a s10 zone is the Solaris 10 61# linker. This is different from some other brands where the linker that is 62# used is the native system linker (/.SUNWnative/.../ld.so.1). We have to do 63# this because the linker has a very incestuous relationship with libc and we 64# don't want to use the native linker with the s10 version of libc. (This may 65# come as a surprise to the reader, but when our library is loaded it get's 66# linked against the s10 version of libc.) Although the linker interfaces are 67# normally stable, there are examples, such as with the solaris8 brand, where 68# we could not combine the brand's libc with the native linker. Since we want 69# to run in a known configuration, we use the S10 libc/linker combination. 70# 71# There is one more non-obvious side effect of using the s10 linker that 72# should be mentioned. Since the linker is used to setup processes before 73# libc is loaded, it makes system calls directly (ie avoiding libc), and 74# it makes these system calls before our library has been initialized. 75# Since our library hasn't been initialized yet, there's no way for us 76# to intercept and emulate any of those system calls. So if any of those 77# system calls ever change in the native code such that they break the s10 78# linker then we're kinda screwed and will need to re-visit the current 79# solution. (The likely solution then will probably be to start using the 80# native linker with our brand emulation library.) 81# 82# Note that we make sure to link our brand emulation library 83# libmapmalloc. This is required because in most cases there will be two 84# copies of libc in the same process and we don't want them to fight over 85# the heap. So for our brand library we link against libmapmalloc so that 86# if we (our or copy of libc) try to allocate any memory it will be done 87# via mmap() instead of brk(). 88# 89CPPFLAGS += -D_REENTRANT -U_ASM \ 90 -I. -I../sys -I$(UTSBASE)/common/brand/solaris10 \ 91 -I$(SRC)/uts/common/fs/zfs 92CFLAGS += $(CCVERBOSE) 93# Needed to handle zfs include files 94C99MODE= -xc99=%all 95C99LMODE= -Xc99=%all 96ASFLAGS = -P $(ASFLAGS_$(CURTYPE)) -D_ASM -I. -I../sys 97DYNFLAGS += $(DYNFLAGS_$(CLASS)) 98DYNFLAGS += $(BLOCAL) $(ZNOVERSION) -Wl,-e_start 99LDLIBS += -lc -lmapmalloc 100 101.KEEP_STATE: 102 103all: $(LIBS) 104 105lint: lintcheck 106 107# 108# build the offset header before trying to compile any files. (it's included 109# by s10_misc.h, so it's needed for all objects, not just assembly ones.) 110# 111$(OBJECTS:%=pics/%): $(OFFSETS_H) 112$(OFFSETS_H): $(OFFSETS_SRC) 113 $(OFFSETS_CREATE) $(CTF_FLAGS) < $(OFFSETS_SRC) >$@ 114 115pics/%.o: $(ISASRCDIR)/%.s 116 $(COMPILE.s) -o $@ $< 117 $(POST_PROCESS_O) 118 119include $(SRC)/lib/Makefile.targ 120