🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: comp.unix.wizards
1 messages
1 total messages Started by Chris McDonald UWA Sun, 20 Mar 1994 02:17
SS-10 and SS-1/2 differences in text segment size/location?
#20983
Author: Chris McDonald UWA
Date: Sun, 20 Mar 1994 02:17
140 lines
5098 bytes
It appears (to me?) that the location of a program's data segment is
different on a SS-10 than on a SS1/2. If this is the case then I'm
hoping someone can solve my problem in determining the length of
a program's data segment (or clear my misunderstanding).
In particular, I'm trying to determine the size of a shared object's
data segment.

My understanding is that the initialized data segment commences on the
next PAGSIZ boundary after the address of etext.
From here to end should be the size of both the initialized and
uninitialized (bss) segments (using ld -p -d ...) .

The small example programs below hopefully show the problem I have.
The first file main.c dynamically loads in outer.so and reports
various addresses and the data segment length.

On a SS-1/2 the program reports "len_ds = 496 bytes", which I am happy
with, but on a SS-10 the same binary (or compiled/linked again)
reports "len_ds = 4592 bytes", exactly 4096 bytes more.
/bin/size on outer.so reports the same on both platforms.

Do I have a misunderstanding here, or are the SS-10 and SS-1/2 different
and (if so) how do I correct for it - I can detect a SS-10 with uname(2).

---

This problem is getting rather urgent, so any help will be much appreciated.
We have installed the SS-10 Jumbo patch, but it offers no success.

Thanks,

_______________________________________________________________________________
Chris McDonald                     ~|
                                   /_\
                                 -     -
                              - ========= -
 
Department of Computer Science,   AARNet: chrism@cs.anu.edu.au
Australian National University,   FTP:    cs.anu.edu.au,  150.203.23.24
Canberra, ACT, Australia, 0200.
PHONE:  ((+61) 06) 249 5693       FAX:    ((+61) 06) 249 0010


#! /bin/sh
# This is a shell archive, meaning:
# 1. Remove everything above the #! /bin/sh line.
# 2. Save the resulting text in a file.
# 3. Execute the file with /bin/sh (not csh) to create:
#	main.c
#	outer.c
# This archive created: Sun Mar 20 11:23:56 1994
export PATH; PATH=/bin:/usr/bin:$PATH
if test -f 'main.c'
then
	echo shar: "will not over-write existing file 'main.c'"
else
sed 's/^X//' << \SHAR_EOF > 'main.c'
X/*	Compile and link as:
X
X		cc -o main main.c -ldl
X */
X
X
X#include <stdio.h>
X#include <fcntl.h>
X#include <dlfcn.h>
X#include <sun4/a.out.h>
X
X#include <sys/types.h>
X#include <sys/stat.h>
X
Xstatic char *argv0;
X
Xint main(argc, argv) int argc; char **argv;
X{
X    static void dynamic_load();
X
X    argv0	= argv[0];
X    (void)dynamic_load("outer.so");
X
X    (void)exit(0);
X    return(0);
X}
X
X
Xstatic void dynamic_load(so_file) char *so_file;
X{
X    void	 *handle;
X    unsigned int dynamic_etext, dynamic_end;
X    int		 len_dataseg;
X
X    handle		= dlopen(so_file, RTLD_LAZY);
X    if(handle == NULL) {
X	(void)fprintf(stderr,"%s: NULL HANDLE from \"%s\"!\n", argv0,so_file);
X	exit(1);
X    }
X
X    dynamic_end		= (unsigned int)dlsym(handle, "end");
X    dynamic_etext	= (unsigned int)dlsym(handle, "etext");
X
X    if((dynamic_etext % PAGSIZ) != 0)
X	dynamic_etext	= ((dynamic_etext/PAGSIZ)+1)*PAGSIZ;
X
X    len_dataseg	= (unsigned int)dynamic_end - (unsigned int)dynamic_etext;
X
X    (void)fprintf(stderr,"end\t= %10u\nedata\t= %10u\netext\t= %10u\n",
X	    (unsigned int)dynamic_end,
X	    (unsigned int)dlsym(handle, "edata"),
X	    (unsigned int)dynamic_etext );
X    (void)fprintf(stderr, "len_ds\t= %10d bytes\n", len_dataseg);
X
X    /* (void)dlclose(handle); */
X}
SHAR_EOF
fi
if test -f 'outer.c'
then
	echo shar: "will not over-write existing file 'outer.c'"
else
sed 's/^X//' << \SHAR_EOF > 'outer.c'
X/*	Compile and link with:
X
X		cc -c -o outer.o outer.c
X		ld -d -p -o outer.so outer.o
X */
X
X
Xint	array[100];
X
X
Xint func()
X{
X    array[3]	= 0;
X    return 0;
X}
SHAR_EOF
fi
exit 0
#	End of shell archive
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads