Implemented 'QMAGIC' a.out format correctly, and changed the default

output to be QMAGIC.
This commit is contained in:
David Greenman 1994-01-03 18:35:54 +00:00
parent 504c39bf88
commit 1799d2585e
9 changed files with 62 additions and 45 deletions

View File

@ -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: md.c,v 1.4 1993/11/22 19:05:23 jkh Exp $
* $Id: md.c,v 1.6 1993/12/02 01:03:04 jkh Exp $
*/
#include <sys/param.h>
@ -41,6 +41,8 @@
#include "ld.h"
int netzmagic = 0;
/*
* Get relocation addend corresponding to relocation record RP
* from address ADDR
@ -96,10 +98,14 @@ md_init_header(hp, magic, flags)
struct exec *hp;
int magic, flags;
{
if (oldmagic)
hp->a_midmag = oldmagic;
else
N_SETMAGIC((*hp), magic, MID_I386, flags);
if (!netzmagic && (magic == ZMAGIC) && !(link_mode & DYNAMIC)) {
hp->a_midmag = magic;
} else {
if (netzmagic)
N_SETMAGIC_NET((*hp), magic, MID_I386, flags);
else
N_SETMAGIC((*hp), magic, MID_I386, flags);
}
/* TEXT_START depends on the value of outheader.a_entry. */
if (!(link_mode & SHAREABLE)) /*WAS: if (entry_symbol) */

View File

@ -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: md.h,v 1.5 1993/12/08 10:14:48 pk Exp $
* $Id: md.h,v 1.6 1993/12/11 12:02:05 jkh Exp $
*/
@ -45,10 +45,15 @@
#define PAGSIZ 4096
#endif
#define N_SET_FLAG(ex,f) N_SETMAGIC(ex,N_GETMAGIC(ex), MID_MACHINE, \
N_GETFLAG(ex)|(f))
#define N_IS_DYNAMIC(ex) ((N_GETFLAG(ex) & EX_DYNAMIC))
#define N_SET_FLAG(ex,f) (netzmagic ? \
N_SETMAGIC_NET(ex,N_GETMAGIC_NET(ex), MID_MACHINE, \
N_GETFLAG_NET(ex)|(f)) : \
N_SETMAGIC(ex,N_GETMAGIC(ex), MID_MACHINE, \
N_GETFLAG(ex)|(f)))
#define N_IS_DYNAMIC(ex) ((N_GETMAGIC_NET(ex) == ZMAGIC) ? \
((N_GETFLAG_NET(ex) & EX_DYNAMIC)) : \
((N_GETFLAG(ex) & EX_DYNAMIC)))
/*
* Should be handled by a.out.h ?

View File

@ -32,7 +32,7 @@ static char sccsid[] = "@(#)ld.c 6.10 (Berkeley) 5/22/91";
Set, indirect, and warning symbol features added by Randy Smith. */
/*
* $Id: ld.c,v 1.16 1993/12/11 11:58:24 jkh Exp $
* $Id: ld.c,v 1.17 1993/12/22 23:28:08 jkh Exp $
*/
/* Define how to initialize system-dependent header fields. */
@ -585,14 +585,13 @@ decode_option(swt, arg)
return;
#endif
#ifdef QMAGIC
case 'Q':
magic = oldmagic = QMAGIC;
magic = QMAGIC;
return;
case 'Z':
magic = oldmagic = ZMAGIC;
magic = ZMAGIC;
netzmagic = 1;
return;
#endif
case 'o':
output_filename = arg;
@ -658,7 +657,7 @@ decode_option(swt, arg)
return;
case 'z':
oldmagic = magic = ZMAGIC;
magic = ZMAGIC;
return;
default:
@ -1438,7 +1437,7 @@ digest_symbols ()
* the padding in the text segment size.
*/
if (magic == ZMAGIC || page_align_data) {
if (magic == ZMAGIC || magic == QMAGIC || page_align_data) {
int text_end = text_size + N_TXTOFF(outheader);
text_pad = PALIGN(text_end, page_size) - text_end;
text_size += text_pad;
@ -1491,7 +1490,7 @@ printf("bssstart = %#x, bsssize = %#x\n",
if (specified_data_size && specified_data_size > data_size)
data_pad = specified_data_size - data_size;
if (magic == ZMAGIC)
if (magic == ZMAGIC || magic == QMAGIC)
data_pad = PALIGN(data_pad + data_size, page_size) - data_size;
bss_size -= data_pad;
@ -2177,9 +2176,7 @@ write_header ()
{
int flags = (rrs_section_type == RRS_FULL) ? EX_DYNAMIC : 0;
#ifdef QMAGIC
if (!oldmagic)
#endif
if (netzmagic || magic == QMAGIC || (link_mode & DYNAMIC))
N_SET_FLAG (outheader, flags);
outheader.a_text = text_size;

View File

@ -1,4 +1,4 @@
/* $Id: ld.h,v 1.7 1993/12/04 00:52:58 jkh Exp $ */
/* $Id: ld.h,v 1.8 1993/12/11 11:58:26 jkh Exp $ */
/*-
* This code is derived from software copyrighted by the Free Software
* Foundation.
@ -54,12 +54,10 @@ char *progname;
/* Define this to specify the default executable format. */
#ifndef DEFAULT_MAGIC
#define DEFAULT_MAGIC ZMAGIC
#define DEFAULT_MAGIC QMAGIC
#endif
#ifdef QMAGIC
int oldmagic;
#endif
extern netzmagic;
/*

View File

@ -1,4 +1,4 @@
# $Id: Makefile,v 1.6 1993/11/25 01:06:42 jkh Exp $
# $Id: Makefile,v 1.7 1993/12/11 21:05:59 jkh Exp $
PROG= ld.so
SRCS= mdprologue.S sbrk.c rtld.c shlib.c etc.c md.c
@ -7,7 +7,7 @@ LDDIR?= $(.CURDIR)/..
#PICFLAG=-pic
PICFLAG=-fpic
CFLAGS += -I$(LDDIR) -I$(.CURDIR) -I$(LDDIR)/$(MACHINE) -O $(PICFLAG) -DRTLD
LDFLAGS = -Bshareable -Bsymbolic -assert nosymbolic
LDFLAGS = -Bshareable -Bsymbolic -assert nosymbolic -Z
LIBS = -lc_pic -lgcc_pic
BINDIR= /usr/libexec
ASFLAGS = -k

View File

@ -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: crt0.c,v 1.8 1993/11/04 10:51:41 pk Exp $
* $Id: crt0.c,v 1.6 1993/11/09 04:26:11 paul Exp $
*/
@ -264,7 +264,7 @@ __do_dynamic_link ()
if (read(crt.crt_ldfd, &hdr, sizeof hdr) < sizeof hdr) {
_FATAL("Failure reading ld.so\n");
}
if (N_GETMAGIC(hdr) != ZMAGIC) {
if ((N_GETMAGIC_NET(hdr) != ZMAGIC) && (N_GETMAGIC(hdr) != QMAGIC)) {
_FATAL("Bad magic: ld.so\n");
}
@ -287,7 +287,7 @@ __do_dynamic_link ()
#endif
/* Map in ld.so */
crt.crt_ba = mmap(0, hdr.a_text+hdr.a_data+hdr.a_bss,
crt.crt_ba = mmap(0, hdr.a_text,
PROT_READ|PROT_EXEC,
MAP_FILE|MAP_COPY,
crt.crt_ldfd, N_TXTOFF(hdr));
@ -308,7 +308,7 @@ __do_dynamic_link ()
/* Map in data segment of ld.so writable */
if (mmap(crt.crt_ba+N_DATADDR(hdr), hdr.a_data,
PROT_READ|PROT_EXEC|PROT_WRITE,
PROT_READ|PROT_WRITE,
MAP_FIXED|MAP_FILE|MAP_COPY,
crt.crt_ldfd, N_DATOFF(hdr)) == -1) {
_FATAL("Cannot map ld.so\n");
@ -316,7 +316,7 @@ __do_dynamic_link ()
/* Map bss segment of ld.so zero */
if (hdr.a_bss && mmap(crt.crt_ba+N_BSSADDR(hdr), hdr.a_bss,
PROT_READ|PROT_EXEC|PROT_WRITE,
PROT_READ|PROT_WRITE,
MAP_FIXED|MAP_ANON|MAP_COPY,
crt.crt_dzfd, 0) == -1) {
_FATAL("Cannot map ld.so\n");

View File

@ -1,4 +1,4 @@
# $Id: Makefile,v 1.6 1993/11/25 01:06:42 jkh Exp $
# $Id: Makefile,v 1.7 1993/12/11 21:05:59 jkh Exp $
PROG= ld.so
SRCS= mdprologue.S sbrk.c rtld.c shlib.c etc.c md.c
@ -7,7 +7,7 @@ LDDIR?= $(.CURDIR)/..
#PICFLAG=-pic
PICFLAG=-fpic
CFLAGS += -I$(LDDIR) -I$(.CURDIR) -I$(LDDIR)/$(MACHINE) -O $(PICFLAG) -DRTLD
LDFLAGS = -Bshareable -Bsymbolic -assert nosymbolic
LDFLAGS = -Bshareable -Bsymbolic -assert nosymbolic -Z
LIBS = -lc_pic -lgcc_pic
BINDIR= /usr/libexec
ASFLAGS = -k

View File

@ -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: md.c,v 1.4 1993/11/22 19:05:23 jkh Exp $
* $Id: md.c,v 1.6 1993/12/02 01:03:04 jkh Exp $
*/
#include <sys/param.h>
@ -41,6 +41,8 @@
#include "ld.h"
int netzmagic = 0;
/*
* Get relocation addend corresponding to relocation record RP
* from address ADDR
@ -96,10 +98,14 @@ md_init_header(hp, magic, flags)
struct exec *hp;
int magic, flags;
{
if (oldmagic)
hp->a_midmag = oldmagic;
else
N_SETMAGIC((*hp), magic, MID_I386, flags);
if (!netzmagic && (magic == ZMAGIC) && !(link_mode & DYNAMIC)) {
hp->a_midmag = magic;
} else {
if (netzmagic)
N_SETMAGIC_NET((*hp), magic, MID_I386, flags);
else
N_SETMAGIC((*hp), magic, MID_I386, flags);
}
/* TEXT_START depends on the value of outheader.a_entry. */
if (!(link_mode & SHAREABLE)) /*WAS: if (entry_symbol) */

View File

@ -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: md.h,v 1.5 1993/12/08 10:14:48 pk Exp $
* $Id: md.h,v 1.6 1993/12/11 12:02:05 jkh Exp $
*/
@ -45,10 +45,15 @@
#define PAGSIZ 4096
#endif
#define N_SET_FLAG(ex,f) N_SETMAGIC(ex,N_GETMAGIC(ex), MID_MACHINE, \
N_GETFLAG(ex)|(f))
#define N_IS_DYNAMIC(ex) ((N_GETFLAG(ex) & EX_DYNAMIC))
#define N_SET_FLAG(ex,f) (netzmagic ? \
N_SETMAGIC_NET(ex,N_GETMAGIC_NET(ex), MID_MACHINE, \
N_GETFLAG_NET(ex)|(f)) : \
N_SETMAGIC(ex,N_GETMAGIC(ex), MID_MACHINE, \
N_GETFLAG(ex)|(f)))
#define N_IS_DYNAMIC(ex) ((N_GETMAGIC_NET(ex) == ZMAGIC) ? \
((N_GETFLAG_NET(ex) & EX_DYNAMIC)) : \
((N_GETFLAG(ex) & EX_DYNAMIC)))
/*
* Should be handled by a.out.h ?