11diff --git a/bfd/elf-bfd.h b/bfd/elf-bfd.h
2- index b89d3dda05d..1ad8a9c088d 100644
2+ index c89327fdc9c..b46689a21c1 100644
33--- a/bfd/elf-bfd.h
44+++ b/bfd/elf-bfd.h
5- @@ -2005 ,6 +2005 ,14 @@ struct output_elf_obj_tdata
5+ @@ -2008 ,6 +2008 ,14 @@ struct output_elf_obj_tdata
66 asection *sec;
77 } package_metadata;
88
@@ -18,10 +18,10 @@ index b89d3dda05d..1ad8a9c088d 100644
1818 bfd_size_type program_header_size;
1919
2020diff --git a/bfd/elf.c b/bfd/elf.c
21- index f85f79e1e35..d27f05b92ae 100644
21+ index 1f2b82bfe92..7e9964a15f4 100644
2222--- a/bfd/elf.c
2323+++ b/bfd/elf.c
24- @@ -7166 ,6 +7166 ,14 @@ _bfd_elf_write_object_contents (bfd *abfd)
24+ @@ -7189 ,6 +7189 ,14 @@ _bfd_elf_write_object_contents (bfd *abfd)
2525 if (!bed->s->write_shdrs_and_ehdr (abfd))
2626 return false;
2727
@@ -37,7 +37,7 @@ index f85f79e1e35..d27f05b92ae 100644
3737 if (t->o->build_id.after_write_object_contents != NULL
3838 && !(*t->o->build_id.after_write_object_contents) (abfd))
3939diff --git a/bfd/elfnn-aarch64.c b/bfd/elfnn-aarch64.c
40- index 94c9a01069b..d39880b27c4 100644
40+ index 65182f49070..3ba294ad940 100644
4141--- a/bfd/elfnn-aarch64.c
4242+++ b/bfd/elfnn-aarch64.c
4343@@ -2441,6 +2441,12 @@ enum elf_aarch64_stub_type
@@ -53,7 +53,7 @@ index 94c9a01069b..d39880b27c4 100644
5353 struct elf_aarch64_stub_hash_entry
5454 {
5555 /* Base hash table entry structure. */
56- @@ -6969 ,11 +6975 ,13 @@ elfNN_aarch64_relocate_section (bfd *output_bfd,
56+ @@ -6977 ,11 +6983 ,13 @@ elfNN_aarch64_relocate_section (bfd *output_bfd,
5757 Elf_Internal_Sym *sym;
5858 asection *sec;
5959 struct elf_link_hash_entry *h;
@@ -67,7 +67,7 @@ index 94c9a01069b..d39880b27c4 100644
6767 char *error_message = NULL;
6868
6969 r_symndx = ELFNN_R_SYM (rel->r_info);
70- @@ -7113 ,6 +7121 ,10 @@ elfNN_aarch64_relocate_section (bfd *output_bfd,
70+ @@ -7121 ,6 +7129 ,10 @@ elfNN_aarch64_relocate_section (bfd *output_bfd,
7171 h, &unresolved_reloc,
7272 save_addend, &addend, sym);
7373
@@ -78,7 +78,7 @@ index 94c9a01069b..d39880b27c4 100644
7878 switch (elfNN_aarch64_bfd_reloc_from_type (input_bfd, r_type))
7979 {
8080 case BFD_RELOC_AARCH64_TLSGD_ADD_LO12_NC:
81- @@ -7136 ,7 +7148 ,7 @@ elfNN_aarch64_relocate_section (bfd *output_bfd,
81+ @@ -7144 ,7 +7156 ,7 @@ elfNN_aarch64_relocate_section (bfd *output_bfd,
8282 need_relocs =
8383 (!bfd_link_executable (info) || indx != 0) &&
8484 (h == NULL
@@ -87,7 +87,7 @@ index 94c9a01069b..d39880b27c4 100644
8787 || h->root.type != bfd_link_hash_undefweak);
8888
8989 BFD_ASSERT (globals->root.srelgot != NULL);
90- @@ -7231 ,7 +7243 ,7 @@ elfNN_aarch64_relocate_section (bfd *output_bfd,
90+ @@ -7239 ,7 +7251 ,7 @@ elfNN_aarch64_relocate_section (bfd *output_bfd,
9191 need_relocs =
9292 (!bfd_link_executable (info) || indx != 0) &&
9393 (h == NULL
@@ -96,7 +96,7 @@ index 94c9a01069b..d39880b27c4 100644
9696 || h->root.type != bfd_link_hash_undefweak);
9797
9898 BFD_ASSERT (globals->root.srelgot != NULL);
99- @@ -7280 ,7 +7292 ,7 @@ elfNN_aarch64_relocate_section (bfd *output_bfd,
99+ @@ -7288 ,7 +7300 ,7 @@ elfNN_aarch64_relocate_section (bfd *output_bfd,
100100 bfd_vma off = symbol_tlsdesc_got_offset (input_bfd, h, r_symndx);
101101
102102 need_relocs = (h == NULL
@@ -105,7 +105,7 @@ index 94c9a01069b..d39880b27c4 100644
105105 || h->root.type != bfd_link_hash_undefweak);
106106
107107 BFD_ASSERT (globals->root.srelgot != NULL);
108- @@ -7606 ,6 +7618 ,23 @@ need_copy_relocation_p (struct elf_aarch64_link_hash_entry *eh)
108+ @@ -7614 ,6 +7626 ,23 @@ need_copy_relocation_p (struct elf_aarch64_link_hash_entry *eh)
109109 return false;
110110 }
111111
@@ -129,15 +129,15 @@ index 94c9a01069b..d39880b27c4 100644
129129 /* Adjust a symbol defined by a dynamic object and referenced by a
130130 regular object. The current definition is in some section of the
131131 dynamic object, but we're not including those sections. We have to
132- @@ -8824 ,6 +8853 ,7 @@ elfNN_aarch64_allocate_dynrelocs (struct elf_link_hash_entry *h, void *inf)
132+ @@ -8720 ,6 +8749 ,7 @@ elfNN_aarch64_allocate_dynrelocs (struct elf_link_hash_entry *h, void *inf)
133133 struct elf_aarch64_link_hash_table *htab;
134134 struct elf_aarch64_link_hash_entry *eh;
135135 struct elf_dyn_relocs *p;
136136+ bool resolved_to_zero;
137137
138138 /* An example of a bfd_link_hash_indirect symbol is versioned
139139 symbol. For example: __gxx_personality_v0(bfd_link_hash_indirect)
140- @@ -8843 ,6 +8873 ,10 @@ elfNN_aarch64_allocate_dynrelocs (struct elf_link_hash_entry *h, void *inf)
140+ @@ -8739 ,6 +8769 ,10 @@ elfNN_aarch64_allocate_dynrelocs (struct elf_link_hash_entry *h, void *inf)
141141 info = (struct bfd_link_info *) inf;
142142 htab = elf_aarch64_hash_table (info);
143143
@@ -148,7 +148,7 @@ index 94c9a01069b..d39880b27c4 100644
148148 /* Since STT_GNU_IFUNC symbol must go through PLT, we handle it
149149 here if it is defined and referenced in a non-shared object. */
150150 if (h->type == STT_GNU_IFUNC
151- @@ -8852 ,7 +8886 ,7 @@ elfNN_aarch64_allocate_dynrelocs (struct elf_link_hash_entry *h, void *inf)
151+ @@ -8748 ,7 +8782 ,7 @@ elfNN_aarch64_allocate_dynrelocs (struct elf_link_hash_entry *h, void *inf)
152152 {
153153 /* Make sure this symbol is output as a dynamic symbol.
154154 Undefined weak syms won't yet be marked as dynamic. */
@@ -157,7 +157,7 @@ index 94c9a01069b..d39880b27c4 100644
157157 && h->root.type == bfd_link_hash_undefweak)
158158 {
159159 if (!bfd_elf_link_record_dynamic_symbol (info, h))
160- @@ -8886 ,6 +8920 ,11 @@ elfNN_aarch64_allocate_dynrelocs (struct elf_link_hash_entry *h, void *inf)
160+ @@ -8782 ,6 +8816 ,11 @@ elfNN_aarch64_allocate_dynrelocs (struct elf_link_hash_entry *h, void *inf)
161161 of relaxing into these from the large model PLT entries. */
162162 s->size += htab->plt_entry_size;
163163
@@ -169,15 +169,15 @@ index 94c9a01069b..d39880b27c4 100644
169169 /* We also need to make an entry in the .got.plt section, which
170170 will be placed in the .got section by the linker script. */
171171 htab->root.sgotplt->size += GOT_ENTRY_SIZE;
172- @@ -8914 ,6 +8953 ,7 @@ elfNN_aarch64_allocate_dynrelocs (struct elf_link_hash_entry *h, void *inf)
172+ @@ -8810 ,6 +8849 ,7 @@ elfNN_aarch64_allocate_dynrelocs (struct elf_link_hash_entry *h, void *inf)
173173 htab->variant_pcs = 1;
174174
175175 }
176176+ }
177177 else
178178 {
179179 h->plt.offset = (bfd_vma) - 1;
180- @@ -8926 ,9 +8966 ,6 @@ elfNN_aarch64_allocate_dynrelocs (struct elf_link_hash_entry *h, void *inf)
180+ @@ -8822 ,9 +8862 ,6 @@ elfNN_aarch64_allocate_dynrelocs (struct elf_link_hash_entry *h, void *inf)
181181 h->needs_plt = 0;
182182 }
183183
@@ -187,7 +187,7 @@ index 94c9a01069b..d39880b27c4 100644
187187 if (h->got.refcount > 0)
188188 {
189189 bool dyn;
190- @@ -8940 ,7 +8977 ,7 @@ elfNN_aarch64_allocate_dynrelocs (struct elf_link_hash_entry *h, void *inf)
190+ @@ -8836 ,7 +8873 ,7 @@ elfNN_aarch64_allocate_dynrelocs (struct elf_link_hash_entry *h, void *inf)
191191
192192 /* Make sure this symbol is output as a dynamic symbol.
193193 Undefined weak syms won't yet be marked as dynamic. */
@@ -196,7 +196,7 @@ index 94c9a01069b..d39880b27c4 100644
196196 && h->root.type == bfd_link_hash_undefweak)
197197 {
198198 if (!bfd_elf_link_record_dynamic_symbol (info, h))
199- @@ -8954 ,7 +8991 ,7 @@ elfNN_aarch64_allocate_dynrelocs (struct elf_link_hash_entry *h, void *inf)
199+ @@ -8850 ,7 +8887 ,7 @@ elfNN_aarch64_allocate_dynrelocs (struct elf_link_hash_entry *h, void *inf)
200200 {
201201 h->got.offset = htab->root.sgot->size;
202202 htab->root.sgot->size += GOT_ENTRY_SIZE;
@@ -205,7 +205,7 @@ index 94c9a01069b..d39880b27c4 100644
205205 || h->root.type != bfd_link_hash_undefweak)
206206 && (bfd_link_pic (info)
207207 || WILL_CALL_FINISH_DYNAMIC_SYMBOL (dyn, 0, h))
208- @@ -8990 ,7 +9027 ,7 @@ elfNN_aarch64_allocate_dynrelocs (struct elf_link_hash_entry *h, void *inf)
208+ @@ -8886 ,7 +8923 ,7 @@ elfNN_aarch64_allocate_dynrelocs (struct elf_link_hash_entry *h, void *inf)
209209 }
210210
211211 indx = h && h->dynindx != -1 ? h->dynindx : 0;
@@ -214,7 +214,7 @@ index 94c9a01069b..d39880b27c4 100644
214214 || h->root.type != bfd_link_hash_undefweak)
215215 && (!bfd_link_executable (info)
216216 || indx != 0
217- @@ -9072 ,7 +9109 ,7 @@ elfNN_aarch64_allocate_dynrelocs (struct elf_link_hash_entry *h, void *inf)
217+ @@ -8968 ,7 +9005 ,7 @@ elfNN_aarch64_allocate_dynrelocs (struct elf_link_hash_entry *h, void *inf)
218218 visibility. */
219219 if (h->dyn_relocs != NULL && h->root.type == bfd_link_hash_undefweak)
220220 {
@@ -223,7 +223,7 @@ index 94c9a01069b..d39880b27c4 100644
223223 || UNDEFWEAK_NO_DYNAMIC_RELOC (info, h))
224224 h->dyn_relocs = NULL;
225225
226- @@ -9092 ,7 +9129 ,9 @@ elfNN_aarch64_allocate_dynrelocs (struct elf_link_hash_entry *h, void *inf)
226+ @@ -8988 ,7 +9025 ,9 @@ elfNN_aarch64_allocate_dynrelocs (struct elf_link_hash_entry *h, void *inf)
227227 symbols which turn out to need copy relocs or are not
228228 dynamic. */
229229
@@ -234,15 +234,15 @@ index 94c9a01069b..d39880b27c4 100644
234234 && ((h->def_dynamic
235235 && !h->def_regular)
236236 || (htab->root.dynamic_sections_created
237- @@ -9103 ,6 +9142 ,7 @@ elfNN_aarch64_allocate_dynrelocs (struct elf_link_hash_entry *h, void *inf)
237+ @@ -8999 ,6 +9038 ,7 @@ elfNN_aarch64_allocate_dynrelocs (struct elf_link_hash_entry *h, void *inf)
238238 Undefined weak syms won't yet be marked as dynamic. */
239239 if (h->dynindx == -1
240240 && !h->forced_local
241241+ && !resolved_to_zero
242242 && h->root.type == bfd_link_hash_undefweak
243243 && !bfd_elf_link_record_dynamic_symbol (info, h))
244244 return false;
245- @@ -10058 ,8 +10098 ,17 @@ elfNN_aarch64_finish_dynamic_symbol (bfd *output_bfd,
245+ @@ -9954 ,8 +9994 ,17 @@ elfNN_aarch64_finish_dynamic_symbol (bfd *output_bfd,
246246 Elf_Internal_Sym *sym)
247247 {
248248 struct elf_aarch64_link_hash_table *htab;
@@ -260,7 +260,7 @@ index 94c9a01069b..d39880b27c4 100644
260260 if (h->plt.offset != (bfd_vma) - 1)
261261 {
262262 asection *plt, *gotplt, *relplt;
263- @@ -10094 ,7 +10143 ,7 @@ elfNN_aarch64_finish_dynamic_symbol (bfd *output_bfd,
263+ @@ -9990 ,7 +10039 ,7 @@ elfNN_aarch64_finish_dynamic_symbol (bfd *output_bfd,
264264 abort ();
265265
266266 elfNN_aarch64_create_small_pltn_entry (h, htab, output_bfd, info);
@@ -269,7 +269,7 @@ index 94c9a01069b..d39880b27c4 100644
269269 {
270270 /* Mark the symbol as undefined, rather than as defined in
271271 the .plt section. */
272- @@ -10116 ,7 +10165 ,8 @@ elfNN_aarch64_finish_dynamic_symbol (bfd *output_bfd,
272+ @@ -10012 ,7 +10061 ,8 @@ elfNN_aarch64_finish_dynamic_symbol (bfd *output_bfd,
273273 && elf_aarch64_hash_entry (h)->got_type == GOT_NORMAL
274274 /* Undefined weak symbol in static PIE resolves to 0 without
275275 any dynamic relocations. */
@@ -279,7 +279,7 @@ index 94c9a01069b..d39880b27c4 100644
279279 {
280280 Elf_Internal_Rela rela;
281281 bfd_byte *loc;
282- @@ -10766 ,6 +10816 ,9 @@ const struct elf_size_info elfNN_aarch64_size_info =
282+ @@ -10680 ,6 +10730 ,9 @@ const struct elf_size_info elfNN_aarch64_size_info =
283283 #define elf_backend_init_index_section \
284284 _bfd_elf_init_2_index_sections
285285
@@ -310,10 +310,10 @@ index 45bf31a179a..02e0cad8699 100644
310310 ARCH="aarch64:ilp32"
311311 MACHINE=
312312diff --git a/ld/emultempl/aarch64elf.em b/ld/emultempl/aarch64elf.em
313- index aa2859d4f73..c680dca8f86 100644
313+ index 7791aabf16d..a1486617099 100644
314314--- a/ld/emultempl/aarch64elf.em
315315+++ b/ld/emultempl/aarch64elf.em
316- @@ -368 ,7 +368 ,7 @@ PARSE_AND_LIST_LONGOPTS='
316+ @@ -458 ,7 +458 ,7 @@ PARSE_AND_LIST_LONGOPTS='
317317 { "no-apply-dynamic-relocs", no_argument, NULL, OPTION_NO_APPLY_DYNAMIC_RELOCS},
318318 '
319319
@@ -323,18 +323,18 @@ index aa2859d4f73..c680dca8f86 100644
323323 " enum sizes\n"));
324324 fprintf (file, _(" --no-wchar-size-warning Don'\''t warn about objects with incompatible\n"
325325diff --git a/ld/emultempl/elf.em b/ld/emultempl/elf.em
326- index 863657e12f5..672974df511 100644
326+ index 777f7204038..895f9ce59e6 100644
327327--- a/ld/emultempl/elf.em
328328+++ b/ld/emultempl/elf.em
329- @@ -813 ,6 +813 ,7 @@ EOF
329+ @@ -814 ,6 +814 ,7 @@ EOF
330330 fi
331331 fragment <<EOF
332332 {"build-id", optional_argument, NULL, OPTION_BUILD_ID},
333333+ {"nx-module-name", optional_argument, NULL, OPTION_NX_MODULE_NAME},
334334 {"package-metadata", optional_argument, NULL, OPTION_PACKAGE_METADATA},
335335 {"compress-debug-sections", required_argument, NULL, OPTION_COMPRESS_DEBUG},
336336 {"rosegment", no_argument, NULL, OPTION_ROSEGMENT},
337- @@ -892 ,6 +893 ,18 @@ gld${EMULATION_NAME}_handle_option (int optc)
337+ @@ -901 ,6 +902 ,18 @@ gld${EMULATION_NAME}_handle_option (int optc)
338338 case OPTION_NO_ROSEGMENT:
339339 link_info.one_rosegment = false;
340340 break;
@@ -354,7 +354,7 @@ index 863657e12f5..672974df511 100644
354354
355355 if test x"$GENERATE_SHLIB_SCRIPT" = xyes; then
356356diff --git a/ld/ldelf.c b/ld/ldelf.c
357- index 09691609fc0..5769b4aa0f9 100644
357+ index 4a1aa044e70..24025b0c5a6 100644
358358--- a/ld/ldelf.c
359359+++ b/ld/ldelf.c
360360@@ -55,6 +55,9 @@ const char *ldelf_emit_note_gnu_build_id;
@@ -367,7 +367,7 @@ index 09691609fc0..5769b4aa0f9 100644
367367 /* These variables are required to pass information back and forth
368368 between after_open and check_needed and stat_needed and vercheck. */
369369
370- @@ -1209 ,8 +1212 ,93 @@ ldelf_handle_dt_needed (struct elf_link_hash_table *htab,
370+ @@ -1213 ,8 +1216 ,93 @@ ldelf_handle_dt_needed (struct elf_link_hash_table *htab,
371371 *save_input_bfd_tail = NULL;
372372 }
373373
@@ -382,7 +382,7 @@ index 09691609fc0..5769b4aa0f9 100644
382382+ unsigned char *contents;
383383+ bfd_size_type size;
384384+ file_ptr position;
385-
385+ +
386386+ name = t->o->nx_module_name.name;
387387+ asec = t->o->nx_module_name.sec;
388388+ if (bfd_is_abs_section (asec->output_section))
@@ -413,7 +413,7 @@ index 09691609fc0..5769b4aa0f9 100644
413413+ return (bfd_seek (abfd, position, SEEK_SET) == 0
414414+ && bfd_write (contents, size, abfd) == size);
415415+ }
416- +
416+
417417+ /* Make .nx-module-name section, and set up elf_tdata->nx_module_name. */
418418+
419419+ static bool
@@ -462,7 +462,7 @@ index 09691609fc0..5769b4aa0f9 100644
462462 void
463463 ldelf_before_plugin_all_symbols_read (int use_libpath, int native,
464464 int is_linux, int is_freebsd,
465- @@ -1289 ,6 +1377 ,24 @@ ldelf_after_open (int use_libpath, int native, int is_linux, int is_freebsd,
465+ @@ -1293 ,6 +1381 ,24 @@ ldelf_after_open (int use_libpath, int native, int is_linux, int is_freebsd,
466466 }
467467 }
468468
@@ -488,7 +488,7 @@ index 09691609fc0..5769b4aa0f9 100644
488488
489489 /* Do not allow executable files to be used as inputs to the link. */
490490diff --git a/ld/ldelf.h b/ld/ldelf.h
491- index 239194772c4..68516dbf45e 100644
491+ index a6498cf2758..b69da549175 100644
492492--- a/ld/ldelf.h
493493+++ b/ld/ldelf.h
494494@@ -20,6 +20,7 @@
@@ -497,13 +497,13 @@ index 239194772c4..68516dbf45e 100644
497497 extern const char *ldelf_emit_note_fdo_package_metadata;
498498+ extern const char *ldelf_emit_nx_module_name;
499499
500+ extern void ldelf_finish (void);
500501 extern void ldelf_after_parse (void);
501- extern bool ldelf_load_symbols (lang_input_statement_type *);
502502diff --git a/ld/ldlex.h b/ld/ldlex.h
503- index defe3fcbbb9..30f31df990e 100644
503+ index b8b7d6b6829..3c9ee8d8742 100644
504504--- a/ld/ldlex.h
505505+++ b/ld/ldlex.h
506- @@ -186 ,6 +186 ,7 @@ enum option_values
506+ @@ -187 ,6 +187 ,7 @@ enum option_values
507507 /* Used by emultempl/elf.em, emultempl/pe.em and emultempl/pep.em. */
508508 OPTION_BUILD_ID,
509509 OPTION_EXCLUDE_LIBS,
0 commit comments