Changes to make -Ur work again.

* ldmain.c (add_to_set): Now takes reloc argument rather than
	bitsize.  Check config.build_constructors here.  If an new hash
	table entry is created, mark it as undefined.
	(constructor_callback): No longer takes bitsize argument.  Pass
	BFD_RELOC_CTOR to ldctor_add_set_entry, but first make sure the
	BFD backend supports it.
	(reloc_overflow): Handle a NULL abfd argument.
	(reloc_dangerous, unattached_reloc): Likewise.
	* ldctor.c: Include ldmain.h.
	(struct set_info): Change bitsize field to reloc.
	(ldctor_add_set_entry): Now takes reloc argument rather than
	bitsize.  Don't bother to check config.build_constructors here.
	(ldctor_build_sets): Get the size from the reloc howto.  If
	generating relocateable output, call lang_add_reloc rather than
	lang_add_data.
	* ldctor.h (ldctor_add_set_entry): Change declaration to use reloc
	instead of bitsize.
	* ldlang.h (statement_enum): Add lang_reloc_statement_enum.
	(lang_reloc_statement_type): New structure.
	(lang_statement_union_type): Add reloc_statement field.
	(lang_add_reloc): Declare new function.
	* ldlang.c (lang_for_each_statement_worker): Handle
	lang_reloc_statement_enum.
	(map_input_to_output_sections, print_statement): Likewise.
	(lang_size_sections, lang_do_assignments): Likewise.
	(print_reloc_statement): New function.
	(lang_add_reloc): New function.
	* ldwrite.c (build_link_order): Handle lang_reloc_statement_enum.
This commit is contained in:
Ian Lance Taylor 1994-03-22 00:24:13 +00:00
parent 651d2da7f6
commit 4fdbafb247
3 changed files with 208 additions and 6 deletions

View File

@ -1,3 +1,56 @@
Mon Mar 21 18:28:37 1994 Ian Lance Taylor (ian@tweedledumb.cygnus.com)
Changes to make -Ur work again.
* ldmain.c (add_to_set): Now takes reloc argument rather than
bitsize. Check config.build_constructors here. If an new hash
table entry is created, mark it as undefined.
(constructor_callback): No longer takes bitsize argument. Pass
BFD_RELOC_CTOR to ldctor_add_set_entry, but first make sure the
BFD backend supports it.
(reloc_overflow): Handle a NULL abfd argument.
(reloc_dangerous, unattached_reloc): Likewise.
* ldctor.c: Include ldmain.h.
(struct set_info): Change bitsize field to reloc.
(ldctor_add_set_entry): Now takes reloc argument rather than
bitsize. Don't bother to check config.build_constructors here.
(ldctor_build_sets): Get the size from the reloc howto. If
generating relocateable output, call lang_add_reloc rather than
lang_add_data.
* ldctor.h (ldctor_add_set_entry): Change declaration to use reloc
instead of bitsize.
* ldlang.h (statement_enum): Add lang_reloc_statement_enum.
(lang_reloc_statement_type): New structure.
(lang_statement_union_type): Add reloc_statement field.
(lang_add_reloc): Declare new function.
* ldlang.c (lang_for_each_statement_worker): Handle
lang_reloc_statement_enum.
(map_input_to_output_sections, print_statement): Likewise.
(lang_size_sections, lang_do_assignments): Likewise.
(print_reloc_statement): New function.
(lang_add_reloc): New function.
* ldwrite.c (build_link_order): Handle lang_reloc_statement_enum.
* Makefile.in (cdtest.out, cdtest-ur.o): New targets.
(cdtest-ur, cdtest-ur.out): New targets.
(check-cdtest): Now also check that -Ur works correctly.
* scripttemp/alpha.sc: Align all sections to 16 byte boundaries.
Thu Mar 17 12:45:41 1994 Ian Lance Taylor (ian@tweedledumb.cygnus.com)
* ldlang.c (lang_process): Move lang_common call before
map_input_to_output_sections, to ensure that any alignment
constraints set by common symbols are copied over to the output
sections.
Fri Mar 11 22:17:34 1994 Ian Lance Taylor (ian@tweedledumb.cygnus.com)
* emulparams/elf32ppc.sh (TEMPLATE_NAME): Don't define.
(OTHER_READWRITE_SECTIONS): Rename .toc to .got.
* Makefile.in (em_elf32ppc.c): Depend upon generic.em, not ppc.em.
* emultempl/ppc.em: Remove ugly stub code; turns out not to be
needed for ELF.
Tue Mar 8 04:22:27 1994 David J. Mackenzie (djm@rtl.cygnus.com)
* config/i386bsd.mh: New file.

View File

@ -112,6 +112,7 @@ static void print_input_statement PARAMS ((lang_input_statement_type *statm));
static void print_input_section PARAMS ((lang_input_section_type *in));
static void print_fill_statement PARAMS ((lang_fill_statement_type *fill));
static void print_data_statement PARAMS ((lang_data_statement_type *data));
static void print_reloc_statement PARAMS ((lang_reloc_statement_type *reloc));
static void print_padding_statement PARAMS ((lang_padding_statement_type *s));
static void print_wild_statement
PARAMS ((lang_wild_statement_type *w,
@ -231,6 +232,7 @@ lang_for_each_statement_worker (func, s)
s->wild_statement.children.head);
break;
case lang_data_statement_enum:
case lang_reloc_statement_enum:
case lang_object_symbols_statement_enum:
case lang_output_statement_enum:
case lang_target_statement_enum:
@ -778,6 +780,12 @@ lookup_name (name, force_load)
|| ! search->real
|| search->filename == (const char *) NULL)
return search;
/* start-sanitize-mpw */
#ifdef MPW
/* I hate adding code that works, but for reasons I don't know. */
search->the_bfd = NULL;
#endif
/* end-sanitize-mpw */
ldfile_open_file (search);
@ -1084,6 +1092,7 @@ map_input_to_output_sections (s, target, output_section_statement)
case lang_input_section_enum:
case lang_object_symbols_statement_enum:
case lang_data_statement_enum:
case lang_reloc_statement_enum:
case lang_assignment_statement_enum:
case lang_padding_statement_enum:
break;
@ -1365,6 +1374,32 @@ print_data_statement (data)
fprintf (config.map_file, "\n");
}
/* Print a reloc statement. */
static void
print_reloc_statement (reloc)
lang_reloc_statement_type *reloc;
{
print_section ("");
print_space ();
print_section ("");
print_space ();
/* ASSERT(print_dot == data->output_vma);*/
print_address (reloc->output_vma + reloc->output_section->vma);
print_space ();
print_address (reloc->addend_value);
print_space ();
fprintf (config.map_file, "RELOC %s ", reloc->howto->name);
print_dot += bfd_get_reloc_size (reloc->howto);
exp_print_tree (reloc->addend_exp);
fprintf (config.map_file, "\n");
}
static void
print_padding_statement (s)
@ -1443,6 +1478,9 @@ print_statement (s, os)
case lang_data_statement_enum:
print_data_statement (&s->data_statement);
break;
case lang_reloc_statement_enum:
print_reloc_statement (&s->reloc_statement);
break;
case lang_input_section_enum:
print_input_section (&s->input_section);
break;
@ -1730,6 +1768,20 @@ lang_size_sections (s, output_section_statement, prev, fill, dot, relax)
}
break;
case lang_reloc_statement_enum:
{
int size;
s->reloc_statement.output_vma =
dot - output_section_statement->bfd_section->vma;
s->reloc_statement.output_section =
output_section_statement->bfd_section;
size = bfd_get_reloc_size (s->reloc_statement.howto);
dot += size;
output_section_statement->bfd_section->_raw_size += size;
}
break;
case lang_wild_statement_enum:
dot = lang_size_sections (s->wild_statement.children.head,
@ -1918,6 +1970,21 @@ lang_do_assignments (s, output_section_statement, fill, dot)
break;
}
break;
case lang_reloc_statement_enum:
{
etree_value_type value;
value = exp_fold_tree (s->reloc_statement.addend_exp,
abs_output_section,
lang_final_phase_enum, dot, &dot);
s->reloc_statement.addend_value = value.value;
if (value.valid == false)
einfo ("%F%P: invalid reloc statement\n");
}
dot += bfd_get_reloc_size (s->reloc_statement.howto);
break;
case lang_input_section_enum:
{
asection *in = s->input_section.section;
@ -2447,6 +2514,9 @@ lang_process ()
files. */
ldctor_build_sets ();
/* Size up the common data */
lang_common ();
/* Run through the contours of the script and attatch input sections
to the correct output sections
*/
@ -2457,9 +2527,6 @@ lang_process ()
/* Find any sections not attatched explicitly and handle them */
lang_place_orphans ();
/* Size up the common data */
lang_common ();
ldemul_before_allocation ();
@ -2627,6 +2694,34 @@ lang_add_data (type, exp)
}
/* Create a new reloc statement. RELOC is the BFD relocation type to
generate. HOWTO is the corresponding howto structure (we could
look this up, but the caller has already done so). SECTION is the
section to generate a reloc against, or NAME is the name of the
symbol to generate a reloc against. Exactly one of SECTION and
NAME must be NULL. ADDEND is an expression for the addend. */
void
lang_add_reloc (reloc, howto, section, name, addend)
bfd_reloc_code_real_type reloc;
const reloc_howto_type *howto;
asection *section;
const char *name;
union etree_union *addend;
{
lang_reloc_statement_type *p = new_stat (lang_reloc_statement, stat_ptr);
p->reloc = reloc;
p->howto = howto;
p->section = section;
p->name = name;
p->addend_exp = addend;
p->addend_value = 0;
p->output_section = NULL;
p->output_vma = 0;
}
void
lang_add_assignment (exp)
etree_type * exp;

View File

@ -48,13 +48,17 @@ build_link_order (statement)
it just does the output directly. */
{
bfd_vma value = statement->data_statement.value;
bfd_byte play_area[LONG_SIZE];
bfd_byte play_area[QUAD_SIZE];
unsigned int size = 0;
asection *output_section = statement->data_statement.output_section;
ASSERT (output_section->owner == output_bfd);
switch (statement->data_statement.type)
{
case QUAD:
bfd_put_64 (output_bfd, value, play_area);
size = QUAD_SIZE;
break;
case LONG:
bfd_put_32 (output_bfd, value, play_area);
size = LONG_SIZE;
@ -79,6 +83,52 @@ build_link_order (statement)
}
break;
case lang_reloc_statement_enum:
{
lang_reloc_statement_type *rs;
asection *output_section;
struct bfd_link_order *link_order;
rs = &statement->reloc_statement;
output_section = rs->output_section;
ASSERT (output_section->owner == output_bfd);
link_order = bfd_new_link_order (output_bfd, output_section);
if (link_order == NULL)
einfo ("%P%F: bfd_new_link_order failed");
link_order->offset = rs->output_vma;
link_order->size = bfd_get_reloc_size (rs->howto);
link_order->u.reloc.p =
((struct bfd_link_order_reloc *)
xmalloc (sizeof (struct bfd_link_order_reloc)));
link_order->u.reloc.p->reloc = rs->reloc;
link_order->u.reloc.p->addend = rs->addend_value;
if (rs->section != (asection *) NULL)
{
ASSERT (rs->name == (const char *) NULL);
link_order->type = bfd_section_reloc_link_order;
if (rs->section->owner == output_bfd)
link_order->u.reloc.p->u.section = rs->section;
else
{
link_order->u.reloc.p->u.section = rs->section->output_section;
link_order->u.reloc.p->addend += rs->section->output_offset;
}
}
else
{
ASSERT (rs->name != (const char *) NULL);
link_order->type = bfd_symbol_reloc_link_order;
link_order->u.reloc.p->u.name = rs->name;
}
}
break;
case lang_input_section_enum:
/* Create a new link_order in the output section with this
attached */
@ -109,7 +159,10 @@ build_link_order (statement)
link_order->u.indirect.section = i;
ASSERT (i->output_section == output_section);
}
link_order->size = bfd_section_size (i->owner, i);
if (i->_cooked_size)
link_order->size = i->_cooked_size;
else
link_order->size = bfd_get_section_size_before_reloc (i);
link_order->offset = i->output_offset;
}
}
@ -149,7 +202,7 @@ ldwrite ()
lang_for_each_statement (build_link_order);
if (! bfd_final_link (output_bfd, &link_info))
einfo ("%F%P: %B: %E\n", output_bfd);
einfo ("%F%P: final link failed: %E\n", output_bfd);
if (config.map_file)
{
@ -226,6 +279,7 @@ print_file_stuff (f)
/* Print a symbol. */
/*ARGSUSED*/
static boolean
print_symbol (p, ignore)
struct bfd_link_hash_entry *p;