/* Linker command language support.
- Copyright (C) 1991-2019 Free Software Foundation, Inc.
+ Copyright (C) 1991-2020 Free Software Foundation, Inc.
This file is part of the GNU Binutils.
/* We know the first statement on this list is *ABS*. May as well
skip it. */
- first = &lang_os_list.head->output_section_statement;
+ first = (void *) lang_os_list.head;
first = first->next;
/* First try for an exact match. */
lang_statement_union_type **assign = NULL;
bfd_boolean ignore_first;
- ignore_first = after == &lang_os_list.head->output_section_statement;
+ ignore_first = after == (void *) lang_os_list.head;
for (where = &after->header.next;
*where != NULL;
/* Shuffle the bfd section list to make the output file look
neater. This is really only cosmetic. */
if (place->section == NULL
- && after != &lang_os_list.head->output_section_statement)
+ && after != (void *) lang_os_list.head)
{
asection *bfd_section = after->bfd_section;
{
lang_input_statement_type *search;
- for (search = &input_file_chain.head->input_statement;
+ for (search = (void *) input_file_chain.head;
search != NULL;
search = search->next_real_file)
{
}
static void
-init_opb (void)
+init_opb (asection *s)
{
- unsigned x = bfd_arch_mach_octets_per_byte (ldfile_output_architecture,
- ldfile_output_machine);
+ unsigned int x;
+
opb_shift = 0;
+ if (bfd_get_flavour (link_info.output_bfd) == bfd_target_elf_flavour
+ && s != NULL
+ && (s->flags & SEC_ELF_OCTETS) != 0)
+ return;
+
+ x = bfd_arch_mach_octets_per_byte (ldfile_output_architecture,
+ ldfile_output_machine);
if (x > 1)
while ((x & 1) == 0)
{
lang_reset_memory_regions ();
}
- for (os = &lang_os_list.head->output_section_statement;
+ for (os = (void *) lang_os_list.head;
os != NULL;
os = os->next)
{
if (map_head_is_link_order)
return;
- for (os = &lang_os_list.head->output_section_statement;
+ for (os = (void *) lang_os_list.head;
os != NULL;
os = os->next)
{
int len;
bfd_vma addr;
- init_opb ();
+ init_opb (i);
print_space ();
minfo ("%s", i->name);
size = 0;
}
- minfo ("0x%V %W %pB\n", addr, size, i->owner);
+ minfo ("0x%V %W %pB\n", addr, TO_ADDR (size), i->owner);
if (size != i->rawsize && i->rawsize != 0)
{
--len;
}
- minfo (_("%W (size before relaxing)\n"), i->rawsize);
+ minfo (_("%W (size before relaxing)\n"), TO_ADDR (i->rawsize));
}
if (i->output_section != NULL
bfd_size_type size;
const char *name;
- init_opb ();
+ init_opb (data->output_section);
for (i = 0; i < SECTION_NAME_MAP_LENGTH; i++)
print_space ();
bfd_vma addr;
bfd_size_type size;
- init_opb ();
+ init_opb (reloc->output_section);
for (i = 0; i < SECTION_NAME_MAP_LENGTH; i++)
print_space ();
int len;
bfd_vma addr;
- init_opb ();
+ init_opb (s->output_section);
minfo (" *fill*");
len = sizeof " *fill*" - 1;
for (p = NULL, i = 0; i < count; i++)
{
s = sections[i].sec;
+ init_opb (s);
if ((s->flags & SEC_LOAD) != 0)
{
s_start = s->lma;
for (p = NULL, i = 0; i < count; i++)
{
s = sections[i].sec;
+ init_opb (s);
s_start = s->vma;
s_end = s_start + TO_ADDR (s->size) - 1;
int section_alignment = 0;
os = &s->output_section_statement;
+ init_opb (os->bfd_section);
if (os->constraint == -1)
break;
/* Otherwise, keep the same lma to vma relationship
as the previous section. */
else
- lma = dot + last->lma - last->vma;
+ lma = os->bfd_section->vma + last->lma - last->vma;
if (section_alignment > 0)
lma = align_power (lma, section_alignment);
os = &(s->output_section_statement);
os->after_end = *found_end;
+ init_opb (os->bfd_section);
if (os->bfd_section != NULL && !os->ignored)
{
if ((os->bfd_section->flags & SEC_ALLOC) != 0)
bfd *input_bfd;
const bfd_arch_info_type *compatible;
- for (file = &file_chain.head->input_statement;
+ for (file = (void *) file_chain.head;
file != NULL;
file = file->next)
{
{
lang_input_statement_type *f;
- for (f = &input_file_chain.head->input_statement;
+ for (f = (void *) input_file_chain.head;
f != NULL;
f = f->next_real_file)
if (f->flags.real)
p->last_os = NULL;
}
- for (os = &lang_os_list.head->output_section_statement;
+ for (os = (void *) lang_os_list.head;
os != NULL;
os = os->next)
{
find_replacements_insert_point (bfd_boolean *before)
{
lang_input_statement_type *claim1, *lastobject;
- lastobject = &input_file_chain.head->input_statement;
- for (claim1 = &file_chain.head->input_statement;
+ lastobject = (void *) input_file_chain.head;
+ for (claim1 = (void *) file_chain.head;
claim1 != NULL;
claim1 = claim1->next)
{
file chain if it is full of archive elements. Archives don't
appear on the file chain, but if an element has been extracted
then their input_statement->next points at it. */
- for (f = &input_file_chain.head->input_statement;
+ for (f = (void *) input_file_chain.head;
f != NULL;
f = f->next_real_file)
{
{
lang_output_section_statement_type *os;
- for (os = &lang_os_list.head->output_section_statement;
+ for (os = (void *) lang_os_list.head;
os != NULL;
os = os->next)
{
/* Open the output file. */
lang_for_each_statement (ldlang_open_output);
- init_opb ();
+ init_opb (NULL);
ldemul_create_output_section_statements ();
bfd_vma at;
c = 0;
- for (os = &lang_os_list.head->output_section_statement;
+ for (os = (void *) lang_os_list.head;
os != NULL;
os = os->next)
{
free (secs);
/* Make sure all the phdr assignments succeeded. */
- for (os = &lang_os_list.head->output_section_statement;
+ for (os = (void *) lang_os_list.head;
os != NULL;
os = os->next)
{
for (r = lang_memory_region_list; r->next != NULL; r = r->next)
{
bfd_vma used_length = r->current - r->origin;
- double percent;
printf ("%16s: ",r->name_list.name);
lang_print_memory_size (used_length);
lang_print_memory_size ((bfd_vma) r->length);
- percent = used_length * 100.0 / r->length;
-
- printf (" %6.2f%%\n", percent);
+ if (r->length != 0)
+ {
+ double percent = used_length * 100.0 / r->length;
+ printf (" %6.2f%%", percent);
+ }
+ printf ("\n");
}
}