devkitA64: update binutils patch with latest changes

This commit is contained in:
fincs 2019-03-23 19:32:37 +01:00 committed by Dave Murphy
parent ade65bab03
commit 65c1a1256a
2 changed files with 252 additions and 346 deletions

View File

@ -1,346 +0,0 @@
diff -NBaur binutils-2.31.1/bfd/elfnn-aarch64.c binutils-2.31.1-dka64/bfd/elfnn-aarch64.c
--- binutils-2.31.1/bfd/elfnn-aarch64.c 2018-06-25 12:44:16.000000000 +0100
+++ binutils-2.31.1-dka64/bfd/elfnn-aarch64.c 2018-07-27 18:11:15.757082269 +0100
@@ -2342,6 +2342,12 @@
aarch64_stub_erratum_843419_veneer,
};
+/* Is an undefined weak symbol resolved to 0 ? */
+#define UNDEFINED_WEAK_RESOLVED_TO_ZERO(INFO, EH) \
+ ((EH)->root.root.type == bfd_link_hash_undefweak \
+ && bfd_link_executable (INFO) \
+ && !(INFO)->dynamic_undefined_weak)
+
struct elf_aarch64_stub_hash_entry
{
/* Base hash table entry structure. */
@@ -6370,11 +6376,13 @@
Elf_Internal_Sym *sym;
asection *sec;
struct elf_link_hash_entry *h;
+ struct elf_aarch64_link_hash_entry *eh;
bfd_vma relocation;
bfd_reloc_status_type r;
arelent bfd_reloc;
char sym_type;
bfd_boolean unresolved_reloc = FALSE;
+ bfd_boolean resolved_to_zero = FALSE;
char *error_message = NULL;
r_symndx = ELFNN_R_SYM (rel->r_info);
@@ -6509,6 +6517,10 @@
h, &unresolved_reloc,
save_addend, &addend, sym);
+ eh = (struct elf_aarch64_link_hash_entry *) h;
+ resolved_to_zero = (eh != NULL
+ && UNDEFINED_WEAK_RESOLVED_TO_ZERO (info, eh));
+
switch (elfNN_aarch64_bfd_reloc_from_type (input_bfd, r_type))
{
case BFD_RELOC_AARCH64_TLSGD_ADD_LO12_NC:
@@ -6532,7 +6544,7 @@
need_relocs =
(!bfd_link_executable (info) || indx != 0) &&
(h == NULL
- || ELF_ST_VISIBILITY (h->other) == STV_DEFAULT
+ || (ELF_ST_VISIBILITY (h->other) == STV_DEFAULT && !resolved_to_zero)
|| h->root.type != bfd_link_hash_undefweak);
BFD_ASSERT (globals->root.srelgot != NULL);
@@ -6627,7 +6639,7 @@
need_relocs =
(!bfd_link_executable (info) || indx != 0) &&
(h == NULL
- || ELF_ST_VISIBILITY (h->other) == STV_DEFAULT
+ || (ELF_ST_VISIBILITY (h->other) == STV_DEFAULT && !resolved_to_zero)
|| h->root.type != bfd_link_hash_undefweak);
BFD_ASSERT (globals->root.srelgot != NULL);
@@ -6676,7 +6688,7 @@
bfd_vma off = symbol_tlsdesc_got_offset (input_bfd, h, r_symndx);
need_relocs = (h == NULL
- || ELF_ST_VISIBILITY (h->other) == STV_DEFAULT
+ || (ELF_ST_VISIBILITY (h->other) == STV_DEFAULT && !resolved_to_zero)
|| h->root.type != bfd_link_hash_undefweak);
BFD_ASSERT (globals->root.srelgot != NULL);
@@ -7019,6 +7031,26 @@
return FALSE;
}
+/* Remove undefined weak symbol from the dynamic symbol table if it
+ is resolved to 0. */
+
+extern bfd_boolean
+elfNN_aarch64_elf_fixup_symbol (struct bfd_link_info *, struct elf_link_hash_entry *);
+
+bfd_boolean
+elfNN_aarch64_elf_fixup_symbol (struct bfd_link_info *info,
+ struct elf_link_hash_entry *h)
+{
+ if (h->dynindx != -1
+ && UNDEFINED_WEAK_RESOLVED_TO_ZERO (info, elf_aarch64_hash_entry (h)))
+ {
+ h->dynindx = -1;
+ _bfd_elf_strtab_delref (elf_hash_table (info)->dynstr,
+ h->dynstr_index);
+ }
+ return TRUE;
+}
+
/* Adjust a symbol defined by a dynamic object and referenced by a
regular object. The current definition is in some section of the
dynamic object, but we're not including those sections. We have to
@@ -8221,6 +8253,7 @@
struct elf_aarch64_link_hash_table *htab;
struct elf_aarch64_link_hash_entry *eh;
struct elf_dyn_relocs *p;
+ bfd_boolean resolved_to_zero;
/* An example of a bfd_link_hash_indirect symbol is versioned
symbol. For example: __gxx_personality_v0(bfd_link_hash_indirect)
@@ -8240,6 +8273,10 @@
info = (struct bfd_link_info *) inf;
htab = elf_aarch64_hash_table (info);
+ eh = (struct elf_aarch64_link_hash_entry *) h;
+ eh->tlsdesc_got_jump_table_offset = (bfd_vma) - 1;
+ resolved_to_zero = UNDEFINED_WEAK_RESOLVED_TO_ZERO (info, eh);
+
/* Since STT_GNU_IFUNC symbol must go through PLT, we handle it
here if it is defined and referenced in a non-shared object. */
if (h->type == STT_GNU_IFUNC
@@ -8249,7 +8286,7 @@
{
/* Make sure this symbol is output as a dynamic symbol.
Undefined weak syms won't yet be marked as dynamic. */
- if (h->dynindx == -1 && !h->forced_local
+ if (h->dynindx == -1 && !h->forced_local && !resolved_to_zero
&& h->root.type == bfd_link_hash_undefweak)
{
if (!bfd_elf_link_record_dynamic_symbol (info, h))
@@ -8283,6 +8320,11 @@
of relaxing into these from the large model PLT entries. */
s->size += PLT_SMALL_ENTRY_SIZE;
+ /* There should be no PLT relocations against resolved undefined
+ weak symbols in the executable. */
+ if (!resolved_to_zero)
+ {
+
/* We also need to make an entry in the .got.plt section, which
will be placed in the .got section by the linker script. */
htab->root.sgotplt->size += GOT_ENTRY_SIZE;
@@ -8305,6 +8347,7 @@
htab->root.srelplt->reloc_count++;
}
+ }
else
{
h->plt.offset = (bfd_vma) - 1;
@@ -8317,9 +8360,6 @@
h->needs_plt = 0;
}
- eh = (struct elf_aarch64_link_hash_entry *) h;
- eh->tlsdesc_got_jump_table_offset = (bfd_vma) - 1;
-
if (h->got.refcount > 0)
{
bfd_boolean dyn;
@@ -8331,7 +8371,7 @@
/* Make sure this symbol is output as a dynamic symbol.
Undefined weak syms won't yet be marked as dynamic. */
- if (dyn && h->dynindx == -1 && !h->forced_local
+ if (dyn && h->dynindx == -1 && !h->forced_local && !resolved_to_zero
&& h->root.type == bfd_link_hash_undefweak)
{
if (!bfd_elf_link_record_dynamic_symbol (info, h))
@@ -8345,7 +8385,7 @@
{
h->got.offset = htab->root.sgot->size;
htab->root.sgot->size += GOT_ENTRY_SIZE;
- if ((ELF_ST_VISIBILITY (h->other) == STV_DEFAULT
+ if (((ELF_ST_VISIBILITY (h->other) == STV_DEFAULT && !resolved_to_zero)
|| h->root.type != bfd_link_hash_undefweak)
&& (bfd_link_pic (info)
|| WILL_CALL_FINISH_DYNAMIC_SYMBOL (dyn, 0, h))
@@ -8381,7 +8421,7 @@
}
indx = h && h->dynindx != -1 ? h->dynindx : 0;
- if ((ELF_ST_VISIBILITY (h->other) == STV_DEFAULT
+ if (((ELF_ST_VISIBILITY (h->other) == STV_DEFAULT && !resolved_to_zero)
|| h->root.type != bfd_link_hash_undefweak)
&& (!bfd_link_executable (info)
|| indx != 0
@@ -8447,7 +8487,7 @@
visibility. */
if (eh->dyn_relocs != NULL && h->root.type == bfd_link_hash_undefweak)
{
- if (ELF_ST_VISIBILITY (h->other) != STV_DEFAULT
+ if (ELF_ST_VISIBILITY (h->other) != STV_DEFAULT || resolved_to_zero
|| UNDEFWEAK_NO_DYNAMIC_RELOC (info, h))
eh->dyn_relocs = NULL;
@@ -8467,7 +8507,9 @@
symbols which turn out to need copy relocs or are not
dynamic. */
- if (!h->non_got_ref
+ if (!(h->non_got_ref
+ || (h->root.type == bfd_link_hash_undefweak
+ && !resolved_to_zero))
&& ((h->def_dynamic
&& !h->def_regular)
|| (htab->root.dynamic_sections_created
@@ -8478,6 +8520,7 @@
Undefined weak syms won't yet be marked as dynamic. */
if (h->dynindx == -1
&& !h->forced_local
+ && !resolved_to_zero
&& h->root.type == bfd_link_hash_undefweak
&& !bfd_elf_link_record_dynamic_symbol (info, h))
return FALSE;
@@ -9098,8 +9141,17 @@
Elf_Internal_Sym *sym)
{
struct elf_aarch64_link_hash_table *htab;
+ struct elf_aarch64_link_hash_entry *eh;
+ bfd_boolean local_undefweak;
htab = elf_aarch64_hash_table (info);
+ eh = (struct elf_aarch64_link_hash_entry *) h;
+
+ /* We keep PLT/GOT entries without dynamic PLT/GOT relocations for
+ resolved undefined weak symbols in executable so that their
+ references have value 0 at run-time. */
+ local_undefweak = UNDEFINED_WEAK_RESOLVED_TO_ZERO (info, eh);
+
if (h->plt.offset != (bfd_vma) - 1)
{
asection *plt, *gotplt, *relplt;
@@ -9134,7 +9186,7 @@
return FALSE;
elfNN_aarch64_create_small_pltn_entry (h, htab, output_bfd, info);
- if (!h->def_regular)
+ if (!local_undefweak && !h->def_regular)
{
/* Mark the symbol as undefined, rather than as defined in
the .plt section. */
@@ -9153,10 +9205,11 @@
}
if (h->got.offset != (bfd_vma) - 1
- && elf_aarch64_hash_entry (h)->got_type == GOT_NORMAL
+ && elf_aarch64_hash_entry (h)->got_type == GOT_NORMAL
/* Undefined weak symbol in static PIE resolves to 0 without
any dynamic relocations. */
- && !UNDEFWEAK_NO_DYNAMIC_RELOC (info, h))
+ && !UNDEFWEAK_NO_DYNAMIC_RELOC (info, h)
+ && !local_undefweak)
{
Elf_Internal_Rela rela;
bfd_byte *loc;
@@ -9650,6 +9703,9 @@
#define elf_backend_init_index_section \
_bfd_elf_init_2_index_sections
+#define elf_backend_fixup_symbol \
+ elfNN_aarch64_elf_fixup_symbol
+
#define elf_backend_finish_dynamic_sections \
elfNN_aarch64_finish_dynamic_sections
diff -NBaur binutils-2.31.1/ld/emulparams/aarch64elf32.sh binutils-2.31.1-dka64/ld/emulparams/aarch64elf32.sh
--- binutils-2.31.1/ld/emulparams/aarch64elf32.sh 2018-06-24 19:38:57.000000000 +0100
+++ binutils-2.31.1-dka64/ld/emulparams/aarch64elf32.sh 2018-07-27 18:04:52.585317513 +0100
@@ -1,3 +1,5 @@
+. ${srcdir}/emulparams/dynamic_undefined_weak.sh
+
ARCH="aarch64:ilp32"
MACHINE=
NOP=0x1f2003d5
diff -NBaur binutils-2.31.1/ld/emulparams/aarch64elf.sh binutils-2.31.1-dka64/ld/emulparams/aarch64elf.sh
--- binutils-2.31.1/ld/emulparams/aarch64elf.sh 2018-06-24 19:38:57.000000000 +0100
+++ binutils-2.31.1-dka64/ld/emulparams/aarch64elf.sh 2018-07-27 18:04:52.585317513 +0100
@@ -1,3 +1,5 @@
+. ${srcdir}/emulparams/dynamic_undefined_weak.sh
+
ARCH=aarch64
MACHINE=
NOP=0x1f2003d5
diff -NBaur binutils-2.31.1/ld/emultempl/aarch64elf.em binutils-2.31.1-dka64/ld/emultempl/aarch64elf.em
--- binutils-2.31.1/ld/emultempl/aarch64elf.em 2018-06-26 12:27:20.000000000 +0100
+++ binutils-2.31.1-dka64/ld/emultempl/aarch64elf.em 2018-07-27 18:04:52.585317513 +0100
@@ -380,7 +380,7 @@
{ "no-apply-dynamic-relocs", no_argument, NULL, OPTION_NO_APPLY_DYNAMIC_RELOCS},
'
-PARSE_AND_LIST_OPTIONS='
+PARSE_AND_LIST_OPTIONS=${PARSE_AND_LIST_OPTIONS}'
fprintf (file, _(" --no-enum-size-warning Don'\''t warn about objects with incompatible\n"
" enum sizes\n"));
fprintf (file, _(" --no-wchar-size-warning Don'\''t warn about objects with incompatible\n"
diff -NBaur binutils-2.31.1/ld/Makefile.am binutils-2.31.1-dka64/ld/Makefile.am
--- binutils-2.31.1/ld/Makefile.am 2018-06-24 19:38:57.000000000 +0100
+++ binutils-2.31.1-dka64/ld/Makefile.am 2018-07-27 18:04:52.585317513 +0100
@@ -1495,19 +1495,23 @@
$(srcdir)/scripttempl/aout.sc ${GEN_DEPENDS}
eaarch64elf.c: $(srcdir)/emulparams/aarch64elf.sh \
- $(ELF_DEPS) $(srcdir)/emultempl/aarch64elf.em \
+ $(srcdir)/emulparams/dynamic_undefined_weak.sh \
+ $(ELF_DEPS) $(srcdir)/emultempl/aarch64elf.em ldemul-list.h \
$(srcdir)/scripttempl/elf.sc ${GEN_DEPENDS}
eaarch64elf32.c: $(srcdir)/emulparams/aarch64elf32.sh \
- $(ELF_DEPS) $(srcdir)/emultempl/aarch64elf.em \
+ $(srcdir)/emulparams/dynamic_undefined_weak.sh \
+ $(ELF_DEPS) $(srcdir)/emultempl/aarch64elf.em ldemul-list.h \
$(srcdir)/scripttempl/elf.sc ${GEN_DEPENDS}
eaarch64elfb.c: $(srcdir)/emulparams/aarch64elfb.sh $(srcdir)/emulparams/aarch64elf.sh \
- $(ELF_DEPS) $(srcdir)/emultempl/aarch64elf.em \
+ $(srcdir)/emulparams/dynamic_undefined_weak.sh \
+ $(ELF_DEPS) $(srcdir)/emultempl/aarch64elf.em ldemul-list.h \
$(srcdir)/scripttempl/elf.sc ${GEN_DEPENDS}
eaarch64elf32b.c: $(srcdir)/emulparams/aarch64elf32b.sh $(srcdir)/emulparams/aarch64elf32.sh \
- $(ELF_DEPS) $(srcdir)/emultempl/aarch64elf.em \
+ $(srcdir)/emulparams/dynamic_undefined_weak.sh \
+ $(ELF_DEPS) $(srcdir)/emultempl/aarch64elf.em ldemul-list.h \
$(srcdir)/scripttempl/elf.sc ${GEN_DEPENDS}
eaarch64cloudabi.c: $(srcdir)/emulparams/aarch64cloudabi.sh \
diff -NBaur binutils-2.31.1/ld/Makefile.in binutils-2.31.1-dka64/ld/Makefile.in
--- binutils-2.31.1/ld/Makefile.in 2018-07-18 08:46:21.000000000 +0100
+++ binutils-2.31.1-dka64/ld/Makefile.in 2018-07-27 18:04:52.585317513 +0100
@@ -3097,18 +3097,22 @@
eaarch64elf.c: $(srcdir)/emulparams/aarch64elf.sh \
$(ELF_DEPS) $(srcdir)/emultempl/aarch64elf.em \
+ $(srcdir)/emulparams/dynamic_undefined_weak.sh \
$(srcdir)/scripttempl/elf.sc ${GEN_DEPENDS}
eaarch64elf32.c: $(srcdir)/emulparams/aarch64elf32.sh \
$(ELF_DEPS) $(srcdir)/emultempl/aarch64elf.em \
+ $(srcdir)/emulparams/dynamic_undefined_weak.sh \
$(srcdir)/scripttempl/elf.sc ${GEN_DEPENDS}
eaarch64elfb.c: $(srcdir)/emulparams/aarch64elfb.sh $(srcdir)/emulparams/aarch64elf.sh \
$(ELF_DEPS) $(srcdir)/emultempl/aarch64elf.em \
+ $(srcdir)/emulparams/dynamic_undefined_weak.sh \
$(srcdir)/scripttempl/elf.sc ${GEN_DEPENDS}
eaarch64elf32b.c: $(srcdir)/emulparams/aarch64elf32b.sh $(srcdir)/emulparams/aarch64elf32.sh \
$(ELF_DEPS) $(srcdir)/emultempl/aarch64elf.em \
+ $(srcdir)/emulparams/dynamic_undefined_weak.sh \
$(srcdir)/scripttempl/elf.sc ${GEN_DEPENDS}
eaarch64cloudabi.c: $(srcdir)/emulparams/aarch64cloudabi.sh \

View File

@ -1,3 +1,41 @@
diff --git a/bfd/elf-bfd.h b/bfd/elf-bfd.h
index 5741c60264..fb5d9d069c 100644
--- a/bfd/elf-bfd.h
+++ b/bfd/elf-bfd.h
@@ -1789,6 +1789,14 @@ struct output_elf_obj_tdata
asection *sec;
} build_id;
+ /* Data for .nx-module-name. */
+ struct
+ {
+ bfd_boolean (*after_write_object_contents) (bfd *);
+ const char *name;
+ asection *sec;
+ } nx_module_name;
+
/* Records the result of `get_program_header_size'. */
bfd_size_type program_header_size;
diff --git a/bfd/elf.c b/bfd/elf.c
index eb3e1828e9..bc6bb48804 100644
--- a/bfd/elf.c
+++ b/bfd/elf.c
@@ -6514,6 +6514,14 @@ _bfd_elf_write_object_contents (bfd *abfd)
if (!bed->s->write_shdrs_and_ehdr (abfd))
return FALSE;
+ /* Write out the NX module name. */
+ if (t->o->nx_module_name.after_write_object_contents != NULL)
+ {
+ failed = !(*t->o->nx_module_name.after_write_object_contents) (abfd);
+ if (failed)
+ return FALSE;
+ }
+
/* This is last since write_shdrs_and_ehdr can touch i_shdrp[0]. */
if (t->o->build_id.after_write_object_contents != NULL)
return (*t->o->build_id.after_write_object_contents) (abfd);
diff --git a/bfd/elfnn-aarch64.c b/bfd/elfnn-aarch64.c
index faa27611d4..888af6bcd8 100644
--- a/bfd/elfnn-aarch64.c
@ -350,3 +388,217 @@ index 45e40b510c..916ef2086a 100644
fprintf (file, _(" --no-enum-size-warning Don'\''t warn about objects with incompatible\n"
" enum sizes\n"));
fprintf (file, _(" --no-wchar-size-warning Don'\''t warn about objects with incompatible\n"
diff --git a/ld/emultempl/elf32.em b/ld/emultempl/elf32.em
index f4f7ad6b4e..8428a54697 100644
--- a/ld/emultempl/elf32.em
+++ b/ld/emultempl/elf32.em
@@ -192,6 +192,9 @@ static char *depaudit; /* colon (typically) separated list of libs */
/* Style of .note.gnu.build-id section. */
static const char *emit_note_gnu_build_id;
+/* NX module name. */
+static const char *emit_nx_module_name;
+
/* On Linux, it's possible to have different versions of the same
shared library linked against different versions of libc. The
dynamic linker somehow tags which libc version to use in
@@ -1217,6 +1220,92 @@ setup_build_id (bfd *ibfd)
return FALSE;
}
+static bfd_boolean
+write_nx_module_name (bfd *abfd)
+{
+ struct elf_obj_tdata *t = elf_tdata (abfd);
+ const char *name;
+ asection *asec;
+ Elf_Internal_Shdr *i_shdr;
+ unsigned char *contents;
+ bfd_size_type size;
+ file_ptr position;
+
+ name = t->o->nx_module_name.name;
+ asec = t->o->nx_module_name.sec;
+ if (bfd_is_abs_section (asec->output_section))
+ {
+ einfo (_("%P: warning: .nx-module-name section discarded,"
+ " --build-id ignored\n"));
+ return TRUE;
+ }
+ i_shdr = &elf_section_data (asec->output_section)->this_hdr;
+
+ if (i_shdr->contents == NULL)
+ {
+ if (asec->contents == NULL)
+ asec->contents = (unsigned char *) xmalloc (asec->size);
+ contents = asec->contents;
+ }
+ else
+ contents = i_shdr->contents + asec->output_offset;
+
+ size = asec->size;
+ bfd_h_put_32 (abfd, 0, &contents[0]);
+ bfd_h_put_32 (abfd, size - 9, &contents[4]);
+ memcpy (&contents[8], name, size - 9);
+ contents[size - 1] = 0; /* ensure null termination for AMS */
+
+ position = i_shdr->sh_offset + asec->output_offset;
+
+ return (bfd_seek (abfd, position, SEEK_SET) == 0
+ && bfd_bwrite (contents, size, abfd) == size);
+}
+
+/* Make .nx-module-name section, and set up elf_tdata->nx_module_name. */
+
+static bfd_boolean
+setup_nx_module_name (bfd *ibfd, bfd *obfd)
+{
+ asection *s;
+ bfd_size_type size;
+ flagword flags;
+
+ if (emit_nx_module_name[0] == '\0')
+ {
+ /* Extract the basename of the output bfd and use it as the module name. */
+ char *dot_pos;
+ free ((char *) emit_nx_module_name);
+ emit_nx_module_name = (char *) lbasename (bfd_get_filename (obfd));
+ emit_nx_module_name = xstrdup (emit_nx_module_name);
+ dot_pos = strrchr (emit_nx_module_name, '.');
+ if (dot_pos != NULL)
+ {
+ /* Remove extension. */
+ *dot_pos = 0;
+ }
+ }
+
+ size = 8 + strlen(emit_nx_module_name) + 1; /* extra null terminator for AMS */
+ flags = (SEC_ALLOC | SEC_LOAD | SEC_IN_MEMORY
+ | SEC_LINKER_CREATED | SEC_READONLY | SEC_DATA);
+ s = bfd_make_section_with_flags (ibfd, ".nx-module-name", flags);
+ if (s != NULL && bfd_set_section_alignment (ibfd, s, 4))
+ {
+ struct elf_obj_tdata *t = elf_tdata (link_info.output_bfd);
+ t->o->nx_module_name.after_write_object_contents = &write_nx_module_name;
+ t->o->nx_module_name.name = emit_nx_module_name;
+ t->o->nx_module_name.sec = s;
+ elf_section_type (s) = SHT_PROGBITS;
+ s->size = size;
+ return TRUE;
+ }
+
+ einfo (_("%P: warning: cannot create .nx-module-name section,"
+ " --nx-module-name ignored\n"));
+ return FALSE;
+}
+
/* This is called after all the input files have been opened. */
static void
@@ -1267,6 +1356,24 @@ gld${EMULATION_NAME}_after_open (void)
}
}
+ if (emit_nx_module_name != NULL)
+ {
+ /* Find an ELF input. */
+ for (abfd = link_info.input_bfds;
+ abfd != (bfd *) NULL; abfd = abfd->link.next)
+ if (bfd_get_flavour (abfd) == bfd_target_elf_flavour
+ && bfd_count_sections (abfd) != 0
+ && !((lang_input_statement_type *) abfd->usrdata)->flags.just_syms)
+ break;
+
+ /* If there are no ELF input files do not try to create a .nx-module-name section. */
+ if (abfd == NULL || !setup_nx_module_name (abfd, link_info.output_bfd))
+ {
+ free ((char *) emit_nx_module_name);
+ emit_nx_module_name = NULL;
+ }
+ }
+
get_elf_backend_data (link_info.output_bfd)->setup_gnu_properties (&link_info);
if (bfd_link_relocatable (&link_info))
@@ -2720,6 +2827,7 @@ enum elf_options
OPTION_EXCLUDE_LIBS,
OPTION_HASH_STYLE,
OPTION_BUILD_ID,
+ OPTION_NX_MODULE_NAME,
OPTION_AUDIT,
OPTION_COMPRESS_DEBUG
};
@@ -2750,6 +2858,7 @@ EOF
fi
fragment <<EOF
{"build-id", optional_argument, NULL, OPTION_BUILD_ID},
+ {"nx-module-name", optional_argument, NULL, OPTION_NX_MODULE_NAME},
{"compress-debug-sections", required_argument, NULL, OPTION_COMPRESS_DEBUG},
EOF
if test x"$GENERATE_SHLIB_SCRIPT" = xyes; then
@@ -2814,6 +2923,16 @@ gld${EMULATION_NAME}_handle_option (int optc)
einfo (_("%F%P: invalid --compress-debug-sections option: \`%s'\n"),
optarg);
break;
+ case OPTION_NX_MODULE_NAME:
+ if (emit_nx_module_name != NULL)
+ {
+ free ((char *) emit_nx_module_name);
+ emit_nx_module_name = NULL;
+ }
+ if (optarg == NULL)
+ optarg = "";
+ emit_nx_module_name = xstrdup (optarg);
+ break;
EOF
if test x"$GENERATE_SHLIB_SCRIPT" = xyes; then
diff --git a/ld/ldgram.y b/ld/ldgram.y
index c3eadeb392..59ab143526 100644
--- a/ld/ldgram.y
+++ b/ld/ldgram.y
@@ -819,6 +819,7 @@ origin_spec:
ORIGIN '=' mustbe_exp
{
region->origin_exp = $3;
+ region->current = region->origin;
}
;
diff --git a/ld/ldlang.c b/ld/ldlang.c
index 33f6bda292..7161f4210a 100644
--- a/ld/ldlang.c
+++ b/ld/ldlang.c
@@ -7381,9 +7381,6 @@ lang_process (void)
current_target = default_target;
lang_statement_iteration++;
open_input_bfds (statement_list.head, OPEN_BFD_NORMAL);
- /* open_input_bfds also handles assignments, so we can give values
- to symbolic origin/length now. */
- lang_do_memory_regions ();
#ifdef ENABLE_PLUGINS
if (link_info.lto_plugin_active)
@@ -7526,6 +7523,8 @@ lang_process (void)
/* PR 13683: We must rerun the assignments prior to running garbage
collection in order to make sure that all symbol aliases are resolved. */
lang_do_assignments (lang_mark_phase_enum);
+
+ lang_do_memory_regions();
expld.phase = lang_first_phase_enum;
/* Size up the common data. */
@@ -7610,11 +7609,8 @@ lang_process (void)
/* Fix any __start, __stop, .startof. or .sizeof. symbols. */
lang_finalize_start_stop ();
- /* Do all the assignments again, to report errors. Assignment
- statements are processed multiple times, updating symbols; In
- open_input_bfds, lang_do_assignments, and lang_size_sections.
- Since lang_relax_sections calls lang_do_assignments, symbols are
- also updated in ldemul_after_allocation. */
+ /* Do all the assignments, now that we know the final resting places
+ of all the symbols. */
lang_do_assignments (lang_final_phase_enum);
ldemul_finish ();