+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;
+ bfd_boolean big_endian = FALSE;
+
+ 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;
+
+ /* 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 (link_info.output_bfd))
+ big_endian = TRUE;
+ else if (bfd_little_endian (link_info.output_bfd))
+ big_endian = FALSE;
+ else
+ {
+ bfd_boolean swap;
+
+ swap = FALSE;
+ if (command_line.endian == ENDIAN_BIG)
+ big_endian = TRUE;
+ else if (command_line.endian == ENDIAN_LITTLE)
+ {
+ big_endian = FALSE;
+ swap = TRUE;
+ }
+ else if (command_line.endian == ENDIAN_UNSET)
+ {
+ big_endian = TRUE;
+ {
+ LANG_FOR_EACH_INPUT_STATEMENT (s)
+ {
+ if (s->the_bfd != NULL)
+ {
+ if (bfd_little_endian (s->the_bfd))
+ {
+ big_endian = FALSE;
+ swap = TRUE;
+ }
+ break;
+ }
+ }
+ }
+ }