* $Id: symbol.c,v 1.2 1993/11/09 04:19:04 paul Exp $ - symbol table routines
/* Create the symbol table entries for `etext', `edata' and `end'. */
symtab_init (relocatable_output
)
* Put linker reserved symbols into symbol table.
dynamic_symbol
= getsym ("__DYNAMIC");
dynamic_symbol
->defined
= relocatable_output
?N_UNDF
:(N_DATA
| N_EXT
);
dynamic_symbol
->referenced
= 0;
dynamic_symbol
->value
= 0;
got_symbol
= getsym ("__GLOBAL_OFFSET_TABLE_");
got_symbol
->defined
= N_DATA
| N_EXT
;
got_symbol
->referenced
= 0;
edata_symbol
= getsym ("_edata");
etext_symbol
= getsym ("_etext");
end_symbol
= getsym ("_end");
edata_symbol
= getsym ("edata");
etext_symbol
= getsym ("etext");
end_symbol
= getsym ("end");
edata_symbol
->defined
= N_DATA
| N_EXT
;
etext_symbol
->defined
= N_TEXT
| N_EXT
;
end_symbol
->defined
= N_BSS
| N_EXT
;
edata_symbol
->referenced
= 1;
etext_symbol
->referenced
= 1;
end_symbol
->referenced
= 1;
/* Compute the hash code for symbol name KEY. */
k
= (((k
<< 1) + (k
>> 14)) ^ (*cp
++)) & 0x3fff;
/* Get the symbol table entry for the global symbol named KEY.
Create one if there is none. */
/* Determine the proper bucket. */
hashval
= hash_string (key
) % TABSIZE
;
for (bp
= symtab
[hashval
]; bp
; bp
= bp
->link
)
if (! strcmp (key
, bp
->name
))
/* Nothing was found; create a new symbol table entry. */
bp
= (symbol
*) xmalloc (sizeof (symbol
));
bp
->name
= (char *) xmalloc (strlen (key
) + 1);
bp
->multiply_defined
= 0;
bp
->cpyreloc_reserved
= 0;
bp
->cpyreloc_claimed
= 0;
/* Add the entry to the bucket. */
bp
->link
= symtab
[hashval
];
/* Like `getsym' but return 0 if the symbol is not already known. */
/* Determine which bucket. */
hashval
= hash_string (key
) % TABSIZE
;
for (bp
= symtab
[hashval
]; bp
; bp
= bp
->link
)
if (! strcmp (key
, bp
->name
))