Implemented 'QMAGIC' a.out format correctly, and changed the default
output to be QMAGIC.
This commit is contained in:
parent
504c39bf88
commit
1799d2585e
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=928
@ -27,7 +27,7 @@
|
|||||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* 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>
|
#include <sys/param.h>
|
||||||
@ -41,6 +41,8 @@
|
|||||||
|
|
||||||
#include "ld.h"
|
#include "ld.h"
|
||||||
|
|
||||||
|
int netzmagic = 0;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Get relocation addend corresponding to relocation record RP
|
* Get relocation addend corresponding to relocation record RP
|
||||||
* from address ADDR
|
* from address ADDR
|
||||||
@ -96,10 +98,14 @@ md_init_header(hp, magic, flags)
|
|||||||
struct exec *hp;
|
struct exec *hp;
|
||||||
int magic, flags;
|
int magic, flags;
|
||||||
{
|
{
|
||||||
if (oldmagic)
|
if (!netzmagic && (magic == ZMAGIC) && !(link_mode & DYNAMIC)) {
|
||||||
hp->a_midmag = oldmagic;
|
hp->a_midmag = magic;
|
||||||
else
|
} else {
|
||||||
N_SETMAGIC((*hp), magic, MID_I386, flags);
|
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. */
|
/* TEXT_START depends on the value of outheader.a_entry. */
|
||||||
if (!(link_mode & SHAREABLE)) /*WAS: if (entry_symbol) */
|
if (!(link_mode & SHAREABLE)) /*WAS: if (entry_symbol) */
|
||||||
|
@ -27,7 +27,7 @@
|
|||||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* 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
|
#define PAGSIZ 4096
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define N_SET_FLAG(ex,f) N_SETMAGIC(ex,N_GETMAGIC(ex), MID_MACHINE, \
|
#define N_SET_FLAG(ex,f) (netzmagic ? \
|
||||||
N_GETFLAG(ex)|(f))
|
N_SETMAGIC_NET(ex,N_GETMAGIC_NET(ex), MID_MACHINE, \
|
||||||
|
N_GETFLAG_NET(ex)|(f)) : \
|
||||||
#define N_IS_DYNAMIC(ex) ((N_GETFLAG(ex) & EX_DYNAMIC))
|
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 ?
|
* Should be handled by a.out.h ?
|
||||||
|
@ -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. */
|
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. */
|
/* Define how to initialize system-dependent header fields. */
|
||||||
@ -585,14 +585,13 @@ decode_option(swt, arg)
|
|||||||
return;
|
return;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef QMAGIC
|
|
||||||
case 'Q':
|
case 'Q':
|
||||||
magic = oldmagic = QMAGIC;
|
magic = QMAGIC;
|
||||||
return;
|
return;
|
||||||
case 'Z':
|
case 'Z':
|
||||||
magic = oldmagic = ZMAGIC;
|
magic = ZMAGIC;
|
||||||
|
netzmagic = 1;
|
||||||
return;
|
return;
|
||||||
#endif
|
|
||||||
|
|
||||||
case 'o':
|
case 'o':
|
||||||
output_filename = arg;
|
output_filename = arg;
|
||||||
@ -658,7 +657,7 @@ decode_option(swt, arg)
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
case 'z':
|
case 'z':
|
||||||
oldmagic = magic = ZMAGIC;
|
magic = ZMAGIC;
|
||||||
return;
|
return;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
@ -1438,7 +1437,7 @@ digest_symbols ()
|
|||||||
* the padding in the text segment size.
|
* 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);
|
int text_end = text_size + N_TXTOFF(outheader);
|
||||||
text_pad = PALIGN(text_end, page_size) - text_end;
|
text_pad = PALIGN(text_end, page_size) - text_end;
|
||||||
text_size += text_pad;
|
text_size += text_pad;
|
||||||
@ -1491,7 +1490,7 @@ printf("bssstart = %#x, bsssize = %#x\n",
|
|||||||
if (specified_data_size && specified_data_size > data_size)
|
if (specified_data_size && specified_data_size > data_size)
|
||||||
data_pad = 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;
|
data_pad = PALIGN(data_pad + data_size, page_size) - data_size;
|
||||||
|
|
||||||
bss_size -= data_pad;
|
bss_size -= data_pad;
|
||||||
@ -2177,9 +2176,7 @@ write_header ()
|
|||||||
{
|
{
|
||||||
int flags = (rrs_section_type == RRS_FULL) ? EX_DYNAMIC : 0;
|
int flags = (rrs_section_type == RRS_FULL) ? EX_DYNAMIC : 0;
|
||||||
|
|
||||||
#ifdef QMAGIC
|
if (netzmagic || magic == QMAGIC || (link_mode & DYNAMIC))
|
||||||
if (!oldmagic)
|
|
||||||
#endif
|
|
||||||
N_SET_FLAG (outheader, flags);
|
N_SET_FLAG (outheader, flags);
|
||||||
|
|
||||||
outheader.a_text = text_size;
|
outheader.a_text = text_size;
|
||||||
|
@ -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
|
* This code is derived from software copyrighted by the Free Software
|
||||||
* Foundation.
|
* Foundation.
|
||||||
@ -54,12 +54,10 @@ char *progname;
|
|||||||
/* Define this to specify the default executable format. */
|
/* Define this to specify the default executable format. */
|
||||||
|
|
||||||
#ifndef DEFAULT_MAGIC
|
#ifndef DEFAULT_MAGIC
|
||||||
#define DEFAULT_MAGIC ZMAGIC
|
#define DEFAULT_MAGIC QMAGIC
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef QMAGIC
|
extern netzmagic;
|
||||||
int oldmagic;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -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
|
PROG= ld.so
|
||||||
SRCS= mdprologue.S sbrk.c rtld.c shlib.c etc.c md.c
|
SRCS= mdprologue.S sbrk.c rtld.c shlib.c etc.c md.c
|
||||||
@ -7,7 +7,7 @@ LDDIR?= $(.CURDIR)/..
|
|||||||
#PICFLAG=-pic
|
#PICFLAG=-pic
|
||||||
PICFLAG=-fpic
|
PICFLAG=-fpic
|
||||||
CFLAGS += -I$(LDDIR) -I$(.CURDIR) -I$(LDDIR)/$(MACHINE) -O $(PICFLAG) -DRTLD
|
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
|
LIBS = -lc_pic -lgcc_pic
|
||||||
BINDIR= /usr/libexec
|
BINDIR= /usr/libexec
|
||||||
ASFLAGS = -k
|
ASFLAGS = -k
|
||||||
|
@ -27,7 +27,7 @@
|
|||||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* 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) {
|
if (read(crt.crt_ldfd, &hdr, sizeof hdr) < sizeof hdr) {
|
||||||
_FATAL("Failure reading ld.so\n");
|
_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");
|
_FATAL("Bad magic: ld.so\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -287,7 +287,7 @@ __do_dynamic_link ()
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Map in ld.so */
|
/* 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,
|
PROT_READ|PROT_EXEC,
|
||||||
MAP_FILE|MAP_COPY,
|
MAP_FILE|MAP_COPY,
|
||||||
crt.crt_ldfd, N_TXTOFF(hdr));
|
crt.crt_ldfd, N_TXTOFF(hdr));
|
||||||
@ -308,7 +308,7 @@ __do_dynamic_link ()
|
|||||||
|
|
||||||
/* Map in data segment of ld.so writable */
|
/* Map in data segment of ld.so writable */
|
||||||
if (mmap(crt.crt_ba+N_DATADDR(hdr), hdr.a_data,
|
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,
|
MAP_FIXED|MAP_FILE|MAP_COPY,
|
||||||
crt.crt_ldfd, N_DATOFF(hdr)) == -1) {
|
crt.crt_ldfd, N_DATOFF(hdr)) == -1) {
|
||||||
_FATAL("Cannot map ld.so\n");
|
_FATAL("Cannot map ld.so\n");
|
||||||
@ -316,7 +316,7 @@ __do_dynamic_link ()
|
|||||||
|
|
||||||
/* Map bss segment of ld.so zero */
|
/* Map bss segment of ld.so zero */
|
||||||
if (hdr.a_bss && mmap(crt.crt_ba+N_BSSADDR(hdr), hdr.a_bss,
|
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,
|
MAP_FIXED|MAP_ANON|MAP_COPY,
|
||||||
crt.crt_dzfd, 0) == -1) {
|
crt.crt_dzfd, 0) == -1) {
|
||||||
_FATAL("Cannot map ld.so\n");
|
_FATAL("Cannot map ld.so\n");
|
||||||
|
@ -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
|
PROG= ld.so
|
||||||
SRCS= mdprologue.S sbrk.c rtld.c shlib.c etc.c md.c
|
SRCS= mdprologue.S sbrk.c rtld.c shlib.c etc.c md.c
|
||||||
@ -7,7 +7,7 @@ LDDIR?= $(.CURDIR)/..
|
|||||||
#PICFLAG=-pic
|
#PICFLAG=-pic
|
||||||
PICFLAG=-fpic
|
PICFLAG=-fpic
|
||||||
CFLAGS += -I$(LDDIR) -I$(.CURDIR) -I$(LDDIR)/$(MACHINE) -O $(PICFLAG) -DRTLD
|
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
|
LIBS = -lc_pic -lgcc_pic
|
||||||
BINDIR= /usr/libexec
|
BINDIR= /usr/libexec
|
||||||
ASFLAGS = -k
|
ASFLAGS = -k
|
||||||
|
@ -27,7 +27,7 @@
|
|||||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* 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>
|
#include <sys/param.h>
|
||||||
@ -41,6 +41,8 @@
|
|||||||
|
|
||||||
#include "ld.h"
|
#include "ld.h"
|
||||||
|
|
||||||
|
int netzmagic = 0;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Get relocation addend corresponding to relocation record RP
|
* Get relocation addend corresponding to relocation record RP
|
||||||
* from address ADDR
|
* from address ADDR
|
||||||
@ -96,10 +98,14 @@ md_init_header(hp, magic, flags)
|
|||||||
struct exec *hp;
|
struct exec *hp;
|
||||||
int magic, flags;
|
int magic, flags;
|
||||||
{
|
{
|
||||||
if (oldmagic)
|
if (!netzmagic && (magic == ZMAGIC) && !(link_mode & DYNAMIC)) {
|
||||||
hp->a_midmag = oldmagic;
|
hp->a_midmag = magic;
|
||||||
else
|
} else {
|
||||||
N_SETMAGIC((*hp), magic, MID_I386, flags);
|
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. */
|
/* TEXT_START depends on the value of outheader.a_entry. */
|
||||||
if (!(link_mode & SHAREABLE)) /*WAS: if (entry_symbol) */
|
if (!(link_mode & SHAREABLE)) /*WAS: if (entry_symbol) */
|
||||||
|
@ -27,7 +27,7 @@
|
|||||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* 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
|
#define PAGSIZ 4096
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define N_SET_FLAG(ex,f) N_SETMAGIC(ex,N_GETMAGIC(ex), MID_MACHINE, \
|
#define N_SET_FLAG(ex,f) (netzmagic ? \
|
||||||
N_GETFLAG(ex)|(f))
|
N_SETMAGIC_NET(ex,N_GETMAGIC_NET(ex), MID_MACHINE, \
|
||||||
|
N_GETFLAG_NET(ex)|(f)) : \
|
||||||
#define N_IS_DYNAMIC(ex) ((N_GETFLAG(ex) & EX_DYNAMIC))
|
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 ?
|
* Should be handled by a.out.h ?
|
||||||
|
Loading…
Reference in New Issue
Block a user