-char *ldmalloc();
-/* Static vars for do_warnings and subroutines of it */
-int list_unresolved_refs; /* List unresolved refs */
-int list_warning_symbols; /* List warning syms */
-int list_multiple_defs; /* List multiple definitions */
-extern int errno;
-extern char *sys_errlist[];
-
-extern unsigned int undefined_global_sym_count;
+static void
+build_link_order (lang_statement_union_type *statement)
+{
+ switch (statement->header.type)
+ {
+ case lang_data_statement_enum:
+ {
+ asection *output_section;
+ struct bfd_link_order *link_order;
+ bfd_vma value;
+
+ output_section = statement->data_statement.output_section;
+ ASSERT (output_section->owner == link_info.output_bfd);
+
+ if (!((output_section->flags & SEC_HAS_CONTENTS) != 0
+ || ((output_section->flags & SEC_LOAD) != 0
+ && (output_section->flags & SEC_THREAD_LOCAL))))
+ break;
+
+ link_order = bfd_new_link_order (link_info.output_bfd, output_section);
+ if (link_order == NULL)
+ einfo (_("%F%P: bfd_new_link_order failed\n"));
+
+ link_order->type = bfd_data_link_order;
+ link_order->offset = statement->data_statement.output_offset;
+ link_order->u.data.contents = (bfd_byte *) xmalloc (QUAD_SIZE);
+
+ value = statement->data_statement.value;
+
+ /* By convention, the bfd_put routines for an unknown
+ endianness are big endian, so we must swap here if the
+ input is little endian. */
+ if (!bfd_big_endian (link_info.output_bfd)
+ && !bfd_little_endian (link_info.output_bfd)
+ && !link_info.big_endian)
+ {
+ bfd_byte buffer[8];
+
+ switch (statement->data_statement.type)
+ {
+ case QUAD:
+ case SQUAD:
+ if (sizeof (bfd_vma) >= QUAD_SIZE)
+ {
+ bfd_putl64 (value, buffer);
+ value = bfd_getb64 (buffer);
+ break;
+ }
+ /* Fall through. */
+ 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 ();
+ }
+ }