From c5e20471be97e2dcd3498ac284487e2546715f66 Mon Sep 17 00:00:00 2001 From: Alan Modra Date: Wed, 24 Jul 2019 10:11:08 +0930 Subject: [PATCH] Re: ELF final_write_processing I missed some early exits from final_write_processing that mean _bfd_elf_final_write_processing could be missed. * elf-vxworks.c (elf_vxworks_final_write_processing): Don't return early. * elf32-arc.c (arc_elf_final_write_processing): Likewise. * elf32-xtensa.c (elf_xtensa_final_write_processing): Likewise. --- bfd/ChangeLog | 7 +++++++ bfd/elf-vxworks.c | 13 +++++++------ bfd/elf32-arc.c | 14 +++----------- bfd/elf32-xtensa.c | 6 +++--- 4 files changed, 20 insertions(+), 20 deletions(-) diff --git a/bfd/ChangeLog b/bfd/ChangeLog index a309957de87..1fe3860d9fa 100644 --- a/bfd/ChangeLog +++ b/bfd/ChangeLog @@ -1,3 +1,10 @@ +2019-07-24 Alan Modra + + * elf-vxworks.c (elf_vxworks_final_write_processing): Don't return + early. + * elf32-arc.c (arc_elf_final_write_processing): Likewise. + * elf32-xtensa.c (elf_xtensa_final_write_processing): Likewise. + 2019-07-24 Alan Modra * elf32-visium.c (visium_elf_post_process_headers): Don't set diff --git a/bfd/elf-vxworks.c b/bfd/elf-vxworks.c index 32eb5a9ccfb..4447b365110 100644 --- a/bfd/elf-vxworks.c +++ b/bfd/elf-vxworks.c @@ -221,13 +221,14 @@ elf_vxworks_final_write_processing (bfd *abfd, bfd_boolean linker) sec = bfd_get_section_by_name (abfd, ".rel.plt.unloaded"); if (!sec) sec = bfd_get_section_by_name (abfd, ".rela.plt.unloaded"); - if (!sec) - return; - d = elf_section_data (sec); - d->this_hdr.sh_link = elf_onesymtab (abfd); - sec = bfd_get_section_by_name (abfd, ".plt"); if (sec) - d->this_hdr.sh_info = elf_section_data (sec)->this_idx; + { + d = elf_section_data (sec); + d->this_hdr.sh_link = elf_onesymtab (abfd); + sec = bfd_get_section_by_name (abfd, ".plt"); + if (sec) + d->this_hdr.sh_info = elf_section_data (sec)->this_idx; + } _bfd_elf_final_write_processing (abfd, linker); } diff --git a/bfd/elf32-arc.c b/bfd/elf32-arc.c index ad5757acc94..fc4c3ae50a5 100644 --- a/bfd/elf32-arc.c +++ b/bfd/elf32-arc.c @@ -1026,20 +1026,12 @@ arc_elf_final_write_processing (bfd *abfd, bfd_boolean linker) switch (bfd_get_mach (abfd)) { - case bfd_mach_arc_arc600: - emf = EM_ARC_COMPACT; - break; - case bfd_mach_arc_arc601: - emf = EM_ARC_COMPACT; - break; - case bfd_mach_arc_arc700: - emf = EM_ARC_COMPACT; - break; case bfd_mach_arc_arcv2: emf = EM_ARC_COMPACT2; break; default: - return; + emf = EM_ARC_COMPACT; + break; } elf_elfheader (abfd)->e_machine = emf; @@ -1050,7 +1042,7 @@ arc_elf_final_write_processing (bfd *abfd, bfd_boolean linker) else e_flags |= E_ARC_OSABI_V3; - elf_elfheader (abfd)->e_flags |= e_flags; + elf_elfheader (abfd)->e_flags |= e_flags; _bfd_elf_final_write_processing (abfd, linker); } diff --git a/bfd/elf32-xtensa.c b/bfd/elf32-xtensa.c index 66d23a8d63d..40edb467e5e 100644 --- a/bfd/elf32-xtensa.c +++ b/bfd/elf32-xtensa.c @@ -3466,7 +3466,7 @@ static void elf_xtensa_final_write_processing (bfd *abfd, bfd_boolean linker) { int mach; - unsigned long val; + unsigned long val = elf_elfheader (abfd)->e_flags & EF_XTENSA_MACH; switch (mach = bfd_get_mach (abfd)) { @@ -3474,10 +3474,10 @@ elf_xtensa_final_write_processing (bfd *abfd, bfd_boolean linker) val = E_XTENSA_MACH; break; default: - return; + break; } - elf_elfheader (abfd)->e_flags &= (~ EF_XTENSA_MACH); + elf_elfheader (abfd)->e_flags &= ~EF_XTENSA_MACH; elf_elfheader (abfd)->e_flags |= val; _bfd_elf_final_write_processing (abfd, linker); } -- 2.30.2