1987-11-20 10:41:03 +00:00
|
|
|
#include <system.h>
|
|
|
|
#include <out.h>
|
1989-01-26 13:32:57 +00:00
|
|
|
#include "back.h"
|
1987-11-20 10:41:03 +00:00
|
|
|
#include "mach.h"
|
|
|
|
|
1987-11-25 13:54:01 +00:00
|
|
|
/* Global datastructures :
|
|
|
|
* - 'text_area' points to the text segment, 'text' points to first free
|
|
|
|
* entry in the text segment.
|
|
|
|
* - 'data_area' points to the data segment, 'data' points to the first free
|
|
|
|
* entry in the data segmnet.
|
|
|
|
* - 'string_area' points to the string area, 'string' points to the first free
|
|
|
|
* entry in the string area.
|
|
|
|
* - 'reloc_info' points to the relocation table, 'relo' points to the first
|
|
|
|
* free entry in the relocation table.
|
|
|
|
* - 'symbol_table' points to the symbol table, 'nname' is the index of the
|
|
|
|
* first free entry in the symbol_table. If pointers were used it is a pain
|
|
|
|
* to do a realloc on the symbol table, because all pointers in the
|
|
|
|
* relocation table to the symbol table have to be updated.
|
|
|
|
* - The bss segment contains only one vaue, so its enough to count the
|
|
|
|
* the bytes wanted.
|
|
|
|
* - The 'size_*' variables count the number of entries in each segment.
|
|
|
|
* - 'cur_seg' contains the number of the segment to be filled.
|
|
|
|
* (see "back.h")
|
|
|
|
*/
|
|
|
|
|
1987-11-20 10:41:03 +00:00
|
|
|
|
|
|
|
char *text_area,
|
|
|
|
*data_area,
|
|
|
|
*string_area,
|
|
|
|
*text, *data, *string;
|
|
|
|
struct outrelo *reloc_info, *relo;
|
|
|
|
struct outname *symbol_table;
|
|
|
|
|
|
|
|
|
|
|
|
int cur_seg = -1 , nname = 0;
|
|
|
|
long nbss = 0, size_text, size_data, size_reloc, size_symbol,
|
1989-01-26 13:32:57 +00:00
|
|
|
size_string, text_cnt, data_cnt;
|
1987-11-20 10:41:03 +00:00
|
|
|
|
|
|
|
|
|
|
|
put2(sect,addr,w)
|
|
|
|
char *sect;
|
|
|
|
long addr;
|
|
|
|
int w;
|
|
|
|
{
|
|
|
|
#ifdef BYTES_REVERSED
|
1988-10-31 15:42:15 +00:00
|
|
|
put1(sect, addr, (w>>8));
|
|
|
|
put1(sect, addr+1, w);
|
1987-11-20 10:41:03 +00:00
|
|
|
#else
|
1988-10-31 15:42:15 +00:00
|
|
|
put1(sect, addr, w);
|
|
|
|
put1(sect, addr+1, (w>>8));
|
1987-11-20 10:41:03 +00:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
put4(sect,addr,l)
|
|
|
|
char *sect;
|
|
|
|
long addr;
|
|
|
|
long l;
|
|
|
|
{
|
|
|
|
#ifdef WORDS_REVERSED
|
1988-10-31 15:42:15 +00:00
|
|
|
put2(sect,addr,(int) (l>>16));
|
|
|
|
put2(sect,addr+2,(int) l);
|
1987-11-20 10:41:03 +00:00
|
|
|
#else
|
1988-10-31 15:42:15 +00:00
|
|
|
put2(sect,addr,(int) l);
|
|
|
|
put2(sect,addr+2,(int) (l>>16));
|
1987-11-20 10:41:03 +00:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
1988-10-31 15:42:15 +00:00
|
|
|
int get2(sect,addr)
|
1987-11-20 10:41:03 +00:00
|
|
|
char *sect;
|
|
|
|
long addr;
|
|
|
|
{
|
|
|
|
#ifdef BYTES_REVERSED
|
1988-10-31 15:42:15 +00:00
|
|
|
return (get1(sect,addr) << 8) | (get1(sect,addr+1) & 255);
|
1987-11-20 10:41:03 +00:00
|
|
|
#else
|
1988-10-31 15:42:15 +00:00
|
|
|
return (get1(sect,addr+1) << 8) | (get1(sect,addr) & 255);
|
1987-11-20 10:41:03 +00:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
long get4(sect,addr)
|
|
|
|
char *sect;
|
|
|
|
long addr;
|
|
|
|
{
|
|
|
|
#ifdef WORDS_REVERSED
|
1989-03-30 09:34:43 +00:00
|
|
|
return ((long)get2(sect,addr) << 16) | (get2(sect, addr+2) & 65535L);
|
1987-11-20 10:41:03 +00:00
|
|
|
#else
|
1989-03-30 09:34:43 +00:00
|
|
|
return ((long)get2(sect,addr+2) << 16) | (get2(sect, addr) & 65535L);
|
1987-11-20 10:41:03 +00:00
|
|
|
#endif
|
|
|
|
}
|