summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorH.J. Lu <hjl.tools@gmail.com>2006-02-10 15:04:19 +0000
committerH.J. Lu <hjl.tools@gmail.com>2006-02-10 15:04:19 +0000
commit2bf61bfe9b48cedfa558483f08891ede634b4dce (patch)
treebfd07ae9602569b22280eaa6a50aa36f5ff1d744
parent30f1c8a675f8fe65ecc0ea06dd7ce1eb50b4b3b7 (diff)
downloadcygnal-2bf61bfe9b48cedfa558483f08891ede634b4dce.tar.gz
cygnal-2bf61bfe9b48cedfa558483f08891ede634b4dce.tar.bz2
cygnal-2bf61bfe9b48cedfa558483f08891ede634b4dce.zip
bfd/
2006-02-10 H.J. Lu <hongjiu.lu@intel.com> PR binutils/2258 * elf.c (copy_private_bfd_data): Renamed to ... (rewrite_elf_program_header): This. (copy_elf_program_header): New function. (copy_private_bfd_data): Likewise. binutils/ 2006-02-10 H.J. Lu <hongjiu.lu@intel.com> PR binutils/2258 * readelf.c (process_program_headers): Use ELF_IS_SECTION_IN_SEGMENT_MEMORY. include/elf/ 2006-02-10 H.J. Lu <hongjiu.lu@intel.com> PR binutils/2258 * internal.h (ELF_IS_SECTION_IN_SEGMENT_FILE): New. (ELF_IS_SECTION_IN_SEGMENT_MEMORY): Likewise.
-rw-r--r--include/elf/ChangeLog6
-rw-r--r--include/elf/internal.h25
2 files changed, 31 insertions, 0 deletions
diff --git a/include/elf/ChangeLog b/include/elf/ChangeLog
index fca9b33e3..bd1418177 100644
--- a/include/elf/ChangeLog
+++ b/include/elf/ChangeLog
@@ -1,3 +1,9 @@
+2006-02-10 H.J. Lu <hongjiu.lu@intel.com>
+
+ PR binutils/2258
+ * internal.h (ELF_IS_SECTION_IN_SEGMENT_FILE): New.
+ (ELF_IS_SECTION_IN_SEGMENT_MEMORY): Likewise.
+
2006-02-07 Nathan Sidwell <nathan@codesourcery.com>
* m68k.h (EF_CPU32, EF_M68000, EF_CFV4E): Rename to ...
diff --git a/include/elf/internal.h b/include/elf/internal.h
index 7e13d54a9..e4eba7d6c 100644
--- a/include/elf/internal.h
+++ b/include/elf/internal.h
@@ -251,4 +251,29 @@ struct elf_segment_map
asection *sections[1];
};
+/* Decide if the given sec_hdr is in the given segment in file. */
+#define ELF_IS_SECTION_IN_SEGMENT_FILE(sec_hdr, segment) \
+ (sec_hdr->sh_size > 0 \
+ /* PT_TLS segment contains only SHF_TLS sections. */ \
+ && (segment->p_type != PT_TLS \
+ || (sec_hdr->sh_flags & SHF_TLS) != 0) \
+ /* Compare allocated sec_hdrs by VMA, unallocated sec_hdrs \
+ by file offset. */ \
+ && (sec_hdr->sh_flags & SHF_ALLOC \
+ ? (sec_hdr->sh_addr >= segment->p_vaddr \
+ && sec_hdr->sh_addr + sec_hdr->sh_size \
+ <= segment->p_vaddr + segment->p_memsz) \
+ : ((bfd_vma) sec_hdr->sh_offset >= segment->p_offset \
+ && (sec_hdr->sh_offset + sec_hdr->sh_size \
+ <= segment->p_offset + segment->p_filesz))))
+
+/* Decide if the given sec_hdr is in the given segment in memory. */
+#define ELF_IS_SECTION_IN_SEGMENT_MEMORY(sec_hdr, segment) \
+ (ELF_IS_SECTION_IN_SEGMENT_FILE (sec_hdr, segment) \
+ /* .tbss is special. It doesn't contribute memory space to \
+ normal segments. */ \
+ && (!((sec_hdr->sh_flags & SHF_TLS) != 0 \
+ && sec_hdr->sh_type == SHT_NOBITS) \
+ || segment->p_type == PT_TLS))
+
#endif /* _ELF_INTERNAL_H */