include/elf/
* internal.h (ELF_TBSS_SPECIAL): New macro, extracted from.. (ELF_SECTION_SIZE): ..here. (ELF_SECTION_IN_SEGMENT_1): Add "strict" arg. (ELF_SECTION_IN_SEGMENT_STRICT): New macro. bfd/ * elf.c (assign_file_positions_for_load_sections): Check that zero size sections are allocated in segments too. (assign_file_positions_for_non_load_sections): Warn if zero size alloc sections are found here. (copy_elf_program_header): Don't drop zero size sections from segment map. (copy_private_bfd_data): Check for changes in zero size sections. binutils/ * readelf.c (process_program_headers): Don't ignore all zero size sections. ld/testsuite/ * ld-powerpc/tlsexe.r: Update. * ld-powerpc/tlsexetoc.r: Update. * ld-powerpc/tlsso.r: Update. * ld-powerpc/tlstocso.r: Update.
This commit is contained in:
		| @@ -1,3 +1,10 @@ | |||||||
|  | 2010-07-20  Alan Modra  <amodra@gmail.com> | ||||||
|  |  | ||||||
|  | 	* internal.h (ELF_TBSS_SPECIAL): New macro, extracted from.. | ||||||
|  | 	(ELF_SECTION_SIZE): ..here. | ||||||
|  | 	(ELF_SECTION_IN_SEGMENT_1): Add "strict" arg. | ||||||
|  | 	(ELF_SECTION_IN_SEGMENT_STRICT): New macro. | ||||||
|  |  | ||||||
| 2010-06-25  Alan Modra  <amodra@gmail.com> | 2010-06-25  Alan Modra  <amodra@gmail.com> | ||||||
|  |  | ||||||
| 	* ppc64.h (R_PPC64_LO_DS_OPT): Define. | 	* ppc64.h (R_PPC64_LO_DS_OPT): Define. | ||||||
|   | |||||||
| @@ -291,37 +291,55 @@ struct elf_segment_map | |||||||
|  |  | ||||||
| /* .tbss is special.  It doesn't contribute memory space to normal | /* .tbss is special.  It doesn't contribute memory space to normal | ||||||
|    segments and it doesn't take file space in normal segments.  */ |    segments and it doesn't take file space in normal segments.  */ | ||||||
| #define ELF_SECTION_SIZE(sec_hdr, segment)			\ | #define ELF_TBSS_SPECIAL(sec_hdr, segment)			\ | ||||||
|   ((!(((sec_hdr)->sh_flags & SHF_TLS) != 0			\ |   (((sec_hdr)->sh_flags & SHF_TLS) != 0				\ | ||||||
|       && (sec_hdr)->sh_type == SHT_NOBITS)			\ |    && (sec_hdr)->sh_type == SHT_NOBITS				\ | ||||||
|     || (segment)->p_type == PT_TLS) ? (sec_hdr)->sh_size : 0) |    && (segment)->p_type != PT_TLS) | ||||||
|  |  | ||||||
| /* Decide if the given sec_hdr is in the given segment.  PT_TLS segment | #define ELF_SECTION_SIZE(sec_hdr, segment)			\ | ||||||
|    contains only SHF_TLS sections.  Only PT_LOAD, PT_GNU_RELRO and |   (ELF_TBSS_SPECIAL(sec_hdr, segment) ? 0 : (sec_hdr)->sh_size) | ||||||
|    and PT_TLS segments can contain SHF_TLS sections.  */ |  | ||||||
| #define ELF_SECTION_IN_SEGMENT_1(sec_hdr, segment, check_vma)		\ | /* Decide if the section SEC_HDR is in SEGMENT.  If CHECK_VMA, then | ||||||
|   ((((((sec_hdr)->sh_flags & SHF_TLS) != 0)				\ |    VMAs are checked for alloc sections.  If STRICT, then a zero size | ||||||
|  |    section won't match at the end of a segment, unless the segment | ||||||
|  |    is also zero size.  */ | ||||||
|  | #define ELF_SECTION_IN_SEGMENT_1(sec_hdr, segment, check_vma, strict)	\ | ||||||
|  |   ((/* Only PT_LOAD, PT_GNU_RELRO and PT_TLS segments can contain	\ | ||||||
|  |        SHF_TLS sections.  */						\ | ||||||
|  |     ((((sec_hdr)->sh_flags & SHF_TLS) != 0)				\ | ||||||
|      && ((segment)->p_type == PT_TLS					\ |      && ((segment)->p_type == PT_TLS					\ | ||||||
| 	 || (segment)->p_type == PT_GNU_RELRO				\ | 	 || (segment)->p_type == PT_GNU_RELRO				\ | ||||||
| 	 || (segment)->p_type == PT_LOAD))				\ | 	 || (segment)->p_type == PT_LOAD))				\ | ||||||
|  |     /* PT_TLS segment contains only SHF_TLS sections, PT_PHDR no	\ | ||||||
|  |        sections at all.  */						\ | ||||||
|     || (((sec_hdr)->sh_flags & SHF_TLS) == 0				\ |     || (((sec_hdr)->sh_flags & SHF_TLS) == 0				\ | ||||||
| 	&& (segment)->p_type != PT_TLS					\ | 	&& (segment)->p_type != PT_TLS					\ | ||||||
| 	&& (segment)->p_type != PT_PHDR))				\ | 	&& (segment)->p_type != PT_PHDR))				\ | ||||||
|    /* Any section besides one of type SHT_NOBITS must have a file	\ |    /* Any section besides one of type SHT_NOBITS must have file		\ | ||||||
|       offset within the segment.  */					\ |       offsets within the segment.  */					\ | ||||||
|    && ((sec_hdr)->sh_type == SHT_NOBITS					\ |    && ((sec_hdr)->sh_type == SHT_NOBITS					\ | ||||||
|        || ((bfd_vma) (sec_hdr)->sh_offset >= (segment)->p_offset	\ |        || ((bfd_vma) (sec_hdr)->sh_offset >= (segment)->p_offset	\ | ||||||
| 	   && ((sec_hdr)->sh_offset + ELF_SECTION_SIZE(sec_hdr, segment) \ | 	   && (!(strict)						\ | ||||||
| 	       <= (segment)->p_offset + (segment)->p_filesz)))		\ | 	       || ((sec_hdr)->sh_offset - (segment)->p_offset		\ | ||||||
|    /* SHF_ALLOC sections must have VMAs within the segment.  Be		\ | 		   <= (segment)->p_filesz - 1))				\ | ||||||
|       careful about segments right at the end of memory.  */		\ | 	   && (((sec_hdr)->sh_offset - (segment)->p_offset		\ | ||||||
|  | 		+ ELF_SECTION_SIZE(sec_hdr, segment))			\ | ||||||
|  | 	       <= (segment)->p_filesz)))				\ | ||||||
|  |    /* SHF_ALLOC sections must have VMAs within the segment.  */		\ | ||||||
|    && (!(check_vma)							\ |    && (!(check_vma)							\ | ||||||
|        || ((sec_hdr)->sh_flags & SHF_ALLOC) == 0			\ |        || ((sec_hdr)->sh_flags & SHF_ALLOC) == 0			\ | ||||||
|        || ((sec_hdr)->sh_addr >= (segment)->p_vaddr			\ |        || ((sec_hdr)->sh_addr >= (segment)->p_vaddr			\ | ||||||
| 	   && ((sec_hdr)->sh_addr - (segment)->p_vaddr			\ | 	   && (!(strict)						\ | ||||||
| 	       + ELF_SECTION_SIZE(sec_hdr, segment) <= (segment)->p_memsz)))) | 	       || ((sec_hdr)->sh_addr - (segment)->p_vaddr		\ | ||||||
|  | 		   <= (segment)->p_memsz - 1))				\ | ||||||
|  | 	   && (((sec_hdr)->sh_addr - (segment)->p_vaddr			\ | ||||||
|  | 		+ ELF_SECTION_SIZE(sec_hdr, segment))			\ | ||||||
|  | 	       <= (segment)->p_memsz)))) | ||||||
|  |  | ||||||
| #define ELF_SECTION_IN_SEGMENT(sec_hdr, segment)			\ | #define ELF_SECTION_IN_SEGMENT(sec_hdr, segment)			\ | ||||||
|   (ELF_SECTION_IN_SEGMENT_1 (sec_hdr, segment, 1)) |   (ELF_SECTION_IN_SEGMENT_1 (sec_hdr, segment, 1, 0)) | ||||||
|  |  | ||||||
|  | #define ELF_SECTION_IN_SEGMENT_STRICT(sec_hdr, segment)			\ | ||||||
|  |   (ELF_SECTION_IN_SEGMENT_1 (sec_hdr, segment, 1, 1)) | ||||||
|  |  | ||||||
| #endif /* _ELF_INTERNAL_H */ | #endif /* _ELF_INTERNAL_H */ | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user