* hash.c (bfd_hash_allocate): Don't call bfd_set_error if
obstack_alloc returns NULL unless the size is non-zero. * linker.c (archive_hash_allocate): Define. (_bfd_generic_link_add_archive_symbols): Use archive_hash_allocate rather than obstack_alloc, for clarity.
This commit is contained in:
parent
c79b49bb80
commit
a537cb21bb
|
@ -1,5 +1,12 @@
|
||||||
Wed Jun 22 10:52:47 1994 Ian Lance Taylor (ian@sanguine.cygnus.com)
|
Wed Jun 22 10:52:47 1994 Ian Lance Taylor (ian@sanguine.cygnus.com)
|
||||||
|
|
||||||
|
* hash.c (bfd_hash_allocate): Don't call bfd_set_error if
|
||||||
|
obstack_alloc returns NULL unless the size is non-zero.
|
||||||
|
|
||||||
|
* linker.c (archive_hash_allocate): Define.
|
||||||
|
(_bfd_generic_link_add_archive_symbols): Use archive_hash_allocate
|
||||||
|
rather than obstack_alloc, for clarity.
|
||||||
|
|
||||||
* elfcode.h (elf_get_reloc_upper_bound): Correct.
|
* elfcode.h (elf_get_reloc_upper_bound): Correct.
|
||||||
|
|
||||||
* aout64.c (BMAGIC, QMAGIC): Define if not already defined. From
|
* aout64.c (BMAGIC, QMAGIC): Define if not already defined. From
|
||||||
|
|
64
bfd/linker.c
64
bfd/linker.c
|
@ -192,8 +192,8 @@ SUBSUBSECTION
|
||||||
add, notably symbol flags, a section, and an offset. The
|
add, notably symbol flags, a section, and an offset. The
|
||||||
symbol flags include such things as <<BSF_WEAK>> or
|
symbol flags include such things as <<BSF_WEAK>> or
|
||||||
<<BSF_INDIRECT>>. The section is a section in the object
|
<<BSF_INDIRECT>>. The section is a section in the object
|
||||||
file, or something like <<bfd_und_section>> for an undefined
|
file, or something like <<bfd_und_section_ptr>> for an undefined
|
||||||
symbol or <<bfd_com_section>> for a common symbol.
|
symbol or <<bfd_com_section_ptr>> for a common symbol.
|
||||||
|
|
||||||
If the <<_bfd_final_link>> routine is also going to need to
|
If the <<_bfd_final_link>> routine is also going to need to
|
||||||
read the symbol information, the <<_bfd_link_add_symbols>>
|
read the symbol information, the <<_bfd_link_add_symbols>>
|
||||||
|
@ -807,6 +807,10 @@ archive_hash_table_init (table, newfunc)
|
||||||
((struct archive_hash_entry *) \
|
((struct archive_hash_entry *) \
|
||||||
bfd_hash_lookup (&(t)->table, (string), (create), (copy)))
|
bfd_hash_lookup (&(t)->table, (string), (create), (copy)))
|
||||||
|
|
||||||
|
/* Allocate space in an archive hash table. */
|
||||||
|
|
||||||
|
#define archive_hash_allocate(t, size) bfd_hash_allocate (&(t)->table, (size))
|
||||||
|
|
||||||
/* Free an archive hash table. */
|
/* Free an archive hash table. */
|
||||||
|
|
||||||
#define archive_hash_table_free(t) bfd_hash_table_free (&(t)->table)
|
#define archive_hash_table_free(t) bfd_hash_table_free (&(t)->table)
|
||||||
|
@ -880,14 +884,10 @@ _bfd_generic_link_add_archive_symbols (abfd, info, checkfn)
|
||||||
arh = archive_hash_lookup (&arsym_hash, arsym->name, true, false);
|
arh = archive_hash_lookup (&arsym_hash, arsym->name, true, false);
|
||||||
if (arh == (struct archive_hash_entry *) NULL)
|
if (arh == (struct archive_hash_entry *) NULL)
|
||||||
goto error_return;
|
goto error_return;
|
||||||
l = (struct archive_list *)
|
l = ((struct archive_list *)
|
||||||
obstack_alloc (&(&(&arsym_hash)->table)->memory,
|
archive_hash_allocate (&arsym_hash, sizeof (struct archive_list)));
|
||||||
sizeof (struct archive_list));
|
|
||||||
if (l == NULL)
|
if (l == NULL)
|
||||||
{
|
goto error_return;
|
||||||
bfd_set_error (bfd_error_no_memory);
|
|
||||||
goto error_return;
|
|
||||||
}
|
|
||||||
l->indx = indx;
|
l->indx = indx;
|
||||||
for (pp = &arh->defs;
|
for (pp = &arh->defs;
|
||||||
*pp != (struct archive_list *) NULL;
|
*pp != (struct archive_list *) NULL;
|
||||||
|
@ -1112,7 +1112,7 @@ generic_link_check_archive_element (abfd, info, pneeded, collect)
|
||||||
will be linked in. */
|
will be linked in. */
|
||||||
h->type = bfd_link_hash_common;
|
h->type = bfd_link_hash_common;
|
||||||
h->u.c.size = bfd_asymbol_value (p);
|
h->u.c.size = bfd_asymbol_value (p);
|
||||||
if (p->section == &bfd_com_section)
|
if (p->section == bfd_com_section_ptr)
|
||||||
h->u.c.section = bfd_make_section_old_way (symbfd, "COMMON");
|
h->u.c.section = bfd_make_section_old_way (symbfd, "COMMON");
|
||||||
else
|
else
|
||||||
h->u.c.section = bfd_make_section_old_way (symbfd,
|
h->u.c.section = bfd_make_section_old_way (symbfd,
|
||||||
|
@ -1163,9 +1163,9 @@ generic_link_add_symbol_list (abfd, info, symbol_count, symbols, collect)
|
||||||
| BSF_GLOBAL
|
| BSF_GLOBAL
|
||||||
| BSF_CONSTRUCTOR
|
| BSF_CONSTRUCTOR
|
||||||
| BSF_WEAK)) != 0
|
| BSF_WEAK)) != 0
|
||||||
|| bfd_get_section (p) == &bfd_und_section
|
|| bfd_is_und_section (bfd_get_section (p))
|
||||||
|| bfd_is_com_section (bfd_get_section (p))
|
|| bfd_is_com_section (bfd_get_section (p))
|
||||||
|| bfd_get_section (p) == &bfd_ind_section)
|
|| bfd_is_ind_section (bfd_get_section (p)))
|
||||||
{
|
{
|
||||||
const char *name;
|
const char *name;
|
||||||
const char *string;
|
const char *string;
|
||||||
|
@ -1173,7 +1173,7 @@ generic_link_add_symbol_list (abfd, info, symbol_count, symbols, collect)
|
||||||
|
|
||||||
name = bfd_asymbol_name (p);
|
name = bfd_asymbol_name (p);
|
||||||
if ((p->flags & BSF_INDIRECT) != 0
|
if ((p->flags & BSF_INDIRECT) != 0
|
||||||
|| p->section == &bfd_ind_section)
|
|| bfd_is_ind_section (p->section))
|
||||||
string = bfd_asymbol_name ((asymbol *) p->value);
|
string = bfd_asymbol_name ((asymbol *) p->value);
|
||||||
else if ((p->flags & BSF_WARNING) != 0)
|
else if ((p->flags & BSF_WARNING) != 0)
|
||||||
{
|
{
|
||||||
|
@ -1204,9 +1204,9 @@ generic_link_add_symbol_list (abfd, info, symbol_count, symbols, collect)
|
||||||
if (info->hash->creator == abfd->xvec)
|
if (info->hash->creator == abfd->xvec)
|
||||||
{
|
{
|
||||||
if (h->sym == (asymbol *) NULL
|
if (h->sym == (asymbol *) NULL
|
||||||
|| (bfd_get_section (p) != &bfd_und_section
|
|| (! bfd_is_und_section (bfd_get_section (p))
|
||||||
&& (! bfd_is_com_section (bfd_get_section (p))
|
&& (! bfd_is_com_section (bfd_get_section (p))
|
||||||
|| (bfd_get_section (h->sym) == &bfd_und_section))))
|
|| bfd_is_und_section (bfd_get_section (h->sym)))))
|
||||||
{
|
{
|
||||||
h->sym = p;
|
h->sym = p;
|
||||||
/* BSF_OLD_COMMON is a hack to support COFF reloc
|
/* BSF_OLD_COMMON is a hack to support COFF reloc
|
||||||
|
@ -1317,7 +1317,7 @@ static const enum link_action link_action[8][7] =
|
||||||
NAME is the name of the symbol.
|
NAME is the name of the symbol.
|
||||||
FLAGS is the BSF_* bits associated with the symbol.
|
FLAGS is the BSF_* bits associated with the symbol.
|
||||||
SECTION is the section in which the symbol is defined; this may be
|
SECTION is the section in which the symbol is defined; this may be
|
||||||
bfd_und_section or bfd_com_section.
|
bfd_und_section_ptr or bfd_com_section_ptr.
|
||||||
VALUE is the value of the symbol, relative to the section.
|
VALUE is the value of the symbol, relative to the section.
|
||||||
STRING is used for either an indirect symbol, in which case it is
|
STRING is used for either an indirect symbol, in which case it is
|
||||||
the name of the symbol to indirect to, or a warning symbol, in
|
the name of the symbol to indirect to, or a warning symbol, in
|
||||||
|
@ -1348,14 +1348,14 @@ _bfd_generic_link_add_one_symbol (info, abfd, name, flags, section, value,
|
||||||
struct bfd_link_hash_entry *h;
|
struct bfd_link_hash_entry *h;
|
||||||
boolean cycle;
|
boolean cycle;
|
||||||
|
|
||||||
if (section == &bfd_ind_section
|
if (bfd_is_ind_section (section)
|
||||||
|| (flags & BSF_INDIRECT) != 0)
|
|| (flags & BSF_INDIRECT) != 0)
|
||||||
row = INDR_ROW;
|
row = INDR_ROW;
|
||||||
else if ((flags & BSF_WARNING) != 0)
|
else if ((flags & BSF_WARNING) != 0)
|
||||||
row = WARN_ROW;
|
row = WARN_ROW;
|
||||||
else if ((flags & BSF_CONSTRUCTOR) != 0)
|
else if ((flags & BSF_CONSTRUCTOR) != 0)
|
||||||
row = SET_ROW;
|
row = SET_ROW;
|
||||||
else if (section == &bfd_und_section)
|
else if (bfd_is_und_section (section))
|
||||||
{
|
{
|
||||||
if ((flags & BSF_WEAK) != 0)
|
if ((flags & BSF_WEAK) != 0)
|
||||||
row = UNDEFW_ROW;
|
row = UNDEFW_ROW;
|
||||||
|
@ -1488,7 +1488,7 @@ _bfd_generic_link_add_one_symbol (info, abfd, name, flags, section, value,
|
||||||
bfd_link_add_undef (info->hash, h);
|
bfd_link_add_undef (info->hash, h);
|
||||||
h->type = bfd_link_hash_common;
|
h->type = bfd_link_hash_common;
|
||||||
h->u.c.size = value;
|
h->u.c.size = value;
|
||||||
if (section == &bfd_com_section)
|
if (section == bfd_com_section_ptr)
|
||||||
{
|
{
|
||||||
h->u.c.section = bfd_make_section_old_way (abfd, "COMMON");
|
h->u.c.section = bfd_make_section_old_way (abfd, "COMMON");
|
||||||
h->u.c.section->flags = SEC_ALLOC;
|
h->u.c.section->flags = SEC_ALLOC;
|
||||||
|
@ -1552,11 +1552,11 @@ _bfd_generic_link_add_one_symbol (info, abfd, name, flags, section, value,
|
||||||
mval = h->u.def.value;
|
mval = h->u.def.value;
|
||||||
break;
|
break;
|
||||||
case bfd_link_hash_common:
|
case bfd_link_hash_common:
|
||||||
msec = &bfd_com_section;
|
msec = bfd_com_section_ptr;
|
||||||
mval = h->u.c.size;
|
mval = h->u.c.size;
|
||||||
break;
|
break;
|
||||||
case bfd_link_hash_indirect:
|
case bfd_link_hash_indirect:
|
||||||
msec = &bfd_ind_section;
|
msec = bfd_ind_section_ptr;
|
||||||
mval = 0;
|
mval = 0;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
@ -1910,9 +1910,9 @@ _bfd_generic_link_output_symbols (output_bfd, input_bfd, info, psymalloc)
|
||||||
| BSF_GLOBAL
|
| BSF_GLOBAL
|
||||||
| BSF_CONSTRUCTOR
|
| BSF_CONSTRUCTOR
|
||||||
| BSF_WEAK)) != 0
|
| BSF_WEAK)) != 0
|
||||||
|| bfd_get_section (sym) == &bfd_und_section
|
|| bfd_is_und_section (bfd_get_section (sym))
|
||||||
|| bfd_is_com_section (bfd_get_section (sym))
|
|| bfd_is_com_section (bfd_get_section (sym))
|
||||||
|| bfd_get_section (sym) == &bfd_ind_section)
|
|| bfd_is_ind_section (bfd_get_section (sym)))
|
||||||
{
|
{
|
||||||
h = _bfd_generic_link_hash_lookup (_bfd_generic_hash_table (info),
|
h = _bfd_generic_link_hash_lookup (_bfd_generic_hash_table (info),
|
||||||
bfd_asymbol_name (sym),
|
bfd_asymbol_name (sym),
|
||||||
|
@ -1948,8 +1948,8 @@ _bfd_generic_link_output_symbols (output_bfd, input_bfd, info, psymalloc)
|
||||||
sym->flags |= BSF_GLOBAL;
|
sym->flags |= BSF_GLOBAL;
|
||||||
if (! bfd_is_com_section (sym->section))
|
if (! bfd_is_com_section (sym->section))
|
||||||
{
|
{
|
||||||
BFD_ASSERT (sym->section == &bfd_und_section);
|
BFD_ASSERT (bfd_is_und_section (sym->section));
|
||||||
sym->section = &bfd_com_section;
|
sym->section = bfd_com_section_ptr;
|
||||||
}
|
}
|
||||||
/* We do not set the section of the symbol to
|
/* We do not set the section of the symbol to
|
||||||
h->root.u.c.section. That value was saved so
|
h->root.u.c.section. That value was saved so
|
||||||
|
@ -1981,7 +1981,7 @@ _bfd_generic_link_output_symbols (output_bfd, input_bfd, info, psymalloc)
|
||||||
else
|
else
|
||||||
output = false;
|
output = false;
|
||||||
}
|
}
|
||||||
else if (sym->section == &bfd_ind_section)
|
else if (bfd_is_ind_section (sym->section))
|
||||||
output = false;
|
output = false;
|
||||||
else if ((sym->flags & BSF_DEBUGGING) != 0)
|
else if ((sym->flags & BSF_DEBUGGING) != 0)
|
||||||
{
|
{
|
||||||
|
@ -1990,7 +1990,7 @@ _bfd_generic_link_output_symbols (output_bfd, input_bfd, info, psymalloc)
|
||||||
else
|
else
|
||||||
output = false;
|
output = false;
|
||||||
}
|
}
|
||||||
else if (sym->section == &bfd_und_section
|
else if (bfd_is_und_section (sym->section)
|
||||||
|| bfd_is_com_section (sym->section))
|
|| bfd_is_com_section (sym->section))
|
||||||
output = false;
|
output = false;
|
||||||
else if ((sym->flags & BSF_LOCAL) != 0)
|
else if ((sym->flags & BSF_LOCAL) != 0)
|
||||||
|
@ -2085,11 +2085,11 @@ _bfd_generic_link_write_global_symbol (h, data)
|
||||||
case bfd_link_hash_new:
|
case bfd_link_hash_new:
|
||||||
abort ();
|
abort ();
|
||||||
case bfd_link_hash_undefined:
|
case bfd_link_hash_undefined:
|
||||||
sym->section = &bfd_und_section;
|
sym->section = bfd_und_section_ptr;
|
||||||
sym->value = 0;
|
sym->value = 0;
|
||||||
break;
|
break;
|
||||||
case bfd_link_hash_weak:
|
case bfd_link_hash_weak:
|
||||||
sym->section = &bfd_und_section;
|
sym->section = bfd_und_section_ptr;
|
||||||
sym->value = 0;
|
sym->value = 0;
|
||||||
sym->flags |= BSF_WEAK;
|
sym->flags |= BSF_WEAK;
|
||||||
break;
|
break;
|
||||||
|
@ -2100,11 +2100,11 @@ _bfd_generic_link_write_global_symbol (h, data)
|
||||||
case bfd_link_hash_common:
|
case bfd_link_hash_common:
|
||||||
sym->value = h->root.u.c.size;
|
sym->value = h->root.u.c.size;
|
||||||
if (sym->section == NULL)
|
if (sym->section == NULL)
|
||||||
sym->section = &bfd_com_section;
|
sym->section = bfd_com_section_ptr;
|
||||||
else if (! bfd_is_com_section (sym->section))
|
else if (! bfd_is_com_section (sym->section))
|
||||||
{
|
{
|
||||||
BFD_ASSERT (sym->section == &bfd_und_section);
|
BFD_ASSERT (bfd_is_und_section (sym->section));
|
||||||
sym->section = &bfd_com_section;
|
sym->section = bfd_com_section_ptr;
|
||||||
}
|
}
|
||||||
/* Do not set the section; see _bfd_generic_link_output_symbols. */
|
/* Do not set the section; see _bfd_generic_link_output_symbols. */
|
||||||
break;
|
break;
|
||||||
|
|
Loading…
Reference in New Issue