many changes, in search for more speed
This commit is contained in:
parent
3bb19b6e7d
commit
0011c49d1e
|
@ -1,7 +1,7 @@
|
||||||
EMHOME=../../../..
|
EMHOME=../../../..
|
||||||
CEG=$(EMHOME)/lib/ceg
|
CEG=$(EMHOME)/lib/ceg
|
||||||
SOURCE=$(CEG)/ce_back/obj_back
|
SOURCE=$(CEG)/ce_back/obj_back
|
||||||
CFLAGS=-O
|
CFLAGS=-O #-pg
|
||||||
CC=cc
|
CC=cc
|
||||||
|
|
||||||
IDIRS=-I.\
|
IDIRS=-I.\
|
||||||
|
|
|
@ -1,8 +1,11 @@
|
||||||
EMHOME=../../..
|
EMHOME=../../..
|
||||||
BACK=$(EMHOME)/lib/ceg/ce_back
|
BACK=$(EMHOME)/lib/ceg/ce_back
|
||||||
|
|
||||||
install : back.a
|
all : back.a
|
||||||
install_ceg
|
make -f ce_makefile
|
||||||
|
|
||||||
|
install: all
|
||||||
|
make -f ce_makefile install
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
rm -rf back.a back
|
rm -rf back.a back
|
||||||
|
|
|
@ -1,14 +1,14 @@
|
||||||
#include "mach.h"
|
#include "mach.h"
|
||||||
#include <back.h>
|
#include <back.h>
|
||||||
#include <stdio.h>
|
|
||||||
#include <out.h>
|
#include <out.h>
|
||||||
|
#include <system.h>
|
||||||
|
|
||||||
|
|
||||||
arg_error( s, arg)
|
arg_error( s, arg)
|
||||||
char *s;
|
char *s;
|
||||||
int arg;
|
int arg;
|
||||||
{
|
{
|
||||||
fprintf( stderr, "arg_error %s %d\n", s, arg);
|
fprint( STDERR, "arg_error %s %d\n", s, arg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -18,7 +18,10 @@ extern File *out_file;
|
||||||
|
|
||||||
struct exec u_header;
|
struct exec u_header;
|
||||||
|
|
||||||
long ntext, ndata, nrelo, nchar, base_address();
|
long ntext, ndata, nrelo, nchar;
|
||||||
|
|
||||||
|
long base_address[SEGBSS+1];
|
||||||
|
|
||||||
int trsize=0, drsize=0;
|
int trsize=0, drsize=0;
|
||||||
|
|
||||||
struct relocation_info *u_reloc;
|
struct relocation_info *u_reloc;
|
||||||
|
@ -29,6 +32,7 @@ output()
|
||||||
{
|
{
|
||||||
register int i;
|
register int i;
|
||||||
register struct nlist *u_name;
|
register struct nlist *u_name;
|
||||||
|
register struct outrelo *rp;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Convert relocation data structures. This also requires
|
* Convert relocation data structures. This also requires
|
||||||
|
@ -41,16 +45,18 @@ output()
|
||||||
u_reloc = (struct relocation_info *)
|
u_reloc = (struct relocation_info *)
|
||||||
Malloc((unsigned)nrelo*sizeof(struct relocation_info));
|
Malloc((unsigned)nrelo*sizeof(struct relocation_info));
|
||||||
|
|
||||||
for (i = 0; i < nrelo; i++) {
|
rp = reloc_info;
|
||||||
if ( ( reloc_info[i].or_sect-S_MIN) == SEGTXT &&
|
for (i = nrelo; i > 0; i--, rp++) {
|
||||||
convert_reloc( &reloc_info[i], u_reloc)) {
|
if ( ( rp->or_sect-S_MIN) == SEGTXT &&
|
||||||
|
convert_reloc( rp, u_reloc)) {
|
||||||
trsize++;
|
trsize++;
|
||||||
u_reloc++;
|
u_reloc++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (i = 0; i < nrelo; i++) {
|
rp = reloc_info;
|
||||||
if ( ( reloc_info[i].or_sect-S_MIN) != SEGTXT &&
|
for (i = nrelo; i > 0; i--, rp++) {
|
||||||
convert_reloc( &reloc_info[i], u_reloc)) {
|
if ( ( rp->or_sect-S_MIN) != SEGTXT &&
|
||||||
|
convert_reloc( rp, u_reloc)) {
|
||||||
u_reloc++;
|
u_reloc++;
|
||||||
drsize++;
|
drsize++;
|
||||||
}
|
}
|
||||||
|
@ -98,39 +104,42 @@ reduce_name_table()
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define S_NEEDED 0x8000
|
#define S_NEEDED 0x8000
|
||||||
#define removable(nm) (!(nm.on_type & S_NEEDED) && *(nm.on_foff+string_area) == GENLAB)
|
#define removable(nm) (!(nm->on_type & S_NEEDED) && *(nm->on_foff+string_area) == GENLAB)
|
||||||
|
|
||||||
register int *diff_index =
|
register int *diff_index =
|
||||||
(int *) Malloc((unsigned)(nname + 1) * sizeof(int));
|
(int *) Malloc((unsigned)(nname + 1) * sizeof(int));
|
||||||
register int i;
|
register int i;
|
||||||
|
register struct outname *np;
|
||||||
char *new_str;
|
char *new_str;
|
||||||
register char *p, *q;
|
register char *p, *q;
|
||||||
|
register struct relocation_info *rp;
|
||||||
|
|
||||||
*diff_index++ = 0;
|
*diff_index++ = 0;
|
||||||
for (i = 0; i < nrelo; i++) {
|
rp = u_reloc;
|
||||||
if (u_reloc[i].r_extern) {
|
for (i = nrelo; i > 0; i--, rp++) {
|
||||||
symbol_table[u_reloc[i].r_symbolnum].on_type |= S_NEEDED;
|
if (rp->r_extern) {
|
||||||
|
symbol_table[rp->r_symbolnum].on_type |= S_NEEDED;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0; i < nname; i++) {
|
np = symbol_table;
|
||||||
|
for (i = 0; i < nname; i++, np++) {
|
||||||
int old_diff_index = diff_index[i-1];
|
int old_diff_index = diff_index[i-1];
|
||||||
|
|
||||||
if (removable(symbol_table[i])) {
|
if (removable(np)) {
|
||||||
diff_index[i] = old_diff_index + 1;
|
diff_index[i] = old_diff_index + 1;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
diff_index[i] = old_diff_index;
|
diff_index[i] = old_diff_index;
|
||||||
if (old_diff_index) {
|
if (old_diff_index) {
|
||||||
symbol_table[i - old_diff_index] = symbol_table[i];
|
symbol_table[i - old_diff_index] = *np;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
nname -= diff_index[nname - 1];
|
nname -= diff_index[nname - 1];
|
||||||
|
|
||||||
for (i = 0; i < nrelo; i++) {
|
rp = u_reloc;
|
||||||
register struct relocation_info *rp = &u_reloc[i];
|
for (i = nrelo; i > 0; i--, rp++) {
|
||||||
|
|
||||||
if (rp->r_extern) {
|
if (rp->r_extern) {
|
||||||
rp->r_symbolnum -= diff_index[rp->r_symbolnum];
|
rp->r_symbolnum -= diff_index[rp->r_symbolnum];
|
||||||
}
|
}
|
||||||
|
@ -139,9 +148,10 @@ reduce_name_table()
|
||||||
free((char *)(diff_index-1));
|
free((char *)(diff_index-1));
|
||||||
|
|
||||||
new_str = q = Malloc((unsigned)(string - string_area));
|
new_str = q = Malloc((unsigned)(string - string_area));
|
||||||
for (i = 0; i < nname; i++) {
|
np = symbol_table;
|
||||||
p = symbol_table[i].on_foff + string_area;
|
for (i = nname; i > 0; i--, np++) {
|
||||||
symbol_table[i].on_foff = q - new_str;
|
p = np->on_foff + string_area;
|
||||||
|
np->on_foff = q - new_str;
|
||||||
while (*q++ = *p) p++;
|
while (*q++ = *p) p++;
|
||||||
}
|
}
|
||||||
free(string_area);
|
free(string_area);
|
||||||
|
@ -172,8 +182,8 @@ init_unixheader()
|
||||||
}
|
}
|
||||||
|
|
||||||
convert_reloc( a_relo, u_relo)
|
convert_reloc( a_relo, u_relo)
|
||||||
struct outrelo *a_relo;
|
register struct outrelo *a_relo;
|
||||||
struct relocation_info *u_relo;
|
register struct relocation_info *u_relo;
|
||||||
{
|
{
|
||||||
int retval = 1;
|
int retval = 1;
|
||||||
|
|
||||||
|
@ -227,65 +237,43 @@ int length;
|
||||||
|
|
||||||
|
|
||||||
convert_name( a_name, u_name)
|
convert_name( a_name, u_name)
|
||||||
struct outname *a_name;
|
register struct outname *a_name;
|
||||||
struct nlist *u_name;
|
register struct nlist *u_name;
|
||||||
{
|
{
|
||||||
/* print( "naam is %s\n", a_name->on_foff + string_area); */
|
/* print( "naam is %s\n", a_name->on_foff + string_area); */
|
||||||
|
|
||||||
u_name->n_str = a_name->on_foff + 4;
|
u_name->n_str = a_name->on_foff + 4;
|
||||||
fill_type( &(u_name->n_type), &(a_name->on_type), a_name->on_valu);
|
if ((a_name->on_type & S_TYP) == S_UND ||
|
||||||
|
(a_name->on_type & S_EXT)) u_name->n_type = N_EXT;
|
||||||
|
else u_name->n_type = 0;
|
||||||
|
if (a_name->on_valu != -1 && (! (a_name->on_type & S_COM))) {
|
||||||
|
switch((a_name->on_type & S_TYP) - S_MIN) {
|
||||||
|
case SEGTXT:
|
||||||
|
u_name->n_type |= N_TEXT;
|
||||||
|
break;
|
||||||
|
case SEGCON:
|
||||||
|
u_name->n_type |= N_DATA;
|
||||||
|
break;
|
||||||
|
case SEGBSS:
|
||||||
|
u_name->n_type |= N_BSS;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
fprint(STDERR, "convert_name(): bad section %d\n",
|
||||||
|
(a_name->on_type & S_TYP) - S_MIN);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
u_name->n_other = '\0';
|
u_name->n_other = '\0';
|
||||||
u_name->n_desc = 0;
|
u_name->n_desc = 0;
|
||||||
if (a_name->on_type & S_COM)
|
if (a_name->on_type & S_COM)
|
||||||
u_name->n_value = a_name->on_valu;
|
u_name->n_value = a_name->on_valu;
|
||||||
else if ( a_name->on_valu != -1)
|
else if ( a_name->on_valu != -1)
|
||||||
u_name->n_value = a_name->on_valu +
|
u_name->n_value = a_name->on_valu +
|
||||||
base_address( ( a_name->on_type & S_TYP) - S_MIN);
|
base_address[( a_name->on_type & S_TYP) - S_MIN];
|
||||||
else
|
else
|
||||||
u_name->n_value = 0;
|
u_name->n_value = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
fill_type( u_type, a_type, valu)
|
|
||||||
unsigned char *u_type;
|
|
||||||
ushort *a_type;
|
|
||||||
long valu;
|
|
||||||
{
|
|
||||||
int sect;
|
|
||||||
|
|
||||||
*u_type = ((*a_type&S_TYP) == S_UND || (*a_type & S_EXT)) ? N_EXT : 0;
|
|
||||||
|
|
||||||
if ( valu != -1 && (! (*a_type & S_COM))) {
|
|
||||||
sect = ( *a_type & S_TYP ) - S_MIN;
|
|
||||||
switch ( sect) {
|
|
||||||
case SEGTXT: *u_type |= N_TEXT;
|
|
||||||
break;
|
|
||||||
case SEGCON : *u_type |= N_DATA;
|
|
||||||
break;
|
|
||||||
case SEGBSS : *u_type |= N_BSS;
|
|
||||||
break;
|
|
||||||
default: fprint(STDERR,
|
|
||||||
"fill_type() : bad section %d\n", sect);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
long base_address( seg)
|
|
||||||
int seg;
|
|
||||||
{
|
|
||||||
switch ( seg) {
|
|
||||||
case SEGTXT : return( 0);
|
|
||||||
break;
|
|
||||||
case SEGCON : return( text - text_area);
|
|
||||||
break;
|
|
||||||
case SEGBSS : return( text - text_area + data - data_area);
|
|
||||||
break;
|
|
||||||
default : fprint( STDERR,
|
|
||||||
"base_adres() : bad section %d\n", seg);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
put_stringtablesize( n)
|
put_stringtablesize( n)
|
||||||
long n;
|
long n;
|
||||||
{
|
{
|
||||||
|
|
|
@ -3,12 +3,9 @@
|
||||||
#include "data.h"
|
#include "data.h"
|
||||||
#include "back.h"
|
#include "back.h"
|
||||||
|
|
||||||
long get4();
|
/* Written to run on SUN, and generate code for SUN */
|
||||||
extern long base_address();
|
|
||||||
/*
|
extern long base_address[];
|
||||||
extern short get2();
|
|
||||||
extern char get1();
|
|
||||||
*/
|
|
||||||
|
|
||||||
do_local_relocation()
|
do_local_relocation()
|
||||||
{
|
{
|
||||||
|
@ -16,11 +13,13 @@ do_local_relocation()
|
||||||
|
|
||||||
/* print( "n relocation records %d\n", relo - reloc_info); */
|
/* print( "n relocation records %d\n", relo - reloc_info); */
|
||||||
|
|
||||||
|
base_address[SEGTXT] = 0;
|
||||||
|
base_address[SEGCON] = text - text_area;
|
||||||
|
base_address[SEGBSS] = base_address[SEGCON] + data - data_area;
|
||||||
for ( rp = reloc_info; rp < relo; rp++) {
|
for ( rp = reloc_info; rp < relo; rp++) {
|
||||||
register struct outname *np = &symbol_table[rp->or_nami];
|
register struct outname *np = &symbol_table[rp->or_nami];
|
||||||
|
|
||||||
if ( np->on_valu != -1 && ! (np->on_type & S_COM)) {
|
if ( np->on_valu != -1 && ! (np->on_type & S_COM)) {
|
||||||
register long oldval,newval;
|
|
||||||
register char *sect;
|
register char *sect;
|
||||||
|
|
||||||
switch( rp->or_sect - S_MIN) {
|
switch( rp->or_sect - S_MIN) {
|
||||||
|
@ -36,19 +35,12 @@ do_local_relocation()
|
||||||
rp->or_sect - S_MIN);
|
rp->or_sect - S_MIN);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
oldval = get4( sect, rp->or_addr);
|
|
||||||
newval = oldval + np->on_valu +
|
|
||||||
base_address( (np->on_type & S_TYP) -S_MIN);
|
|
||||||
if ( rp->or_type & RELO4)
|
if ( rp->or_type & RELO4)
|
||||||
put4( sect, rp->or_addr, newval);
|
*((long *)(sect+rp->or_addr)) +=
|
||||||
/*
|
np->on_valu +
|
||||||
else if ( rp->or_type & RELO2)
|
base_address[(np->on_type&S_TYP)-S_MIN];
|
||||||
put2( sect, rp->or_addr, (int) newval);
|
|
||||||
else if ( rp->or_type & RELO1)
|
|
||||||
put1( sect, rp->or_addr, (char) newval);
|
|
||||||
*/
|
|
||||||
else
|
else
|
||||||
print( STDERR,
|
fprint( STDERR,
|
||||||
"do_relo() : bad relocation size\n");
|
"do_relo() : bad relocation size\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue