diff options
author | Jeremy Drake <sourceware-bugzilla@jdrake.com> | 2020-08-27 12:58:27 +0100 |
---|---|---|
committer | Nick Clifton <nickc@redhat.com> | 2020-08-27 12:58:27 +0100 |
commit | 514b4e191d5f46de8e142fe216e677a35fa9c4bb (patch) | |
tree | f4173c8f49e5987adc1cd1dd4c515c9493bbe268 /ld/pe-dll.c | |
parent | f2e5245f4169c2a1849ba998872e245c1b303950 (diff) | |
download | gdb-514b4e191d5f46de8e142fe216e677a35fa9c4bb.zip gdb-514b4e191d5f46de8e142fe216e677a35fa9c4bb.tar.gz gdb-514b4e191d5f46de8e142fe216e677a35fa9c4bb.tar.bz2 |
Change the default characteristics of DLLs built by the linker to more secure settings.
PR 19011
* emultempl/pe.em (DEFAULT_DLL_CHARACTERISTICS): Define.
(pe_dll_characteristics): Initialise to DEFAULT_DLL_CHARACTERISTICS.
(add_options): Add options to disable DLL characteristics.
(list_options): List the new options.
(handle_options): Handle the new options.
* emultempl/pep.em: Similar changes to above.
(NT_EXE_IMAGE_BASE): Default to an address above 4G.
(NT_DLL_IMAGE_BASE, NT_DLL_AUTO_IMAGE_BASE,
(NT_DLL_AUTO_IMAGE_MASK): Likewise.
* ld.texi: Document the new options.
* pe-dll.c (pe_dll_enable_reloc_section): Change to default to
true.
(generate_reloc): Do nothing if there is no reloc section.
(pe_exe_fill_sections): Only assign the reloc section contents if
the section exists.
* testsuite/ld-pe/pe.exp: Add the --disable-reloc-section flag to
the .secrel32 tests.
* testsuite/ld-scripts/provide-8.d: Expect for fail on PE targets.
* NEWS: Mention the change in DLL generation.
Diffstat (limited to 'ld/pe-dll.c')
-rw-r--r-- | ld/pe-dll.c | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/ld/pe-dll.c b/ld/pe-dll.c index 39c8e4c..f2a1798 100644 --- a/ld/pe-dll.c +++ b/ld/pe-dll.c @@ -160,7 +160,7 @@ int pe_dll_extra_pe_debug = 0; int pe_use_nul_prefixed_import_tables = 0; int pe_use_coff_long_section_names = -1; int pe_leading_underscore = -1; -int pe_dll_enable_reloc_section = 0; +int pe_dll_enable_reloc_section = 1; /* Static variables and types. */ @@ -1506,7 +1506,6 @@ pe_find_data_imports (const char *symhead, static void generate_reloc (bfd *abfd, struct bfd_link_info *info) { - /* For .reloc stuff. */ reloc_data_type *reloc_data; int total_relocs = 0; @@ -1517,6 +1516,8 @@ generate_reloc (bfd *abfd, struct bfd_link_info *info) bfd *b; struct bfd_section *s; + if (reloc_s == NULL) + return; total_relocs = 0; for (b = info->input_bfds; b; b = b->link.next) for (s = b->sections; s; s = s->next) @@ -1548,9 +1549,11 @@ generate_reloc (bfd *abfd, struct bfd_link_info *info) if (s->output_section->vma == 0) { /* Huh? Shouldn't happen, but punt if it does. */ +#if 0 /* This happens when linking with --just-symbols=<file>, so do not generate an error. */ einfo (_("%P: zero vma section reloc detected: `%s' #%d f=%d\n"), s->output_section->name, s->output_section->index, s->output_section->flags); +#endif continue; } @@ -3631,7 +3634,8 @@ pe_exe_fill_sections (bfd *abfd, struct bfd_link_info *info) /* Do the assignments again. */ lang_do_assignments (lang_final_phase_enum); } - reloc_s->contents = reloc_d; + if (reloc_s) + reloc_s->contents = reloc_d; } bfd_boolean |