diff options
author | Hannes Domani <ssbssa@yahoo.de> | 2020-01-03 12:55:12 +0000 |
---|---|---|
committer | Nick Clifton <nickc@redhat.com> | 2020-01-03 12:57:15 +0000 |
commit | dc9bd8c92af67947db44b3cb428c050259b15cd0 (patch) | |
tree | f6115a6aabaced600c41c2b005e685593afa307b /ld/pe-dll.c | |
parent | b26a3d5827edcb942b3af5b921bf317bbc0c8e83 (diff) | |
download | gdb-dc9bd8c92af67947db44b3cb428c050259b15cd0.zip gdb-dc9bd8c92af67947db44b3cb428c050259b15cd0.tar.gz gdb-dc9bd8c92af67947db44b3cb428c050259b15cd0.tar.bz2 |
For PE format files, the base relocation table is necessary if the image is loaded at a different image base than specified in the PE header. This patch provides a new option --enable-reloc-section to force the generation of this section.
* emultempl/pe.em: Add new option --enable-reloc-section.
* emultempl/pep.em: Likewise.
* ld.texi: Document --enable-reloc-section.
* pe-dll.c (pe_dll_build_sections): Use pe_dll_enable_reloc_section.
(pe_dll_fill_sections): Simplify by calling pe_exe_fill_sections.
* pe-dll.h: Add extern declaration of option flag.
* pep-dll.c (pe_dll_enable_reloc_section):
Add alias define for pep_dll_enable_reloc_section.
* pep-dll.h: Add extern declaration of option flag.
Diffstat (limited to 'ld/pe-dll.c')
-rw-r--r-- | ld/pe-dll.c | 35 |
1 files changed, 13 insertions, 22 deletions
diff --git a/ld/pe-dll.c b/ld/pe-dll.c index 4e26c0b..397af87 100644 --- a/ld/pe-dll.c +++ b/ld/pe-dll.c @@ -160,6 +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; /* Static variables and types. */ @@ -3554,7 +3555,14 @@ pe_dll_build_sections (bfd *abfd, struct bfd_link_info *info) process_def_file_and_drectve (abfd, info); if (pe_def_file->num_exports == 0 && !bfd_link_pic (info)) - return; + { + if (pe_dll_enable_reloc_section) + { + build_filler_bfd (0); + pe_output_file_set_long_section_names (filler_bfd); + } + return; + } generate_edata (abfd, info); build_filler_bfd (1); @@ -3573,33 +3581,16 @@ pe_exe_build_sections (bfd *abfd, struct bfd_link_info *info ATTRIBUTE_UNUSED) void pe_dll_fill_sections (bfd *abfd, struct bfd_link_info *info) { - pe_dll_id_target (bfd_get_target (abfd)); - pe_output_file_set_long_section_names (abfd); - image_base = pe_data (abfd)->pe_opthdr.ImageBase; + pe_exe_fill_sections (abfd, info); - generate_reloc (abfd, info); - if (reloc_sz > 0) + if (edata_s) { - bfd_set_section_size (reloc_s, reloc_sz); - - /* Resize the sections. */ - lang_reset_memory_regions (); - lang_size_sections (NULL, TRUE); - - /* Redo special stuff. */ - ldemul_after_allocation (); - - /* Do the assignments again. */ - lang_do_assignments (lang_final_phase_enum); + fill_edata (abfd, info); + edata_s->contents = edata_d; } - fill_edata (abfd, info); - if (bfd_link_dll (info)) pe_data (abfd)->dll = 1; - - edata_s->contents = edata_d; - reloc_s->contents = reloc_d; } void |