# This shell script emits a C file. -*- C -*-
-# Copyright 2006, 2007, 2008
-# Free Software Foundation, Inc.
+# Copyright (C) 2006-2016 Free Software Foundation, Inc.
#
# This file is part of the GNU Binutils.
#
#include "elf32-avr.h"
#include "ldctor.h"
+#include "elf/avr.h"
/* The fake file and it's corresponding section meant to hold
the linker stubs if needed. */
gld${EMULATION_NAME}_before_allocation ();
- /* We only need stubs for the avr6 family. */
- if (strcmp ("${EMULATION_NAME}","avr6"))
+ /* We only need stubs for avr6, avrxmega6, and avrxmega7. */
+ if (strcmp ("${EMULATION_NAME}","avr6")
+ && strcmp ("${EMULATION_NAME}","avrxmega6")
+ && strcmp ("${EMULATION_NAME}","avrxmega7") )
avr_no_stubs = TRUE;
avr_elf_set_global_bfd_parameters ();
/* If generating a relocatable output file, then
we don't have to generate the trampolines. */
- if (link_info.relocatable)
+ if (bfd_link_relocatable (&link_info))
avr_no_stubs = TRUE;
if (avr_no_stubs)
static void
avr_elf_after_allocation (void)
{
- if (!avr_no_stubs && !command_line.relax)
+ if (!avr_no_stubs && ! RELAXATION_ENABLED)
{
/* If relaxing, elf32_avr_size_stubs will be called from
elf32_avr_relax_section. */
- if (!elf32_avr_size_stubs (link_info.output_bfd, &link_info, FALSE))
+ if (!elf32_avr_size_stubs (link_info.output_bfd, &link_info, TRUE))
einfo ("%X%P: can not size stub section: %E\n");
}
}
}
+static void
+avr_elf_before_parse (void)
+{
+ /* Don't create a demand-paged executable, since this feature isn't
+ meaningful in AVR. */
+ config.magic_demand_paged = FALSE;
+
+ gld${EMULATION_NAME}_before_parse ();
+}
+
+static void
+avr_finish (void)
+{
+ bfd *abfd;
+ bfd_boolean avr_link_relax;
+ if (bfd_link_relocatable (&link_info))
+ {
+ avr_link_relax = TRUE;
+ for (abfd = link_info.input_bfds; abfd != NULL; abfd = abfd->link.next)
+ {
+ /* Don't let the linker stubs prevent the final object being
+ marked as link-relax ready. */
+ if ((elf_elfheader (abfd)->e_flags
+ & EF_AVR_LINKRELAX_PREPARED) == 0
+ && abfd != stub_file->the_bfd)
+ {
+ avr_link_relax = FALSE;
+ break;
+ }
+ }
+ }
+ else
+ {
+ avr_link_relax = RELAXATION_ENABLED;
+ }
+
+ abfd = link_info.output_bfd;
+ if (avr_link_relax)
+ elf_elfheader (abfd)->e_flags |= EF_AVR_LINKRELAX_PREPARED;
+ else
+ elf_elfheader (abfd)->e_flags &= ~EF_AVR_LINKRELAX_PREPARED;
+
+ finish_default ();
+}
EOF
#
# Put these extra avr-elf routines in ld_${EMULATION_NAME}_emulation
#
+LDEMUL_BEFORE_PARSE=avr_elf_before_parse
LDEMUL_BEFORE_ALLOCATION=avr_elf_${EMULATION_NAME}_before_allocation
LDEMUL_AFTER_ALLOCATION=avr_elf_after_allocation
LDEMUL_CREATE_OUTPUT_SECTION_STATEMENTS=avr_elf_create_output_section_statements
+LDEMUL_FINISH=avr_finish