diff options
author | H.J. Lu <hjl.tools@gmail.com> | 2007-03-22 15:50:38 +0000 |
---|---|---|
committer | H.J. Lu <hjl.tools@gmail.com> | 2007-03-22 15:50:38 +0000 |
commit | 0920dee7bad8a96ae1866b9cd451103d8897abf5 (patch) | |
tree | 4996079f899d9f1fe4a8d0acee18d64ab2742f76 /bfd/elf.c | |
parent | 7d12900b6ef86df2cf80a0a3b41aa00734a2e9cc (diff) | |
download | gdb-0920dee7bad8a96ae1866b9cd451103d8897abf5.zip gdb-0920dee7bad8a96ae1866b9cd451103d8897abf5.tar.gz gdb-0920dee7bad8a96ae1866b9cd451103d8897abf5.tar.bz2 |
bfd/
2007-03-22 H.J. Lu <hongjiu.lu@intel.com>
PR ld/4007
* elf.c (assign_file_positions_for_load_sections): Check if
all sections are in the segment.
ld/testsuite/
2007-03-22 H.J. Lu <hongjiu.lu@intel.com>
PR ld/4007
* ld-elf/note-1.d: New file.
* ld-elf/note-1.s: Likewise.
* ld-elf/note-1.t: Likewise.
* ld-i386/alloc.d: Likewise.
* ld-i386/alloc.s: Likewise.
* ld-i386/alloc.t: Likewise.
* ld-i386/i386.exp: Run "alloc".
Diffstat (limited to 'bfd/elf.c')
-rw-r--r-- | bfd/elf.c | 29 |
1 files changed, 26 insertions, 3 deletions
@@ -4246,7 +4246,7 @@ assign_file_positions_for_load_sections (bfd *abfd, file_ptr off, voff; bfd_size_type maxpagesize; unsigned int alloc; - unsigned int i; + unsigned int i, j; if (link_info == NULL && !elf_modify_segment_map (abfd, link_info)) @@ -4284,9 +4284,9 @@ assign_file_positions_for_load_sections (bfd *abfd, off = bed->s->sizeof_ehdr; off += alloc * bed->s->sizeof_phdr; - for (m = elf_tdata (abfd)->segment_map, p = phdrs; + for (m = elf_tdata (abfd)->segment_map, p = phdrs, j = 0; m != NULL; - m = m->next, p++) + m = m->next, p++, j++) { asection **secpp; @@ -4604,6 +4604,29 @@ assign_file_positions_for_load_sections (bfd *abfd, p->p_flags |= PF_W; } } + + /* Check if all sections are in the segment. Skip PT_GNU_RELRO + and PT_NOTE segments since they will be processed by + assign_file_positions_for_non_load_sections later. */ + if (p->p_type != PT_GNU_RELRO + && p->p_type != PT_NOTE) + for (i = 0, secpp = m->sections; i < m->count; i++, secpp++) + { + Elf_Internal_Shdr *this_hdr; + asection *sec; + + sec = *secpp; + this_hdr = &(elf_section_data(sec)->this_hdr); + if (this_hdr->sh_size != 0 + && !ELF_IS_SECTION_IN_SEGMENT_FILE (this_hdr, p)) + { + (*_bfd_error_handler) + (_("%B: section `%A' can't be allocated in segment %d"), + abfd, sec, j); + bfd_set_error (bfd_error_bad_value); + return FALSE; + } + } } elf_tdata (abfd)->next_file_pos = off; |