diff options
Diffstat (limited to 'bfd')
-rw-r--r-- | bfd/Makefile.am | 4 | ||||
-rw-r--r-- | bfd/Makefile.in | 5 | ||||
-rw-r--r-- | bfd/config.bfd | 9 | ||||
-rwxr-xr-x | bfd/configure | 14 | ||||
-rw-r--r-- | bfd/configure.ac | 14 | ||||
-rw-r--r-- | bfd/elf-bfd.h | 30 | ||||
-rw-r--r-- | bfd/elf-nacl.c | 362 | ||||
-rw-r--r-- | bfd/elf-nacl.h | 21 | ||||
-rw-r--r-- | bfd/elf32-arc.c | 12 | ||||
-rw-r--r-- | bfd/elf32-arm.c | 283 | ||||
-rw-r--r-- | bfd/elf32-i386.c | 8 | ||||
-rw-r--r-- | bfd/elf32-ppc.c | 9 | ||||
-rw-r--r-- | bfd/elf64-ppc.c | 8 | ||||
-rw-r--r-- | bfd/elf64-x86-64.c | 8 | ||||
-rw-r--r-- | bfd/po/SRC-POTFILES.in | 2 | ||||
-rw-r--r-- | bfd/targets.c | 2 | ||||
-rw-r--r-- | bfd/version.h | 2 |
17 files changed, 43 insertions, 750 deletions
diff --git a/bfd/Makefile.am b/bfd/Makefile.am index 4987ac9..3c32432 100644 --- a/bfd/Makefile.am +++ b/bfd/Makefile.am @@ -289,7 +289,6 @@ BFD32_BACKENDS = \ elf-ifunc.lo \ elf-m10200.lo \ elf-m10300.lo \ - elf-nacl.lo \ elf-sframe.lo \ elf-strtab.lo \ elf-vxworks.lo \ @@ -423,7 +422,6 @@ BFD32_BACKENDS_CFILES = \ elf-ifunc.c \ elf-m10200.c \ elf-m10300.c \ - elf-nacl.c \ elf-sframe.c \ elf-strtab.c \ elf-vxworks.c \ @@ -709,7 +707,7 @@ SOURCE_HFILES = \ elf32-tic6x.h elf32-tilegx.h elf32-tilepro.h elf32-v850.h \ elf64-hppa.h elf64-ppc.h elf64-tilegx.h \ elf-bfd.h elfcode.h elfcore.h elf-hppa.h elf-linker-x86.h \ - elf-linux-core.h elf-nacl.h elf-s390.h elf-vxworks.h \ + elf-linux-core.h elf-s390.h elf-vxworks.h \ elfxx-aarch64.h elfxx-ia64.h elfxx-mips.h elfxx-riscv.h \ elfxx-sparc.h elfxx-tilegx.h elfxx-x86.h elfxx-loongarch.h \ genlink.h go32stub.h \ diff --git a/bfd/Makefile.in b/bfd/Makefile.in index 8a670ad..4c25968 100644 --- a/bfd/Makefile.in +++ b/bfd/Makefile.in @@ -755,7 +755,6 @@ BFD32_BACKENDS = \ elf-ifunc.lo \ elf-m10200.lo \ elf-m10300.lo \ - elf-nacl.lo \ elf-sframe.lo \ elf-strtab.lo \ elf-vxworks.lo \ @@ -889,7 +888,6 @@ BFD32_BACKENDS_CFILES = \ elf-ifunc.c \ elf-m10200.c \ elf-m10300.c \ - elf-nacl.c \ elf-sframe.c \ elf-strtab.c \ elf-vxworks.c \ @@ -1172,7 +1170,7 @@ SOURCE_HFILES = \ elf32-tic6x.h elf32-tilegx.h elf32-tilepro.h elf32-v850.h \ elf64-hppa.h elf64-ppc.h elf64-tilegx.h \ elf-bfd.h elfcode.h elfcore.h elf-hppa.h elf-linker-x86.h \ - elf-linux-core.h elf-nacl.h elf-s390.h elf-vxworks.h \ + elf-linux-core.h elf-s390.h elf-vxworks.h \ elfxx-aarch64.h elfxx-ia64.h elfxx-mips.h elfxx-riscv.h \ elfxx-sparc.h elfxx-tilegx.h elfxx-x86.h elfxx-loongarch.h \ genlink.h go32stub.h \ @@ -1560,7 +1558,6 @@ distclean-compile: @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/elf-ifunc.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/elf-m10200.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/elf-m10300.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/elf-nacl.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/elf-properties.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/elf-sframe.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/elf-strtab.Plo@am__quote@ diff --git a/bfd/config.bfd b/bfd/config.bfd index 4e5a838..eb20a01 100644 --- a/bfd/config.bfd +++ b/bfd/config.bfd @@ -83,6 +83,7 @@ case $targ in *-sony-* | \ *-tandem-* | \ *-*-ieee* | \ + *-*-nacl* | \ *-*-netbsdpe* | \ *-*-netware* | \ *-*-rtemsaout* | \ @@ -376,14 +377,6 @@ case "${targ}" in targ_defvec=arm_elf32_le_vec targ_selvecs="arm_elf32_fdpic_le_vec arm_elf32_be_vec arm_elf32_fdpic_be_vec arm_pe_le_vec arm_pe_be_vec arm_pei_le_vec arm_pei_be_vec" ;; - arm-*-nacl*) - targ_defvec=arm_elf32_nacl_le_vec - targ_selvecs="arm_elf32_nacl_be_vec" - ;; - armeb-*-nacl*) - targ_defvec=arm_elf32_nacl_be_vec - targ_selvecs="arm_elf32_nacl_le_vec" - ;; armeb-*-netbsd*) targ_defvec=arm_elf32_be_vec targ_selvecs="arm_elf32_le_vec" diff --git a/bfd/configure b/bfd/configure index 15a3269..28ac5cc 100755 --- a/bfd/configure +++ b/bfd/configure @@ -15503,14 +15503,12 @@ do aout_vec) tb="$tb host-aout.lo aout32.lo" ;; arc_elf32_be_vec) tb="$tb elf32-arc.lo elf32.lo $elf" ;; arc_elf32_le_vec) tb="$tb elf32-arc.lo elf32.lo $elf" ;; - arm_elf32_be_vec) tb="$tb elf32-arm.lo elf32.lo elf-nacl.lo elf-vxworks.lo $elf" ;; - arm_elf32_le_vec) tb="$tb elf32-arm.lo elf32.lo elf-nacl.lo elf-vxworks.lo $elf" ;; - arm_elf32_fdpic_be_vec) tb="$tb elf32-arm.lo elf32.lo elf-nacl.lo elf-vxworks.lo $elf" ;; - arm_elf32_fdpic_le_vec) tb="$tb elf32-arm.lo elf32.lo elf-nacl.lo elf-vxworks.lo $elf" ;; - arm_elf32_nacl_be_vec) tb="$tb elf32-arm.lo elf32.lo elf-nacl.lo elf-vxworks.lo $elf" ;; - arm_elf32_nacl_le_vec) tb="$tb elf32-arm.lo elf32.lo elf-nacl.lo elf-vxworks.lo $elf" ;; - arm_elf32_vxworks_be_vec) tb="$tb elf32-arm.lo elf32.lo elf-nacl.lo elf-vxworks.lo $elf" ;; - arm_elf32_vxworks_le_vec) tb="$tb elf32-arm.lo elf32.lo elf-nacl.lo elf-vxworks.lo $elf" ;; + arm_elf32_be_vec) tb="$tb elf32-arm.lo elf32.lo elf-vxworks.lo $elf" ;; + arm_elf32_le_vec) tb="$tb elf32-arm.lo elf32.lo elf-vxworks.lo $elf" ;; + arm_elf32_fdpic_be_vec) tb="$tb elf32-arm.lo elf32.lo elf-vxworks.lo $elf" ;; + arm_elf32_fdpic_le_vec) tb="$tb elf32-arm.lo elf32.lo elf-vxworks.lo $elf" ;; + arm_elf32_vxworks_be_vec) tb="$tb elf32-arm.lo elf32.lo elf-vxworks.lo $elf" ;; + arm_elf32_vxworks_le_vec) tb="$tb elf32-arm.lo elf32.lo elf-vxworks.lo $elf" ;; arm_pe_be_vec) tb="$tb pe-arm.lo peigen.lo $coff" ;; arm_pe_le_vec) tb="$tb pe-arm.lo peigen.lo $coff" ;; arm_pe_wince_be_vec) tb="$tb pe-arm-wince.lo pe-arm.lo peigen.lo $coff" ;; diff --git a/bfd/configure.ac b/bfd/configure.ac index 1e918e3..502c526 100644 --- a/bfd/configure.ac +++ b/bfd/configure.ac @@ -427,14 +427,12 @@ do aout_vec) tb="$tb host-aout.lo aout32.lo" ;; arc_elf32_be_vec) tb="$tb elf32-arc.lo elf32.lo $elf" ;; arc_elf32_le_vec) tb="$tb elf32-arc.lo elf32.lo $elf" ;; - arm_elf32_be_vec) tb="$tb elf32-arm.lo elf32.lo elf-nacl.lo elf-vxworks.lo $elf" ;; - arm_elf32_le_vec) tb="$tb elf32-arm.lo elf32.lo elf-nacl.lo elf-vxworks.lo $elf" ;; - arm_elf32_fdpic_be_vec) tb="$tb elf32-arm.lo elf32.lo elf-nacl.lo elf-vxworks.lo $elf" ;; - arm_elf32_fdpic_le_vec) tb="$tb elf32-arm.lo elf32.lo elf-nacl.lo elf-vxworks.lo $elf" ;; - arm_elf32_nacl_be_vec) tb="$tb elf32-arm.lo elf32.lo elf-nacl.lo elf-vxworks.lo $elf" ;; - arm_elf32_nacl_le_vec) tb="$tb elf32-arm.lo elf32.lo elf-nacl.lo elf-vxworks.lo $elf" ;; - arm_elf32_vxworks_be_vec) tb="$tb elf32-arm.lo elf32.lo elf-nacl.lo elf-vxworks.lo $elf" ;; - arm_elf32_vxworks_le_vec) tb="$tb elf32-arm.lo elf32.lo elf-nacl.lo elf-vxworks.lo $elf" ;; + arm_elf32_be_vec) tb="$tb elf32-arm.lo elf32.lo elf-vxworks.lo $elf" ;; + arm_elf32_le_vec) tb="$tb elf32-arm.lo elf32.lo elf-vxworks.lo $elf" ;; + arm_elf32_fdpic_be_vec) tb="$tb elf32-arm.lo elf32.lo elf-vxworks.lo $elf" ;; + arm_elf32_fdpic_le_vec) tb="$tb elf32-arm.lo elf32.lo elf-vxworks.lo $elf" ;; + arm_elf32_vxworks_be_vec) tb="$tb elf32-arm.lo elf32.lo elf-vxworks.lo $elf" ;; + arm_elf32_vxworks_le_vec) tb="$tb elf32-arm.lo elf32.lo elf-vxworks.lo $elf" ;; arm_pe_be_vec) tb="$tb pe-arm.lo peigen.lo $coff" ;; arm_pe_le_vec) tb="$tb pe-arm.lo peigen.lo $coff" ;; arm_pe_wince_be_vec) tb="$tb pe-arm-wince.lo pe-arm.lo peigen.lo $coff" ;; diff --git a/bfd/elf-bfd.h b/bfd/elf-bfd.h index fbb1cd9..b791623 100644 --- a/bfd/elf-bfd.h +++ b/bfd/elf-bfd.h @@ -605,8 +605,7 @@ enum elf_target_os { is_normal, is_solaris, /* Solaris. */ - is_vxworks, /* VxWorks. */ - is_nacl /* Native Client. */ + is_vxworks /* VxWorks. */ }; /* Used by bfd_sym_from_r_symndx to cache a small number of local @@ -3287,25 +3286,20 @@ extern asection _bfd_elf_large_com_section; && ((input_section->flags & SEC_DEBUGGING) != 0 \ || elf_section_type (input_section) == SHT_GNU_SFRAME)) \ { \ - Elf_Internal_Shdr *rel_hdr; \ + Elf_Internal_Shdr *rel_hdr \ + = _bfd_elf_single_rel_hdr (input_section->output_section); \ \ - rel_hdr = _bfd_elf_single_rel_hdr (input_section->output_section); \ + rel_hdr->sh_size -= rel_hdr->sh_entsize; \ + rel_hdr = _bfd_elf_single_rel_hdr (input_section); \ + rel_hdr->sh_size -= rel_hdr->sh_entsize; \ \ - /* Avoid empty output section. */ \ - if (rel_hdr->sh_size > rel_hdr->sh_entsize) \ - { \ - rel_hdr->sh_size -= rel_hdr->sh_entsize; \ - rel_hdr = _bfd_elf_single_rel_hdr (input_section); \ - rel_hdr->sh_size -= rel_hdr->sh_entsize; \ + memmove (rel, rel + count, \ + (relend - rel - count) * sizeof (*rel)); \ \ - memmove (rel, rel + count, \ - (relend - rel - count) * sizeof (*rel)); \ - \ - input_section->reloc_count -= count; \ - relend -= count; \ - rel--; \ - continue; \ - } \ + input_section->reloc_count -= count; \ + relend -= count; \ + rel--; \ + continue; \ } \ \ for (int i_ = 0; i_ < count; i_++) \ diff --git a/bfd/elf-nacl.c b/bfd/elf-nacl.c deleted file mode 100644 index 1265f2a..0000000 --- a/bfd/elf-nacl.c +++ /dev/null @@ -1,362 +0,0 @@ -/* Native Client support for ELF - Copyright (C) 2012-2025 Free Software Foundation, Inc. - - This file is part of BFD, the Binary File Descriptor library. - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see <http://www.gnu.org/licenses/>. */ - -#include "sysdep.h" -#include "bfd.h" -#include "libbfd.h" -#include "elf-bfd.h" -#include "elf-nacl.h" -#include "elf/common.h" -#include "elf/internal.h" - -static bool -segment_executable (struct elf_segment_map *seg) -{ - if (seg->p_flags_valid) - return (seg->p_flags & PF_X) != 0; - else - { - /* The p_flags value has not been computed yet, - so we have to look through the sections. */ - unsigned int i; - for (i = 0; i < seg->count; ++i) - if (seg->sections[i]->flags & SEC_CODE) - return true; - } - return false; -} - -/* Determine if this segment is eligible to receive the file and program - headers. It must be read-only and non-executable. - Its first section must start far enough past the page boundary to - allow space for the headers. */ -static bool -segment_eligible_for_headers (struct elf_segment_map *seg, - bfd_vma minpagesize, bfd_vma sizeof_headers) -{ - unsigned int i; - if (seg->count == 0 || seg->sections[0]->lma % minpagesize < sizeof_headers) - return false; - for (i = 0; i < seg->count; ++i) - { - if ((seg->sections[i]->flags & (SEC_CODE|SEC_READONLY)) != SEC_READONLY) - return false; - } - return true; -} - - -/* We permute the segment_map to get BFD to do the file layout we want: - The first non-executable PT_LOAD segment appears first in the file - and contains the ELF file header and phdrs. */ -bool -nacl_modify_segment_map (bfd *abfd, struct bfd_link_info *info) -{ - const struct elf_backend_data *const bed = get_elf_backend_data (abfd); - struct elf_segment_map **m = &elf_seg_map (abfd); - struct elf_segment_map **first_load = NULL; - struct elf_segment_map **headers = NULL; - int sizeof_headers; - - if (info != NULL && info->user_phdrs) - /* The linker script used PHDRS explicitly, so don't change what the - user asked for. */ - return true; - - if (info != NULL) - /* We're doing linking, so evalute SIZEOF_HEADERS as in a linker script. */ - sizeof_headers = bfd_sizeof_headers (abfd, info); - else - { - /* We're not doing linking, so this is objcopy or suchlike. - We just need to collect the size of the existing headers. */ - struct elf_segment_map *seg; - sizeof_headers = bed->s->sizeof_ehdr; - for (seg = *m; seg != NULL; seg = seg->next) - sizeof_headers += bed->s->sizeof_phdr; - } - - while (*m != NULL) - { - struct elf_segment_map *seg = *m; - - if (seg->p_type == PT_LOAD) - { - bool executable = segment_executable (seg); - - if (executable - && seg->count > 0 - && seg->sections[0]->vma % bed->minpagesize == 0) - { - asection *lastsec = seg->sections[seg->count - 1]; - bfd_vma end = lastsec->vma + lastsec->size; - if (end % bed->minpagesize != 0) - { - /* This is an executable segment that starts on a page - boundary but does not end on a page boundary. Fill - it out to a whole page with code fill (the tail of - the segment will not be within any section). Thus - the entire code segment can be mapped from the file - as whole pages and that mapping will contain only - valid instructions. - - To accomplish this, we must fake out the code in - assign_file_positions_for_load_sections (elf.c) so - that it advances past the rest of the final page, - rather than trying to put the next (unaligned, or - unallocated) section. We do this by appending a - dummy section record to this element in the segment - map. No such output section ever actually exists, - but this gets the layout logic to advance the file - positions past this partial page. Since we are - lying to BFD like this, nothing will ever know to - write the section contents. So we do that by hand - after the fact, in nacl_final_write_processing, below. */ - - struct elf_segment_map *newseg; - asection *sec; - struct bfd_elf_section_data *secdata; - - BFD_ASSERT (!seg->p_size_valid); - - secdata = bfd_zalloc (abfd, sizeof *secdata); - if (secdata == NULL) - return false; - - sec = bfd_zalloc (abfd, sizeof *sec); - if (sec == NULL) - return false; - - /* Fill in only the fields that actually affect the logic - in assign_file_positions_for_load_sections. */ - sec->vma = end; - sec->lma = lastsec->lma + lastsec->size; - sec->size = bed->minpagesize - (end % bed->minpagesize); - sec->flags = (SEC_ALLOC | SEC_LOAD - | SEC_READONLY | SEC_CODE | SEC_LINKER_CREATED); - sec->used_by_bfd = secdata; - - secdata->this_hdr.sh_type = SHT_PROGBITS; - secdata->this_hdr.sh_flags = SHF_ALLOC | SHF_EXECINSTR; - secdata->this_hdr.sh_addr = sec->vma; - secdata->this_hdr.sh_size = sec->size; - - newseg - = bfd_alloc (abfd, (sizeof (*newseg) - + seg->count * sizeof (asection *))); - if (newseg == NULL) - return false; - memcpy (newseg, seg, (sizeof (*newseg) - sizeof (asection *) - + seg->count * sizeof (asection *))); - newseg->sections[newseg->count++] = sec; - *m = seg = newseg; - } - } - - /* First, we're just finding the earliest PT_LOAD. - By the normal rules, this will be the lowest-addressed one. */ - if (first_load == NULL) - first_load = m; - - /* Now that we've noted the first PT_LOAD, we're looking for - the first non-executable PT_LOAD with a nonempty p_filesz. */ - else if (headers == NULL - && segment_eligible_for_headers (seg, bed->minpagesize, - sizeof_headers)) - headers = m; - } - m = &seg->next; - } - - if (headers != NULL) - { - struct elf_segment_map **last_load = NULL; - struct elf_segment_map *seg; - - m = first_load; - while ((seg = *m) != NULL) - { - if (seg->p_type == PT_LOAD) - { - /* Clear the flags on any previous segment that - included the file header and phdrs. */ - seg->includes_filehdr = 0; - seg->includes_phdrs = 0; - seg->no_sort_lma = 1; - /* Also strip out empty segments. */ - if (seg->count == 0) - { - if (headers == &seg->next) - headers = m; - *m = seg->next; - continue; - } - last_load = m; - } - m = &seg->next; - } - - /* This segment will include those headers instead. */ - seg = *headers; - seg->includes_filehdr = 1; - seg->includes_phdrs = 1; - - if (last_load != NULL && first_load != last_load && first_load != headers) - { - /* Put the first PT_LOAD header last. */ - struct elf_segment_map *first = *first_load; - struct elf_segment_map *last = *last_load; - *first_load = first->next; - first->next = last->next; - last->next = first; - } - } - - return true; -} - -/* After nacl_modify_segment_map has done its work, the file layout has - been done as we wanted. But the PT_LOAD phdrs are no longer in the - proper order for the ELF rule that they must appear in ascending address - order. So find the two segments we swapped before, and swap them back. */ -bool -nacl_modify_headers (bfd *abfd, struct bfd_link_info *info) -{ - if (info != NULL && info->user_phdrs) - /* The linker script used PHDRS explicitly, so don't change what the - user asked for. */ - ; - else - { - struct elf_segment_map **m = &elf_seg_map (abfd); - Elf_Internal_Phdr *phdr = elf_tdata (abfd)->phdr; - Elf_Internal_Phdr *p = phdr; - - /* Find the PT_LOAD that contains the headers (should be the first). */ - while (*m != NULL) - { - if ((*m)->p_type == PT_LOAD && (*m)->includes_filehdr) - break; - - m = &(*m)->next; - ++p; - } - - if (*m != NULL) - { - struct elf_segment_map **first_load_seg = m; - Elf_Internal_Phdr *first_load_phdr = p; - struct elf_segment_map **next_load_seg = NULL; - Elf_Internal_Phdr *next_load_phdr = NULL; - - /* Now move past that first one and find the PT_LOAD that should be - before it by address order. */ - - m = &(*m)->next; - ++p; - - while (*m != NULL) - { - if (p->p_type == PT_LOAD && p->p_vaddr < first_load_phdr->p_vaddr) - { - next_load_seg = m; - next_load_phdr = p; - break; - } - - m = &(*m)->next; - ++p; - } - - /* Swap their positions in the segment_map back to how they - used to be. The phdrs have already been set up by now, - so we have to slide up the earlier ones to insert the one - that should be first. */ - if (next_load_seg != NULL) - { - Elf_Internal_Phdr move_phdr; - struct elf_segment_map *first_seg = *first_load_seg; - struct elf_segment_map *next_seg = *next_load_seg; - struct elf_segment_map *first_next = first_seg->next; - struct elf_segment_map *next_next = next_seg->next; - - if (next_load_seg == &first_seg->next) - { - *first_load_seg = next_seg; - next_seg->next = first_seg; - first_seg->next = next_next; - } - else - { - *first_load_seg = first_next; - *next_load_seg = next_next; - - first_seg->next = *next_load_seg; - *next_load_seg = first_seg; - - next_seg->next = *first_load_seg; - *first_load_seg = next_seg; - } - - move_phdr = *next_load_phdr; - memmove (first_load_phdr + 1, first_load_phdr, - (next_load_phdr - first_load_phdr) * sizeof move_phdr); - *first_load_phdr = move_phdr; - } - } - } - - return _bfd_elf_modify_headers (abfd, info); -} - -bool -nacl_final_write_processing (bfd *abfd) -{ - struct elf_segment_map *seg; - for (seg = elf_seg_map (abfd); seg != NULL; seg = seg->next) - if (seg->p_type == PT_LOAD - && seg->count > 1 - && seg->sections[seg->count - 1]->owner == NULL) - { - /* This is a fake section added in nacl_modify_segment_map, above. - It's not a real BFD section, so nothing wrote its contents. - Now write out its contents. */ - - asection *sec = seg->sections[seg->count - 1]; - char *fill; - - BFD_ASSERT (sec->flags & SEC_LINKER_CREATED); - BFD_ASSERT (sec->flags & SEC_CODE); - BFD_ASSERT (sec->size > 0); - - fill = abfd->arch_info->fill (sec->size, bfd_big_endian (abfd), true); - - if (fill == NULL - || bfd_seek (abfd, sec->filepos, SEEK_SET) != 0 - || bfd_write (fill, sec->size, abfd) != sec->size) - { - /* We don't have a proper way to report an error here. So - instead fudge things so that elf_write_shdrs_and_ehdr will - fail. */ - elf_elfheader (abfd)->e_shoff = (file_ptr) -1; - } - - free (fill); - } - return _bfd_elf_final_write_processing (abfd); -} diff --git a/bfd/elf-nacl.h b/bfd/elf-nacl.h deleted file mode 100644 index 3a49dcb..0000000 --- a/bfd/elf-nacl.h +++ /dev/null @@ -1,21 +0,0 @@ -/* Native Client support for ELF - Copyright (C) 2012-2025 Free Software Foundation, Inc. - - This file is part of BFD, the Binary File Descriptor library. - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see <http://www.gnu.org/licenses/>. */ - -bool nacl_modify_segment_map (bfd *, struct bfd_link_info *); -bool nacl_modify_headers (bfd *, struct bfd_link_info *); -bool nacl_final_write_processing (bfd *); diff --git a/bfd/elf32-arc.c b/bfd/elf32-arc.c index 0a6e665..a78516d 100644 --- a/bfd/elf32-arc.c +++ b/bfd/elf32-arc.c @@ -1947,6 +1947,18 @@ elf_arc_relocate_section (bfd * output_bfd, return false; } + if (wrel != rel) + { + Elf_Internal_Shdr *rel_hdr; + size_t deleted = rel - wrel; + + rel_hdr = _bfd_elf_single_rel_hdr (input_section->output_section); + rel_hdr->sh_size -= rel_hdr->sh_entsize * deleted; + rel_hdr = _bfd_elf_single_rel_hdr (input_section); + rel_hdr->sh_size -= rel_hdr->sh_entsize * deleted; + input_section->reloc_count -= deleted; + } + return true; } diff --git a/bfd/elf32-arm.c b/bfd/elf32-arm.c index e4376f0..b5d1866 100644 --- a/bfd/elf32-arm.c +++ b/bfd/elf32-arm.c @@ -25,7 +25,6 @@ #include "libiberty.h" #include "libbfd.h" #include "elf-bfd.h" -#include "elf-nacl.h" #include "elf-vxworks.h" #include "elf/arm.h" #include "elf32-arm.h" @@ -2497,45 +2496,6 @@ static const bfd_vma elf32_arm_plt_thumb_stub [] = 0xe7fd /* b .-2 */ }; -/* The first entry in a procedure linkage table looks like - this. It is set up so that any shared library function that is - called before the relocation has been set up calls the dynamic - linker first. */ -static const bfd_vma elf32_arm_nacl_plt0_entry [] = -{ - /* First bundle: */ - 0xe300c000, /* movw ip, #:lower16:&GOT[2]-.+8 */ - 0xe340c000, /* movt ip, #:upper16:&GOT[2]-.+8 */ - 0xe08cc00f, /* add ip, ip, pc */ - 0xe52dc008, /* str ip, [sp, #-8]! */ - /* Second bundle: */ - 0xe3ccc103, /* bic ip, ip, #0xc0000000 */ - 0xe59cc000, /* ldr ip, [ip] */ - 0xe3ccc13f, /* bic ip, ip, #0xc000000f */ - 0xe12fff1c, /* bx ip */ - /* Third bundle: */ - 0xe320f000, /* nop */ - 0xe320f000, /* nop */ - 0xe320f000, /* nop */ - /* .Lplt_tail: */ - 0xe50dc004, /* str ip, [sp, #-4] */ - /* Fourth bundle: */ - 0xe3ccc103, /* bic ip, ip, #0xc0000000 */ - 0xe59cc000, /* ldr ip, [ip] */ - 0xe3ccc13f, /* bic ip, ip, #0xc000000f */ - 0xe12fff1c, /* bx ip */ -}; -#define ARM_NACL_PLT_TAIL_OFFSET (11 * 4) - -/* Subsequent entries in a procedure linkage table look like this. */ -static const bfd_vma elf32_arm_nacl_plt_entry [] = -{ - 0xe300c000, /* movw ip, #:lower16:&GOT[n]-.+8 */ - 0xe340c000, /* movt ip, #:upper16:&GOT[n]-.+8 */ - 0xe08cc00f, /* add ip, ip, pc */ - 0xea000000, /* b .Lplt_tail */ -}; - /* PR 28924: There was a bug due to too high values of THM_MAX_FWD_BRANCH_OFFSET and THM2_MAX_FWD_BRANCH_OFFSET. The first macro concerns the case when Thumb-2 @@ -2749,32 +2709,6 @@ static const insn_sequence elf32_arm_stub_long_branch_v4t_thumb_tls_pic[] = DATA_WORD (0, R_ARM_REL32, -4), /* dcd R_ARM_REL32(X) */ }; -/* NaCl ARM -> ARM long branch stub. */ -static const insn_sequence elf32_arm_stub_long_branch_arm_nacl[] = -{ - ARM_INSN (0xe59fc00c), /* ldr ip, [pc, #12] */ - ARM_INSN (0xe3ccc13f), /* bic ip, ip, #0xc000000f */ - ARM_INSN (0xe12fff1c), /* bx ip */ - ARM_INSN (0xe320f000), /* nop */ - ARM_INSN (0xe125be70), /* bkpt 0x5be0 */ - DATA_WORD (0, R_ARM_ABS32, 0), /* dcd R_ARM_ABS32(X) */ - DATA_WORD (0, R_ARM_NONE, 0), /* .word 0 */ - DATA_WORD (0, R_ARM_NONE, 0), /* .word 0 */ -}; - -/* NaCl ARM -> ARM long branch stub, PIC. */ -static const insn_sequence elf32_arm_stub_long_branch_arm_nacl_pic[] = -{ - ARM_INSN (0xe59fc00c), /* ldr ip, [pc, #12] */ - ARM_INSN (0xe08cc00f), /* add ip, ip, pc */ - ARM_INSN (0xe3ccc13f), /* bic ip, ip, #0xc000000f */ - ARM_INSN (0xe12fff1c), /* bx ip */ - ARM_INSN (0xe125be70), /* bkpt 0x5be0 */ - DATA_WORD (0, R_ARM_REL32, 8), /* dcd R_ARM_REL32(X+8) */ - DATA_WORD (0, R_ARM_NONE, 0), /* .word 0 */ - DATA_WORD (0, R_ARM_NONE, 0), /* .word 0 */ -}; - /* Stub used for transition to secure state (aka SG veneer). */ static const insn_sequence elf32_arm_stub_cmse_branch_thumb_only[] = { @@ -2859,8 +2793,6 @@ static const insn_sequence elf32_arm_stub_a8_veneer_blx[] = DEF_STUB (long_branch_thumb_only_pic) \ DEF_STUB (long_branch_any_tls_pic) \ DEF_STUB (long_branch_v4t_thumb_tls_pic) \ - DEF_STUB (long_branch_arm_nacl) \ - DEF_STUB (long_branch_arm_nacl_pic) \ DEF_STUB (cmse_branch_thumb_only) \ DEF_STUB (a8_veneer_b_cond) \ DEF_STUB (a8_veneer_b) \ @@ -4524,13 +4456,9 @@ arm_type_of_stub (struct bfd_link_info *info, ? (r_type == R_ARM_TLS_CALL /* TLS PIC Stub. */ ? arm_stub_long_branch_any_tls_pic - : (globals->root.target_os == is_nacl - ? arm_stub_long_branch_arm_nacl_pic - : arm_stub_long_branch_any_arm_pic)) + : arm_stub_long_branch_any_arm_pic) /* non-PIC stubs. */ - : (globals->root.target_os == is_nacl - ? arm_stub_long_branch_arm_nacl - : arm_stub_long_branch_any_any); + : arm_stub_long_branch_any_any; } } } @@ -4793,7 +4721,7 @@ elf32_arm_create_or_find_stub_sec (asection **link_sec_p, asection *section, stub_sec_p = &htab->stub_group[link_sec->id].stub_sec; stub_sec_prefix = link_sec->name; out_sec = link_sec->output_section; - align = htab->root.target_os == is_nacl ? 4 : 3; + align = 3; } if (*stub_sec_p == NULL) @@ -4974,10 +4902,6 @@ arm_stub_required_alignment (enum elf32_arm_stub_type stub_type) case arm_stub_a8_veneer_blx: return 4; - case arm_stub_long_branch_arm_nacl: - case arm_stub_long_branch_arm_nacl_pic: - return 16; - default: abort (); /* Should be unreachable. */ } @@ -9571,10 +9495,6 @@ elf32_arm_allocate_plt_entry (struct bfd_link_info *info, splt = htab->root.iplt; sgotplt = htab->root.igotplt; - /* NaCl uses a special first entry in .iplt too. */ - if (htab->root.target_os == is_nacl && splt->size == 0) - splt->size += htab->plt_header_size; - /* Allocate room for an R_ARM_IRELATIVE relocation in .rel.iplt. */ elf32_arm_allocate_irelocs (info, htab->root.irelplt, 1); } @@ -9627,18 +9547,6 @@ elf32_arm_allocate_plt_entry (struct bfd_link_info *info, sgotplt->size += 4; } -static bfd_vma -arm_movw_immediate (bfd_vma value) -{ - return (value & 0x00000fff) | ((value & 0x0000f000) << 4); -} - -static bfd_vma -arm_movt_immediate (bfd_vma value) -{ - return ((value & 0x0fff0000) >> 16) | ((value & 0xf0000000) >> 12); -} - /* Fill in a PLT entry and its associated GOT slot. If DYNINDX == -1, the entry lives in .iplt and resolves to (*SYM_VALUE)(). Otherwise, DYNINDX is the index of the symbol in the dynamic @@ -9776,45 +9684,6 @@ elf32_arm_populate_plt_entry (bfd *output_bfd, struct bfd_link_info *info, rel.r_addend = 0; SWAP_RELOC_OUT (htab) (output_bfd, &rel, loc); } - else if (htab->root.target_os == is_nacl) - { - /* Calculate the displacement between the PLT slot and the - common tail that's part of the special initial PLT slot. */ - int32_t tail_displacement - = ((splt->output_section->vma + splt->output_offset - + ARM_NACL_PLT_TAIL_OFFSET) - - (plt_address + htab->plt_entry_size + 4)); - BFD_ASSERT ((tail_displacement & 3) == 0); - tail_displacement >>= 2; - - BFD_ASSERT ((tail_displacement & 0xff000000) == 0 - || (-tail_displacement & 0xff000000) == 0); - - /* Calculate the displacement between the PLT slot and the entry - in the GOT. The offset accounts for the value produced by - adding to pc in the penultimate instruction of the PLT stub. */ - got_displacement = (got_address - - (plt_address + htab->plt_entry_size)); - - /* NaCl does not support interworking at all. */ - BFD_ASSERT (!elf32_arm_plt_needs_thumb_stub_p (info, arm_plt)); - - put_arm_insn (htab, output_bfd, - elf32_arm_nacl_plt_entry[0] - | arm_movw_immediate (got_displacement), - ptr + 0); - put_arm_insn (htab, output_bfd, - elf32_arm_nacl_plt_entry[1] - | arm_movt_immediate (got_displacement), - ptr + 4); - put_arm_insn (htab, output_bfd, - elf32_arm_nacl_plt_entry[2], - ptr + 8); - put_arm_insn (htab, output_bfd, - elf32_arm_nacl_plt_entry[3] - | (tail_displacement & 0x00ffffff), - ptr + 12); - } else if (htab->fdpic_p) { const bfd_vma *plt_entry = using_thumb_only (htab) @@ -17344,38 +17213,6 @@ arm_put_trampoline (struct elf32_arm_link_hash_table *htab, bfd *output_bfd, } } -/* Install the special first PLT entry for elf32-arm-nacl. Unlike - other variants, NaCl needs this entry in a static executable's - .iplt too. When we're handling that case, GOT_DISPLACEMENT is - zero. For .iplt really only the last bundle is useful, and .iplt - could have a shorter first entry, with each individual PLT entry's - relative branch calculated differently so it targets the last - bundle instead of the instruction before it (labelled .Lplt_tail - above). But it's simpler to keep the size and layout of PLT0 - consistent with the dynamic case, at the cost of some dead code at - the start of .iplt and the one dead store to the stack at the start - of .Lplt_tail. */ -static void -arm_nacl_put_plt0 (struct elf32_arm_link_hash_table *htab, bfd *output_bfd, - asection *plt, bfd_vma got_displacement) -{ - unsigned int i; - - put_arm_insn (htab, output_bfd, - elf32_arm_nacl_plt0_entry[0] - | arm_movw_immediate (got_displacement), - plt->contents + 0); - put_arm_insn (htab, output_bfd, - elf32_arm_nacl_plt0_entry[1] - | arm_movt_immediate (got_displacement), - plt->contents + 4); - - for (i = 2; i < ARRAY_SIZE (elf32_arm_nacl_plt0_entry); ++i) - put_arm_insn (htab, output_bfd, - elf32_arm_nacl_plt0_entry[i], - plt->contents + (i * 4)); -} - /* Finish up the dynamic sections. */ static bool @@ -17541,9 +17378,6 @@ elf32_arm_finish_dynamic_sections (bfd * output_bfd, struct bfd_link_info * info SWAP_RELOC_OUT (htab) (output_bfd, &rel, htab->srelplt2->contents); } - else if (htab->root.target_os == is_nacl) - arm_nacl_put_plt0 (htab, output_bfd, splt, - got_address + 8 - (plt_address + 16)); else if (using_thumb_only (htab)) { got_displacement = got_address - (plt_address + 12); @@ -17652,12 +17486,6 @@ elf32_arm_finish_dynamic_sections (bfd * output_bfd, struct bfd_link_info * info } } - if (htab->root.target_os == is_nacl - && htab->root.iplt != NULL - && htab->root.iplt->size > 0) - /* NaCl uses a special first entry in .iplt too. */ - arm_nacl_put_plt0 (htab, output_bfd, htab->root.iplt, 0); - /* Fill in the first three entries in the global offset table. */ if (sgot) { @@ -17971,11 +17799,6 @@ elf32_arm_output_plt_map_1 (output_arch_syminfo *osi, if (!elf32_arm_output_map_sym (osi, ARM_MAP_DATA, addr + 20)) return false; } - else if (htab->root.target_os == is_nacl) - { - if (!elf32_arm_output_map_sym (osi, ARM_MAP_ARM, addr)) - return false; - } else if (htab->fdpic_p) { enum map_symbol_type type = using_thumb_only (htab) @@ -18348,11 +18171,6 @@ elf32_arm_output_arch_local_syms (bfd *output_bfd, return false; } } - else if (htab->root.target_os == is_nacl) - { - if (!elf32_arm_output_map_sym (&osi, ARM_MAP_ARM, 0)) - return false; - } else if (using_thumb_only (htab) && !htab->fdpic_p) { if (!elf32_arm_output_map_sym (&osi, ARM_MAP_THUMB, 0)) @@ -18372,17 +18190,6 @@ elf32_arm_output_arch_local_syms (bfd *output_bfd, #endif } } - if (htab->root.target_os == is_nacl - && htab->root.iplt - && htab->root.iplt->size > 0) - { - /* NaCl uses a special first entry in .iplt too. */ - osi.sec = htab->root.iplt; - osi.sec_shndx = (_bfd_elf_section_from_bfd_section - (output_bfd, osi.sec->output_section)); - if (!elf32_arm_output_map_sym (&osi, ARM_MAP_ARM, 0)) - return false; - } if ((htab->root.splt && htab->root.splt->size > 0) || (htab->root.iplt && htab->root.iplt->size > 0)) { @@ -20440,90 +20247,6 @@ elf32_arm_backend_symbol_processing (bfd *abfd, asymbol *sym) #include "elf32-target.h" -/* Native Client targets. */ - -#undef TARGET_LITTLE_SYM -#define TARGET_LITTLE_SYM arm_elf32_nacl_le_vec -#undef TARGET_LITTLE_NAME -#define TARGET_LITTLE_NAME "elf32-littlearm-nacl" -#undef TARGET_BIG_SYM -#define TARGET_BIG_SYM arm_elf32_nacl_be_vec -#undef TARGET_BIG_NAME -#define TARGET_BIG_NAME "elf32-bigarm-nacl" - -/* Like elf32_arm_link_hash_table_create -- but overrides - appropriately for NaCl. */ - -static struct bfd_link_hash_table * -elf32_arm_nacl_link_hash_table_create (bfd *abfd) -{ - struct bfd_link_hash_table *ret; - - ret = elf32_arm_link_hash_table_create (abfd); - if (ret) - { - struct elf32_arm_link_hash_table *htab - = (struct elf32_arm_link_hash_table *) ret; - - htab->plt_header_size = 4 * ARRAY_SIZE (elf32_arm_nacl_plt0_entry); - htab->plt_entry_size = 4 * ARRAY_SIZE (elf32_arm_nacl_plt_entry); - } - return ret; -} - -/* Since NaCl doesn't use the ARM-specific unwind format, we don't - really need to use elf32_arm_modify_segment_map. But we do it - anyway just to reduce gratuitous differences with the stock ARM backend. */ - -static bool -elf32_arm_nacl_modify_segment_map (bfd *abfd, struct bfd_link_info *info) -{ - return (elf32_arm_modify_segment_map (abfd, info) - && nacl_modify_segment_map (abfd, info)); -} - -static bool -elf32_arm_nacl_final_write_processing (bfd *abfd) -{ - arm_final_write_processing (abfd); - return nacl_final_write_processing (abfd); -} - -static bfd_vma -elf32_arm_nacl_plt_sym_val (bfd_vma i, const asection *plt, - const arelent *rel ATTRIBUTE_UNUSED) -{ - return plt->vma - + 4 * (ARRAY_SIZE (elf32_arm_nacl_plt0_entry) + - i * ARRAY_SIZE (elf32_arm_nacl_plt_entry)); -} - -#undef elf32_bed -#define elf32_bed elf32_arm_nacl_bed -#undef bfd_elf32_bfd_link_hash_table_create -#define bfd_elf32_bfd_link_hash_table_create \ - elf32_arm_nacl_link_hash_table_create -#undef elf_backend_plt_alignment -#define elf_backend_plt_alignment 4 -#undef elf_backend_modify_segment_map -#define elf_backend_modify_segment_map elf32_arm_nacl_modify_segment_map -#undef elf_backend_modify_headers -#define elf_backend_modify_headers nacl_modify_headers -#undef elf_backend_final_write_processing -#define elf_backend_final_write_processing elf32_arm_nacl_final_write_processing -#undef bfd_elf32_get_synthetic_symtab -#undef elf_backend_plt_sym_val -#define elf_backend_plt_sym_val elf32_arm_nacl_plt_sym_val -#undef elf_backend_copy_special_section_fields - -#undef ELF_MINPAGESIZE -#undef ELF_COMMONPAGESIZE - -#undef ELF_TARGET_OS -#define ELF_TARGET_OS is_nacl - -#include "elf32-target.h" - /* Reset to defaults. */ #undef elf_backend_plt_alignment #undef elf_backend_modify_segment_map diff --git a/bfd/elf32-i386.c b/bfd/elf32-i386.c index b417cb0..abe26e4 100644 --- a/bfd/elf32-i386.c +++ b/bfd/elf32-i386.c @@ -3600,14 +3600,6 @@ elf_i386_relocate_section (bfd *output_bfd, rel_hdr = _bfd_elf_single_rel_hdr (input_section->output_section); rel_hdr->sh_size -= rel_hdr->sh_entsize * deleted; - if (rel_hdr->sh_size == 0) - { - /* It is too late to remove an empty reloc section. Leave - one NONE reloc. - ??? What is wrong with an empty section??? */ - rel_hdr->sh_size = rel_hdr->sh_entsize; - deleted -= 1; - } rel_hdr = _bfd_elf_single_rel_hdr (input_section); rel_hdr->sh_size -= rel_hdr->sh_entsize * deleted; input_section->reloc_count -= deleted; diff --git a/bfd/elf32-ppc.c b/bfd/elf32-ppc.c index f17effd..3fd9f28 100644 --- a/bfd/elf32-ppc.c +++ b/bfd/elf32-ppc.c @@ -9142,15 +9142,6 @@ ppc_elf_relocate_section (bfd *output_bfd, rel_hdr = _bfd_elf_single_rel_hdr (input_section->output_section); rel_hdr->sh_size -= rel_hdr->sh_entsize * deleted; - if (rel_hdr->sh_size == 0) - { - /* It is too late to remove an empty reloc section. Leave - one NONE reloc. - ??? What is wrong with an empty section??? */ - rel_hdr->sh_size = rel_hdr->sh_entsize; - deleted -= 1; - wrel++; - } relend = wrel; rel_hdr = _bfd_elf_single_rel_hdr (input_section); rel_hdr->sh_size -= rel_hdr->sh_entsize * deleted; diff --git a/bfd/elf64-ppc.c b/bfd/elf64-ppc.c index 00c1c32..e6c90a6 100644 --- a/bfd/elf64-ppc.c +++ b/bfd/elf64-ppc.c @@ -18082,14 +18082,6 @@ ppc64_elf_relocate_section (bfd *output_bfd, rel_hdr = _bfd_elf_single_rel_hdr (input_section->output_section); rel_hdr->sh_size -= rel_hdr->sh_entsize * deleted; - if (rel_hdr->sh_size == 0) - { - /* It is too late to remove an empty reloc section. Leave - one NONE reloc. - ??? What is wrong with an empty section??? */ - rel_hdr->sh_size = rel_hdr->sh_entsize; - deleted -= 1; - } rel_hdr = _bfd_elf_single_rel_hdr (input_section); rel_hdr->sh_size -= rel_hdr->sh_entsize * deleted; input_section->reloc_count -= deleted; diff --git a/bfd/elf64-x86-64.c b/bfd/elf64-x86-64.c index ebd2eb4..b6f97b5 100644 --- a/bfd/elf64-x86-64.c +++ b/bfd/elf64-x86-64.c @@ -5099,14 +5099,6 @@ elf_x86_64_relocate_section (bfd *output_bfd, rel_hdr = _bfd_elf_single_rel_hdr (input_section->output_section); rel_hdr->sh_size -= rel_hdr->sh_entsize * deleted; - if (rel_hdr->sh_size == 0) - { - /* It is too late to remove an empty reloc section. Leave - one NONE reloc. - ??? What is wrong with an empty section??? */ - rel_hdr->sh_size = rel_hdr->sh_entsize; - deleted -= 1; - } rel_hdr = _bfd_elf_single_rel_hdr (input_section); rel_hdr->sh_size -= rel_hdr->sh_entsize * deleted; input_section->reloc_count -= deleted; diff --git a/bfd/po/SRC-POTFILES.in b/bfd/po/SRC-POTFILES.in index 54b078b..1ba9cc2 100644 --- a/bfd/po/SRC-POTFILES.in +++ b/bfd/po/SRC-POTFILES.in @@ -140,8 +140,6 @@ elf-linker-x86.h elf-linux-core.h elf-m10200.c elf-m10300.c -elf-nacl.c -elf-nacl.h elf-properties.c elf-s390.h elf-sframe.c diff --git a/bfd/targets.c b/bfd/targets.c index 2333370..c2ee917 100644 --- a/bfd/targets.c +++ b/bfd/targets.c @@ -696,8 +696,6 @@ extern const bfd_target arm_elf32_be_vec; extern const bfd_target arm_elf32_le_vec; extern const bfd_target arm_elf32_fdpic_be_vec; extern const bfd_target arm_elf32_fdpic_le_vec; -extern const bfd_target arm_elf32_nacl_be_vec; -extern const bfd_target arm_elf32_nacl_le_vec; extern const bfd_target arm_elf32_vxworks_be_vec; extern const bfd_target arm_elf32_vxworks_le_vec; extern const bfd_target arm_mach_o_vec; diff --git a/bfd/version.h b/bfd/version.h index f200fb8..bdb3f9d 100644 --- a/bfd/version.h +++ b/bfd/version.h @@ -16,7 +16,7 @@ In releases, the date is not included in either version strings or sonames. */ -#define BFD_VERSION_DATE 20250718 +#define BFD_VERSION_DATE 20250721 #define BFD_VERSION @bfd_version@ #define BFD_VERSION_STRING @bfd_version_package@ @bfd_version_string@ #define REPORT_BUGS_TO @report_bugs_to@ |