/* This file is is generated by a shell script. DO NOT EDIT! */
/* ${ELFSIZE} bit ELF emulation code for ${EMULATION_NAME}
- Copyright (C) 1991-2015 Free Software Foundation, Inc.
+ Copyright (C) 1991-2016 Free Software Foundation, Inc.
Written by Steve Chamberlain <sac@cygnus.com>
ELF support by Ian Lance Taylor <ian@cygnus.com>
#include "ldmain.h"
#include "ldmisc.h"
#include "ldexp.h"
-#include "ldlex.h"
#include "ldlang.h"
#include "ldfile.h"
#include "ldemul.h"
/* Declare functions used by various EXTRA_EM_FILEs. */
static void gld${EMULATION_NAME}_before_parse (void);
+static void gld${EMULATION_NAME}_after_parse (void);
static void gld${EMULATION_NAME}_after_open (void);
static void gld${EMULATION_NAME}_before_allocation (void);
static void gld${EMULATION_NAME}_after_allocation (void);
input_flags.dynamic = ${DYNAMIC_LINK-TRUE};
config.has_shared = `if test -n "$GENERATE_SHLIB_SCRIPT" ; then echo TRUE ; else echo FALSE ; fi`;
config.separate_code = `if test "x${SEPARATE_CODE}" = xyes ; then echo TRUE ; else echo FALSE ; fi`;
+ `if test -n "$CALL_NOP_BYTE" ; then echo link_info.call_nop_byte = $CALL_NOP_BYTE; fi`;
+ link_info.check_relocs_after_open_input = `if test "x${CHECK_RELOCS_AFTER_OPEN_INPUT}" = xyes ; then echo TRUE ; else echo FALSE ; fi`;
+ link_info.relro = DEFAULT_LD_Z_RELRO;
+}
+
+EOF
+fi
+
+if test x"$LDEMUL_AFTER_PARSE" != xgld"$EMULATION_NAME"_after_parse; then
+fragment <<EOF
+
+static void
+gld${EMULATION_NAME}_after_parse (void)
+{
+ if (bfd_link_pie (&link_info))
+ link_info.flags_1 |= (bfd_vma) DF_1_PIE;
+
+ after_parse_default ();
}
EOF
rp = bfd_elf_get_runpath_list (link_info.output_bfd, &link_info);
for (; !found && rp != NULL; rp = rp->next)
{
- char *tmpname = gld${EMULATION_NAME}_add_sysroot (rp->name);
+ const char *tmpname = rp->name;
+
+ if (IS_ABSOLUTE_PATH (tmpname))
+ tmpname = gld${EMULATION_NAME}_add_sysroot (tmpname);
found = (rp->by == l->by
&& gld${EMULATION_NAME}_search_needed (tmpname,
&n,
force));
- free (tmpname);
+ if (tmpname != rp->name)
+ free ((char *) tmpname);
}
if (found)
break;
}
}
+#if defined(__GNUC__) && GCC_VERSION < 4006
+ /* Work around a GCC uninitialized warning bug fixed in GCC 4.6. */
+static struct bfd_link_hash_entry ehdr_start_empty;
+#endif
+
/* This is called after the sections have been attached to output
sections, but before any sizes or addresses have been set. */
struct elf_link_hash_entry *ehdr_start = NULL;
#if defined(__GNUC__) && GCC_VERSION < 4006
/* Work around a GCC uninitialized warning bug fixed in GCC 4.6. */
- struct bfd_link_hash_entry ehdr_start_save = ehdr_start_save;
+ struct bfd_link_hash_entry ehdr_start_save = ehdr_start_empty;
#else
struct bfd_link_hash_entry ehdr_start_save;
#endif
asection *s;
bfd_size_type sz;
char *msg;
- bfd_boolean ret;
if (is->flags.just_syms)
continue;
einfo ("%F%B: Can't read contents of section .gnu.warning: %E\n",
is->the_bfd);
msg[sz] = '\0';
- ret = link_info.callbacks->warning (&link_info, msg,
- (const char *) NULL,
- is->the_bfd, (asection *) NULL,
- (bfd_vma) 0);
- ASSERT (ret);
+ (*link_info.callbacks->warning) (&link_info, msg,
+ (const char *) NULL, is->the_bfd,
+ (asection *) NULL, (bfd_vma) 0);
free (msg);
/* Clobber the section size, so that we don't waste space
int isdyn = 0;
int iself = s->owner->xvec->flavour == bfd_target_elf_flavour;
unsigned int sh_type = iself ? elf_section_type (s) : SHT_NULL;
+ flagword flags;
+ asection *nexts;
if (!bfd_link_relocatable (&link_info)
&& link_info.combreloc
if (os->bfd_section != NULL
&& (os->bfd_section->flags == 0
- || (_bfd_elf_match_sections_by_type (link_info.output_bfd,
- os->bfd_section,
- s->owner, s)
- && ((s->flags ^ os->bfd_section->flags)
- & (SEC_LOAD | SEC_ALLOC)) == 0)))
+ || (((s->flags ^ os->bfd_section->flags)
+ & (SEC_LOAD | SEC_ALLOC)) == 0
+ && _bfd_elf_match_sections_by_type (link_info.output_bfd,
+ os->bfd_section,
+ s->owner, s))))
{
/* We already have an output section statement with this
name, and its bfd section has compatible flags.
return os;
}
+ flags = s->flags;
+ if (!bfd_link_relocatable (&link_info))
+ {
+ nexts = s;
+ while ((nexts = bfd_get_next_section_by_name (nexts->owner, nexts))
+ != NULL)
+ if (nexts->output_section == NULL
+ && (nexts->flags & SEC_EXCLUDE) == 0
+ && ((nexts->flags ^ flags) & (SEC_LOAD | SEC_ALLOC)) == 0
+ && (nexts->owner->flags & DYNAMIC) == 0
+ && nexts->owner->usrdata != NULL
+ && !(((lang_input_statement_type *) nexts->owner->usrdata)
+ ->flags.just_syms)
+ && _bfd_elf_match_sections_by_type (nexts->owner, nexts,
+ s->owner, s))
+ flags = (((flags ^ SEC_READONLY)
+ | (nexts->flags ^ SEC_READONLY))
+ ^ SEC_READONLY);
+ }
+
/* Decide which segment the section should go in based on the
section name and section flags. We put loadable .note sections
right after the .interp section, so that the PT_NOTE segment is
in the first page. */
place = NULL;
- if ((s->flags & (SEC_ALLOC | SEC_DEBUGGING)) == 0)
+ if ((flags & (SEC_ALLOC | SEC_DEBUGGING)) == 0)
place = &hold[orphan_nonalloc];
- else if ((s->flags & SEC_ALLOC) == 0)
+ else if ((flags & SEC_ALLOC) == 0)
;
- else if ((s->flags & SEC_LOAD) != 0
+ else if ((flags & SEC_LOAD) != 0
&& ((iself && sh_type == SHT_NOTE)
|| (!iself && CONST_STRNEQ (secname, ".note"))))
place = &hold[orphan_interp];
- else if ((s->flags & (SEC_LOAD | SEC_HAS_CONTENTS | SEC_THREAD_LOCAL)) == 0)
+ else if ((flags & (SEC_LOAD | SEC_HAS_CONTENTS | SEC_THREAD_LOCAL)) == 0)
place = &hold[orphan_bss];
- else if ((s->flags & SEC_SMALL_DATA) != 0)
+ else if ((flags & SEC_SMALL_DATA) != 0)
place = &hold[orphan_sdata];
- else if ((s->flags & SEC_THREAD_LOCAL) != 0)
+ else if ((flags & SEC_THREAD_LOCAL) != 0)
place = &hold[orphan_tdata];
- else if ((s->flags & SEC_READONLY) == 0)
+ else if ((flags & SEC_READONLY) == 0)
place = &hold[orphan_data];
else if (((iself && (sh_type == SHT_RELA || sh_type == SHT_REL))
|| (!iself && CONST_STRNEQ (secname, ".rel")))
- && (s->flags & SEC_LOAD) != 0)
+ && (flags & SEC_LOAD) != 0)
place = &hold[orphan_rel];
- else if ((s->flags & SEC_CODE) == 0)
+ else if ((flags & SEC_CODE) == 0)
place = &hold[orphan_rodata];
else
place = &hold[orphan_text];
}
after = place->os;
if (after == NULL)
- after = lang_output_section_find_by_flags
- (s, &place->os, _bfd_elf_match_sections_by_type);
+ after
+ = lang_output_section_find_by_flags (s, flags, &place->os,
+ _bfd_elf_match_sections_by_type);
if (after == NULL)
/* *ABS* is always the first output section statement. */
after = &lang_output_section_statement.head->output_section_statement;
EOF
fi
-if test x"$GENERATE_PIE_SCRIPT" = xyes; then
-fragment <<EOF
- case OPTION_PIE:
- link_info.flags_1 |= (bfd_vma) DF_1_PIE;
- break;
-EOF
-fi
fragment <<EOF
case 'z':
if (strcmp (optarg, "defs") == 0)
link_info.relro = TRUE;
else if (strcmp (optarg, "norelro") == 0)
link_info.relro = FALSE;
+ else if (strcmp (optarg, "common") == 0)
+ link_info.elf_stt_common = elf_stt_common;
+ else if (strcmp (optarg, "nocommon") == 0)
+ link_info.elf_stt_common = no_elf_stt_common;
else if (strcmp (optarg, "text") == 0)
link_info.error_textrel = TRUE;
else if (strcmp (optarg, "notext") == 0)
${LDEMUL_BEFORE_PARSE-gld${EMULATION_NAME}_before_parse},
${LDEMUL_SYSLIB-syslib_default},
${LDEMUL_HLL-hll_default},
- ${LDEMUL_AFTER_PARSE-after_parse_default},
+ ${LDEMUL_AFTER_PARSE-gld${EMULATION_NAME}_after_parse},
${LDEMUL_AFTER_OPEN-gld${EMULATION_NAME}_after_open},
${LDEMUL_AFTER_ALLOCATION-gld${EMULATION_NAME}_after_allocation},
${LDEMUL_SET_OUTPUT_ARCH-set_output_arch_default},