Now there are two incarnations of relocs, linenos and syments. One for
internal digestion, and one full of char arrays for I/O. The original names have gone to detect errors.
This commit is contained in:
parent
9dce1776b6
commit
81623791e4
@ -222,17 +222,25 @@ struct scnhdr {
|
||||
* grouping will have l_lnno = 0 and in place of physical address will be the
|
||||
* symbol table index of the function name.
|
||||
*/
|
||||
struct lineno {
|
||||
struct external_lineno {
|
||||
union {
|
||||
long l_symndx; /* function name symbol index, iff l_lnno == 0*/
|
||||
long l_paddr; /* (physical) address of line number */
|
||||
char l_symndx[4]; /* function name symbol index, iff l_lnno == 0*/
|
||||
char l_paddr[4]; /* (physical) address of line number */
|
||||
} l_addr;
|
||||
unsigned short l_lnno; /* line number */
|
||||
char padding[2]; /* force alignment */
|
||||
};
|
||||
|
||||
#define LINENO struct lineno
|
||||
#define LINESZ sizeof(LINENO)
|
||||
struct internal_lineno {
|
||||
union {
|
||||
long l_symndx; /* function name symbol index, iff l_lnno == 0*/
|
||||
long l_paddr; /* (physical) address of line number */
|
||||
} l_addr;
|
||||
unsigned short l_lnno; /* line number */
|
||||
};
|
||||
|
||||
#define LINENO struct external_lineno
|
||||
#define LINESZ 8
|
||||
|
||||
|
||||
/********************** SYMBOLS **********************/
|
||||
@ -241,7 +249,26 @@ struct lineno {
|
||||
#define FILNMLEN 14 /* # characters in a file name */
|
||||
#define DIMNUM 4 /* # array dimensions in auxiliary entry */
|
||||
|
||||
struct syment {
|
||||
struct external_syment
|
||||
{
|
||||
union {
|
||||
char e_name[SYMNMLEN];
|
||||
struct {
|
||||
char e_zeroes[4];
|
||||
char e_offset[4];
|
||||
} e;
|
||||
} e;
|
||||
char e_value[4];
|
||||
char e_scnum[2];
|
||||
char e_flags[2];
|
||||
char e_type[4];
|
||||
char e_sclass[1];
|
||||
char e_numaux[1];
|
||||
char pad2[2];
|
||||
};
|
||||
|
||||
|
||||
struct internal_syment {
|
||||
union {
|
||||
char _n_name[SYMNMLEN]; /* old COFF version */
|
||||
struct {
|
||||
@ -256,14 +283,8 @@ struct syment {
|
||||
unsigned long n_type; /* type and derived type */
|
||||
char n_sclass; /* storage class */
|
||||
char n_numaux; /* number of aux. entries */
|
||||
char pad2[2]; /* force alignment */
|
||||
};
|
||||
|
||||
#define n_name _n._n_name
|
||||
#define n_ptr _n._n_nptr[1]
|
||||
#define n_zeroes _n._n_n._n_zeroes
|
||||
#define n_offset _n._n_n._n_offset
|
||||
|
||||
/*
|
||||
* Relocatable symbols have number of the section in which they are defined,
|
||||
* or one of the following:
|
||||
@ -315,8 +336,69 @@ struct syment {
|
||||
#define ISARY(x) (((x) & N_TMASK) == (DT_ARY << N_BTSHFT))
|
||||
|
||||
#define DECREF(x) ((((x)>>N_TSHIFT)&~N_BTMASK)|((x)&N_BTMASK))
|
||||
union external_auxent {
|
||||
struct {
|
||||
char x_tagndx[4]; /* str, un, or enum tag indx */
|
||||
union {
|
||||
struct {
|
||||
char x_lnno[2]; /* declaration line number */
|
||||
char x_size[2]; /* str/union/array size */
|
||||
} x_lnsz;
|
||||
char x_fsize[4]; /* size of function */
|
||||
} x_misc;
|
||||
union {
|
||||
struct { /* if ISFCN, tag, or .bb */
|
||||
char x_lnnoptr[4]; /* ptr to fcn line # */
|
||||
char x_endndx[4]; /* entry ndx past block end */
|
||||
} x_fcn;
|
||||
struct { /* if ISARY, up to 4 dimen. */
|
||||
char x_dimen[DIMNUM][2];
|
||||
} x_ary;
|
||||
} x_fcnary;
|
||||
char x_tvndx[2]; /* tv index */
|
||||
} x_sym;
|
||||
|
||||
union auxent {
|
||||
union {
|
||||
char x_fname[FILNMLEN];
|
||||
struct {
|
||||
char x_zeroes[4];
|
||||
char x_offset[4];
|
||||
} x_n;
|
||||
} x_file;
|
||||
|
||||
struct {
|
||||
char x_scnlen[4]; /* section length */
|
||||
char x_nreloc[2]; /* # relocation entries */
|
||||
char x_nlinno[2]; /* # line numbers */
|
||||
} x_scn;
|
||||
|
||||
struct {
|
||||
char x_tvfill[4]; /* tv fill value */
|
||||
char x_tvlen[2]; /* length of .tv */
|
||||
char x_tvran[2][2]; /* tv range */
|
||||
} x_tv; /* info about .tv section (in auxent of symbol .tv)) */
|
||||
|
||||
/******************************************
|
||||
* I960-specific *2nd* aux. entry formats
|
||||
******************************************/
|
||||
struct {
|
||||
/* This is a very old typo that keeps getting propagated. */
|
||||
#define x_stdindx x_stindx
|
||||
char x_stindx[4]; /* sys. table entry */
|
||||
} x_sc; /* system call entry */
|
||||
|
||||
struct {
|
||||
char x_balntry[4]; /* BAL entry point */
|
||||
} x_bal; /* BAL-callable function */
|
||||
|
||||
struct {
|
||||
char x_timestamp[4]; /* time stamp */
|
||||
char x_idstring[20]; /* producer identity string */
|
||||
} x_ident; /* Producer ident info */
|
||||
|
||||
};
|
||||
|
||||
union internal_auxent {
|
||||
struct {
|
||||
long x_tagndx; /* str, un, or enum tag indx */
|
||||
union {
|
||||
@ -376,27 +458,29 @@ union auxent {
|
||||
char x_idstring[20]; /* producer identity string */
|
||||
} x_ident; /* Producer ident info */
|
||||
|
||||
char a[sizeof(struct syment)]; /* force auxent/syment sizes to match */
|
||||
|
||||
};
|
||||
|
||||
#define SYMENT struct syment
|
||||
#define SYMENT struct external_syment
|
||||
#define SYMESZ sizeof(SYMENT)
|
||||
#define AUXENT union auxent
|
||||
#define AUXENT union external_auxent
|
||||
#define AUXESZ sizeof(AUXENT)
|
||||
|
||||
#if VAX || I960
|
||||
# define _ETEXT "_etext"
|
||||
#else
|
||||
# define _ETEXT "etext"
|
||||
#endif
|
||||
|
||||
/********************** RELOCATION DIRECTIVES **********************/
|
||||
|
||||
struct reloc {
|
||||
struct external_reloc {
|
||||
char r_vaddr[4];
|
||||
char r_symndx[4];
|
||||
char r_type[2];
|
||||
char pad[2];
|
||||
};
|
||||
|
||||
struct internal_reloc {
|
||||
long r_vaddr; /* Virtual address of reference */
|
||||
long r_symndx; /* Index into symbol table */
|
||||
unsigned short r_type; /* Relocation type */
|
||||
char pad[2]; /* Unused */
|
||||
};
|
||||
|
||||
/* Relevent values for r_type and i960. Would someone please document them */
|
||||
@ -411,8 +495,8 @@ struct reloc {
|
||||
#define R_GETPA (0x1e)
|
||||
#define R_TAGWORD (0x1f)
|
||||
|
||||
#define RELOC struct reloc
|
||||
#define RELSZ sizeof(RELOC)
|
||||
#define RELOC struct external_reloc
|
||||
#define RELSZ 12
|
||||
|
||||
#define DEFAULT_DATA_SECTION_ALIGNMENT 4
|
||||
#define DEFAULT_BSS_SECTION_ALIGNMENT 4
|
||||
|
@ -133,7 +133,16 @@ struct scnhdr {
|
||||
* grouping will have l_lnno = 0 and in place of physical address will be the
|
||||
* symbol table index of the function name.
|
||||
*/
|
||||
struct lineno{
|
||||
struct external_lineno{
|
||||
union {
|
||||
char l_symndx[4]; /* function name symbol index, iff l_lnno == 0*/
|
||||
char l_paddr[4]; /* (physical) address of line number */
|
||||
} l_addr;
|
||||
|
||||
char l_lnno[4];
|
||||
|
||||
};
|
||||
struct internal_lineno{
|
||||
union {
|
||||
long l_symndx; /* function name symbol index, iff l_lnno == 0*/
|
||||
long l_paddr; /* (physical) address of line number */
|
||||
@ -143,8 +152,8 @@ struct lineno{
|
||||
|
||||
};
|
||||
|
||||
#define LINENO struct lineno
|
||||
#define LINESZ sizeof(LINENO)
|
||||
#define LINENO struct external_lineno
|
||||
#define LINESZ 8
|
||||
|
||||
|
||||
/********************** SYMBOLS **********************/
|
||||
@ -153,8 +162,24 @@ struct lineno{
|
||||
#define FILNMLEN 14 /* # characters in a file name */
|
||||
#define DIMNUM 4 /* # array dimensions in auxiliary entry */
|
||||
|
||||
struct external_syment
|
||||
{
|
||||
union {
|
||||
char e_name[SYMNMLEN];
|
||||
struct {
|
||||
char e_zeroes[4];
|
||||
char e_offset[4];
|
||||
} e;
|
||||
} e;
|
||||
char e_value[4];
|
||||
char e_scnum[2];
|
||||
char e_type[2];
|
||||
char e_sclass[1];
|
||||
char e_numaux[1];
|
||||
char pad2[2];
|
||||
};
|
||||
|
||||
struct syment {
|
||||
struct internal_syment {
|
||||
union {
|
||||
char _n_name[SYMNMLEN]; /* old COFF version */
|
||||
struct {
|
||||
@ -168,12 +193,8 @@ struct syment {
|
||||
unsigned short n_type; /* type and derived type */
|
||||
char n_sclass; /* storage class */
|
||||
char n_numaux; /* number of aux. entries */
|
||||
char pad2[2]; /* force alignment */
|
||||
};
|
||||
|
||||
#define n_name _n._n_name
|
||||
#define n_zeroes _n._n_n._n_zeroes
|
||||
#define n_offset _n._n_n._n_offset
|
||||
};
|
||||
|
||||
/*
|
||||
* Relocatable symbols have number of the section in which they are defined,
|
||||
@ -227,58 +248,114 @@ struct syment {
|
||||
|
||||
#define DECREF(x) ((((x)>>N_TSHIFT)&~N_BTMASK)|((x)&N_BTMASK))
|
||||
|
||||
union auxent {
|
||||
union external_auxent {
|
||||
struct {
|
||||
long x_tagndx; /* str, un, or enum tag indx */
|
||||
char x_tagndx[4]; /* str, un, or enum tag indx */
|
||||
union {
|
||||
struct {
|
||||
unsigned long x_lnno; /* declaration line number */
|
||||
unsigned long x_size; /* str/union/array size */
|
||||
char x_lnno[2]; /* declaration line number */
|
||||
char x_size[2]; /* str/union/array size */
|
||||
} x_lnsz;
|
||||
long x_fsize; /* size of function */
|
||||
char x_fsize[4]; /* size of function */
|
||||
} x_misc;
|
||||
union {
|
||||
struct { /* if ISFCN, tag, or .bb */
|
||||
long x_lnnoptr; /* ptr to fcn line # */
|
||||
long x_endndx; /* entry ndx past block end */
|
||||
char x_lnnoptr[4]; /* ptr to fcn line # */
|
||||
char x_endndx[4]; /* entry ndx past block end */
|
||||
} x_fcn;
|
||||
struct { /* if ISARY, up to 4 dimen. */
|
||||
unsigned short x_dimen[DIMNUM];
|
||||
char x_dimen[DIMNUM][2];
|
||||
} x_ary;
|
||||
} x_fcnary;
|
||||
unsigned short x_tvndx; /* tv index */
|
||||
char x_tvndx[2]; /* tv index */
|
||||
} x_sym;
|
||||
|
||||
union {
|
||||
char x_fname[FILNMLEN];
|
||||
struct {
|
||||
long x_zeroes;
|
||||
long x_offset;
|
||||
char x_zeroes[4];
|
||||
char x_offset[4];
|
||||
} x_n;
|
||||
} x_file;
|
||||
|
||||
struct {
|
||||
long x_scnlen; /* section length */
|
||||
unsigned long x_nreloc; /* # relocation entries */
|
||||
unsigned long x_nlinno; /* # line numbers */
|
||||
char x_scnlen[4]; /* section length */
|
||||
char x_nreloc[2]; /* # relocation entries */
|
||||
char x_nlinno[2]; /* # line numbers */
|
||||
} x_scn;
|
||||
|
||||
struct {
|
||||
char x_tvfill[4]; /* tv fill value */
|
||||
char x_tvlen[2]; /* length of .tv */
|
||||
char x_tvran[2][2]; /* tv range */
|
||||
} x_tv; /* info about .tv section (in auxent of symbol .tv)) */
|
||||
|
||||
|
||||
};
|
||||
union internal_auxent
|
||||
{
|
||||
struct {
|
||||
long x_tagndx; /* str, un, or enum tag indx */
|
||||
union {
|
||||
struct {
|
||||
unsigned short x_lnno; /* declaration line number */
|
||||
unsigned short x_size; /* str/union/array size */
|
||||
} x_lnsz;
|
||||
long x_fsize; /* size of function */
|
||||
} x_misc;
|
||||
union {
|
||||
struct { /* if ISFCN, tag, or .bb */
|
||||
long x_lnnoptr; /* ptr to fcn line # */
|
||||
long x_endndx; /* entry ndx past block end */
|
||||
} x_fcn;
|
||||
struct { /* if ISARY, up to 4 dimen. */
|
||||
unsigned short x_dimen[DIMNUM];
|
||||
} x_ary;
|
||||
} x_fcnary;
|
||||
unsigned short x_tvndx; /* tv index */
|
||||
} x_sym;
|
||||
|
||||
union {
|
||||
char x_fname[FILNMLEN];
|
||||
struct {
|
||||
long x_zeroes;
|
||||
long x_offset;
|
||||
} x_n;
|
||||
} x_file;
|
||||
|
||||
struct {
|
||||
long x_scnlen; /* section length */
|
||||
unsigned short x_nreloc; /* # relocation entries */
|
||||
unsigned short x_nlinno; /* # line numbers */
|
||||
} x_scn;
|
||||
|
||||
struct {
|
||||
long x_tvfill; /* tv fill value */
|
||||
unsigned short x_tvlen; /* length of .tv */
|
||||
unsigned short x_tvran[2]; /* tv range */
|
||||
} x_tv; /* info about .tv section (in auxent of symbol .tv)) */
|
||||
};
|
||||
|
||||
#define SYMENT struct syment
|
||||
#define SYMENT struct external_syment
|
||||
#define SYMESZ 20
|
||||
#define AUXENT union auxent
|
||||
#define AUXENT union external_auxent
|
||||
#define AUXESZ 20
|
||||
|
||||
|
||||
/********************** RELOCATION DIRECTIVES **********************/
|
||||
|
||||
struct reloc {
|
||||
long r_vaddr; /* Virtual address of reference */
|
||||
long r_symndx; /* Index into symbol table */
|
||||
unsigned short r_type; /* Relocation type */
|
||||
unsigned short r_offset;/* Hi 16 bits of constant */
|
||||
struct external_reloc {
|
||||
char r_vaddr[4];
|
||||
char r_symndx[4];
|
||||
char r_type[2];
|
||||
char r_offset[2];
|
||||
};
|
||||
|
||||
struct internal_reloc {
|
||||
long r_vaddr; /* Virtual address of reference */
|
||||
long r_symndx; /* Index into symbol table */
|
||||
unsigned short r_type; /* Relocation type */
|
||||
unsigned short r_offset; /* Hi 16 bits of constant */
|
||||
};
|
||||
|
||||
/* Only values of r_type GNU/88k cares about */
|
||||
@ -292,7 +369,7 @@ struct reloc {
|
||||
|
||||
|
||||
|
||||
#define RELOC struct reloc
|
||||
#define RELSZ sizeof(RELOC)
|
||||
#define RELOC struct external_reloc
|
||||
#define RELSZ 12
|
||||
|
||||
#define DEFAULT_SECTION_ALIGNMENT 8 /* double word */
|
||||
|
Loading…
x
Reference in New Issue
Block a user