static void print_file_stuff PARAMS ((lang_input_statement_type *));
static boolean print_symbol PARAMS ((struct bfd_link_hash_entry *, PTR));
+extern char *strdup();
+
/* Build link_order structures for the BFD linker. */
static void
link_order = bfd_new_link_order (output_bfd, output_section);
if (link_order == NULL)
- einfo ("%P%F: bfd_new_link_order failed");
+ einfo ("%P%F: bfd_new_link_order failed\n");
link_order->type = bfd_data_link_order;
link_order->offset = statement->data_statement.output_vma;
value = statement->data_statement.value;
+ /* If the endianness of the output BFD is not known, then we
+ base the endianness of the data on the first input file.
+ By convention, the bfd_put routines for an unknown
+ endianness are big endian, so we must swap here if the
+ input file is little endian. */
+ if (! bfd_big_endian (output_bfd)
+ && ! bfd_little_endian (output_bfd))
+ {
+ boolean swap;
+
+ swap = false;
+ if (command_line.endian == ENDIAN_LITTLE)
+ swap = true;
+ else if (command_line.endian == ENDIAN_UNSET)
+ {
+ LANG_FOR_EACH_INPUT_STATEMENT (s)
+ {
+ if (s->the_bfd != NULL)
+ {
+ if (bfd_little_endian (s->the_bfd))
+ swap = true;
+ break;
+ }
+ }
+ }
+
+ if (swap)
+ {
+ bfd_byte buffer[8];
+
+ switch (statement->data_statement.type)
+ {
+ case QUAD:
+ bfd_putl64 (value, buffer);
+ value = bfd_getb64 (buffer);
+ break;
+ case LONG:
+ bfd_putl32 (value, buffer);
+ value = bfd_getb32 (buffer);
+ break;
+ case SHORT:
+ bfd_putl16 (value, buffer);
+ value = bfd_getb16 (buffer);
+ break;
+ case BYTE:
+ break;
+ default:
+ abort ();
+ }
+ }
+ }
+
ASSERT (output_section->owner == output_bfd);
switch (statement->data_statement.type)
{
link_order = bfd_new_link_order (output_bfd, output_section);
if (link_order == NULL)
- einfo ("%P%F: bfd_new_link_order failed");
+ einfo ("%P%F: bfd_new_link_order failed\n");
link_order->offset = rs->output_vma;
link_order->size = bfd_get_reloc_size (rs->howto);
link_order->u.reloc.p->reloc = rs->reloc;
link_order->u.reloc.p->addend = rs->addend_value;
- if (rs->section != (asection *) NULL)
+ if (rs->name == 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
{
- ASSERT (rs->name != (const char *) NULL);
link_order->type = bfd_symbol_reloc_link_order;
link_order->u.reloc.p->u.name = rs->name;
}
chars of base section name and a digit suffix */
do
{
- int i;
+ unsigned int i;
char b[6];
for (i = 0; i < sizeof (b) - 1 && s->name[i]; i++)
b[i] = s->name[i];
n->output_section = n;
n->orelocation = 0;
n->reloc_count = 0;
- n->alignment_power = 1;
+ n->alignment_power = s->alignment_power;
return n;
}
static void
print_symbol_table ()
{
- fprintf (config.map_file, "**FILES**\n\n");
+ fprintf (config.map_file, "\n**FILES**\n\n");
lang_for_each_file (print_file_stuff);
fprintf (config.map_file, "**GLOBAL SYMBOLS**\n\n");