Broke sbrk() out of rtld as part of general cleanup.
This commit is contained in:
parent
908cd9251b
commit
8b6ddcb0a3
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=846
@ -1,7 +1,7 @@
|
||||
# $Id: Makefile,v 1.5 1993/11/22 19:05:26 jkh Exp $
|
||||
# $Id: Makefile,v 1.6 1993/11/25 01:06:42 jkh Exp $
|
||||
|
||||
PROG= ld.so
|
||||
SRCS= mdprologue.S rtld.c shlib.c etc.c md.c
|
||||
SRCS= mdprologue.S sbrk.c rtld.c shlib.c etc.c md.c
|
||||
NOMAN= noman
|
||||
LDDIR?= $(.CURDIR)/..
|
||||
#PICFLAG=-pic
|
||||
@ -10,6 +10,7 @@ CFLAGS += -I$(LDDIR) -I$(.CURDIR) -I$(LDDIR)/$(MACHINE) -O $(PICFLAG) -DRTLD
|
||||
LDFLAGS = -Bshareable -Bsymbolic -assert nosymbolic
|
||||
LIBS = -lc_pic -lgcc_pic
|
||||
BINDIR= /usr/libexec
|
||||
ASFLAGS = -k
|
||||
|
||||
.PATH: $(LDDIR) $(LDDIR)/$(MACHINE)
|
||||
|
||||
@ -19,6 +20,6 @@ $(PROG):
|
||||
$(LD) -o $(PROG) $(LDFLAGS) $(OBJS) $(LIBS) $(LDADD)
|
||||
|
||||
.S.o:
|
||||
$(CPP) $(.IMPSRC) | $(AS) -k -o $(.TARGET) -
|
||||
$(CPP) $(.IMPSRC) | $(AS) $(ASFLAGS) -o $(.TARGET) -
|
||||
|
||||
.include <bsd.prog.mk>
|
||||
|
@ -27,7 +27,7 @@
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* $Id: rtld.c,v 1.9 1993/12/09 17:45:43 jkh Exp $
|
||||
* $Id: rtld.c,v 1.10 1993/12/11 20:08:39 jkh Exp $
|
||||
*/
|
||||
|
||||
#include <machine/vmparam.h>
|
||||
@ -129,7 +129,7 @@ static struct ld_entry ld_entry = {
|
||||
dlopen, dlclose, dlsym
|
||||
};
|
||||
|
||||
static void xprintf __P((char *, ...));
|
||||
void xprintf __P((char *, ...));
|
||||
static void init_brk __P((void));
|
||||
static void load_maps __P((struct crt_ldso *));
|
||||
static void map_object __P((struct link_object *, struct link_map *));
|
||||
@ -984,12 +984,6 @@ char *sym;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* Private heap functions.
|
||||
*/
|
||||
|
||||
static caddr_t curbrk;
|
||||
|
||||
void
|
||||
#if __STDC__
|
||||
xprintf(char *fmt, ...)
|
||||
@ -1010,37 +1004,3 @@ char *fmt;
|
||||
(void)write(1, buf, strlen(buf));
|
||||
va_end(ap);
|
||||
}
|
||||
|
||||
caddr_t
|
||||
sbrk(incr)
|
||||
int incr;
|
||||
{
|
||||
int fd = -1;
|
||||
|
||||
/* Round-up increment to page size */
|
||||
incr = ((incr + PAGSIZ - 1) & ~(PAGSIZ - 1));
|
||||
|
||||
#if DEBUG
|
||||
xprintf("sbrk: incr = %#x, curbrk = %#x\n", incr, curbrk);
|
||||
#endif
|
||||
|
||||
#ifdef NEED_DEV_ZERO
|
||||
fd = open("/dev/zero", O_RDWR, 0);
|
||||
if (fd == -1)
|
||||
perror("/dev/zero");
|
||||
#endif
|
||||
|
||||
if ((curbrk = mmap(0, incr,
|
||||
PROT_READ|PROT_WRITE,
|
||||
MAP_ANON|MAP_COPY, fd, 0)) == (caddr_t)-1) {
|
||||
xprintf("Cannot map anonymous memory");
|
||||
_exit(1);
|
||||
}
|
||||
|
||||
#ifdef NEED_DEV_ZERO
|
||||
close(fd);
|
||||
#endif
|
||||
|
||||
return(curbrk);
|
||||
}
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
# $Id: Makefile,v 1.5 1993/11/22 19:05:26 jkh Exp $
|
||||
# $Id: Makefile,v 1.6 1993/11/25 01:06:42 jkh Exp $
|
||||
|
||||
PROG= ld.so
|
||||
SRCS= mdprologue.S rtld.c shlib.c etc.c md.c
|
||||
SRCS= mdprologue.S sbrk.c rtld.c shlib.c etc.c md.c
|
||||
NOMAN= noman
|
||||
LDDIR?= $(.CURDIR)/..
|
||||
#PICFLAG=-pic
|
||||
@ -10,6 +10,7 @@ CFLAGS += -I$(LDDIR) -I$(.CURDIR) -I$(LDDIR)/$(MACHINE) -O $(PICFLAG) -DRTLD
|
||||
LDFLAGS = -Bshareable -Bsymbolic -assert nosymbolic
|
||||
LIBS = -lc_pic -lgcc_pic
|
||||
BINDIR= /usr/libexec
|
||||
ASFLAGS = -k
|
||||
|
||||
.PATH: $(LDDIR) $(LDDIR)/$(MACHINE)
|
||||
|
||||
@ -19,6 +20,6 @@ $(PROG):
|
||||
$(LD) -o $(PROG) $(LDFLAGS) $(OBJS) $(LIBS) $(LDADD)
|
||||
|
||||
.S.o:
|
||||
$(CPP) $(.IMPSRC) | $(AS) -k -o $(.TARGET) -
|
||||
$(CPP) $(.IMPSRC) | $(AS) $(ASFLAGS) -o $(.TARGET) -
|
||||
|
||||
.include <bsd.prog.mk>
|
||||
|
@ -27,7 +27,7 @@
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* $Id: rtld.c,v 1.9 1993/12/09 17:45:43 jkh Exp $
|
||||
* $Id: rtld.c,v 1.10 1993/12/11 20:08:39 jkh Exp $
|
||||
*/
|
||||
|
||||
#include <machine/vmparam.h>
|
||||
@ -129,7 +129,7 @@ static struct ld_entry ld_entry = {
|
||||
dlopen, dlclose, dlsym
|
||||
};
|
||||
|
||||
static void xprintf __P((char *, ...));
|
||||
void xprintf __P((char *, ...));
|
||||
static void init_brk __P((void));
|
||||
static void load_maps __P((struct crt_ldso *));
|
||||
static void map_object __P((struct link_object *, struct link_map *));
|
||||
@ -984,12 +984,6 @@ char *sym;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* Private heap functions.
|
||||
*/
|
||||
|
||||
static caddr_t curbrk;
|
||||
|
||||
void
|
||||
#if __STDC__
|
||||
xprintf(char *fmt, ...)
|
||||
@ -1010,37 +1004,3 @@ char *fmt;
|
||||
(void)write(1, buf, strlen(buf));
|
||||
va_end(ap);
|
||||
}
|
||||
|
||||
caddr_t
|
||||
sbrk(incr)
|
||||
int incr;
|
||||
{
|
||||
int fd = -1;
|
||||
|
||||
/* Round-up increment to page size */
|
||||
incr = ((incr + PAGSIZ - 1) & ~(PAGSIZ - 1));
|
||||
|
||||
#if DEBUG
|
||||
xprintf("sbrk: incr = %#x, curbrk = %#x\n", incr, curbrk);
|
||||
#endif
|
||||
|
||||
#ifdef NEED_DEV_ZERO
|
||||
fd = open("/dev/zero", O_RDWR, 0);
|
||||
if (fd == -1)
|
||||
perror("/dev/zero");
|
||||
#endif
|
||||
|
||||
if ((curbrk = mmap(0, incr,
|
||||
PROT_READ|PROT_WRITE,
|
||||
MAP_ANON|MAP_COPY, fd, 0)) == (caddr_t)-1) {
|
||||
xprintf("Cannot map anonymous memory");
|
||||
_exit(1);
|
||||
}
|
||||
|
||||
#ifdef NEED_DEV_ZERO
|
||||
close(fd);
|
||||
#endif
|
||||
|
||||
return(curbrk);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user