aboutsummaryrefslogtreecommitdiff
path: root/include/elf
diff options
context:
space:
mode:
authorAlan Modra <amodra@gmail.com>2010-04-24 01:05:25 +0000
committerAlan Modra <amodra@gmail.com>2010-04-24 01:05:25 +0000
commit9a83a5533e5c082e2555505e7290456e4eb6afcb (patch)
treeb5553fbdfd6eff8e95ab9d699f574b8799071cdb /include/elf
parent2cd2156f48361fa342ce1ad18cead5cae6ce4af5 (diff)
downloadgdb-9a83a5533e5c082e2555505e7290456e4eb6afcb.zip
gdb-9a83a5533e5c082e2555505e7290456e4eb6afcb.tar.gz
gdb-9a83a5533e5c082e2555505e7290456e4eb6afcb.tar.bz2
include/elf/
* internal.h (ELF_SECTION_SIZE): Protect macro args with parentheses. Invert logic to clarify test for .tbss. (ELF_IS_SECTION_IN_SEGMENT): Rename to.. (ELF_SECTION_IN_SEGMENT_1): ..this. Add check_vma param. Protect macro args with parentheses. (ELF_SECTION_IN_SEGMENT): Define. (ELF_IS_SECTION_IN_SEGMENT_FILE): Delete. (ELF_IS_SECTION_IN_SEGMENT_MEMORY): Delete. bfd/ * elf.c: Replace use of ELF_IS_SECTION_IN_SEGMENT and ELF_IS_SECTION_IN_SEGMENT_FILE with ELF_SECTION_IN_SEGMENT throughout file. (assign_file_positions_for_load_sections): Modify section in segment warning to ignore overlay vmas. * elf32-spu.c (spu_elf_object_p): Replace use of ELF_IS_SECTION_IN_SEGMENT_MEMORY with ELF_SECTION_IN_SEGMENT. binutils/ * readelf.c (process_program_headers): Replace use of ELF_IS_SECTION_IN_SEGMENT_MEMORY with ELF_SECTION_IN_SEGMENT.
Diffstat (limited to 'include/elf')
-rw-r--r--include/elf/ChangeLog11
-rw-r--r--include/elf/internal.h52
2 files changed, 34 insertions, 29 deletions
diff --git a/include/elf/ChangeLog b/include/elf/ChangeLog
index 49be1e1..b65c881 100644
--- a/include/elf/ChangeLog
+++ b/include/elf/ChangeLog
@@ -1,3 +1,14 @@
+2010-04-23 Alan Modra <amodra@gmail.com>
+
+ * internal.h (ELF_SECTION_SIZE): Protect macro args with parentheses.
+ Invert logic to clarify test for .tbss.
+ (ELF_IS_SECTION_IN_SEGMENT): Rename to..
+ (ELF_SECTION_IN_SEGMENT_1): ..this. Add check_vma param. Protect
+ macro args with parentheses.
+ (ELF_SECTION_IN_SEGMENT): Define.
+ (ELF_IS_SECTION_IN_SEGMENT_FILE): Delete.
+ (ELF_IS_SECTION_IN_SEGMENT_MEMORY): Delete.
+
2010-04-15 Matthew Gretton-Dann <matthew.gretton-dann@arm.com>
* arm.h (Tag_FP_arch, Tag_ABI_align_needed, Tag_ABI_align_preserved,
diff --git a/include/elf/internal.h b/include/elf/internal.h
index 06e7266..1dd336d 100644
--- a/include/elf/internal.h
+++ b/include/elf/internal.h
@@ -292,42 +292,36 @@ struct elf_segment_map
/* .tbss is special. It doesn't contribute memory space to normal
segments and it doesn't take file space in normal segments. */
#define ELF_SECTION_SIZE(sec_hdr, segment) \
- (((sec_hdr->sh_flags & SHF_TLS) == 0 \
- || sec_hdr->sh_type != SHT_NOBITS \
- || segment->p_type == PT_TLS) ? sec_hdr->sh_size : 0)
+ ((!(((sec_hdr)->sh_flags & SHF_TLS) != 0 \
+ && (sec_hdr)->sh_type == SHT_NOBITS) \
+ || (segment)->p_type == PT_TLS) ? (sec_hdr)->sh_size : 0)
/* Decide if the given sec_hdr is in the given segment. PT_TLS segment
contains only SHF_TLS sections. Only PT_LOAD, PT_GNU_RELRO and
and PT_TLS segments can contain SHF_TLS sections. */
-#define ELF_IS_SECTION_IN_SEGMENT(sec_hdr, segment) \
- (((((sec_hdr->sh_flags & SHF_TLS) != 0) \
- && (segment->p_type == PT_TLS \
- || segment->p_type == PT_GNU_RELRO \
- || segment->p_type == PT_LOAD)) \
- || ((sec_hdr->sh_flags & SHF_TLS) == 0 \
- && segment->p_type != PT_TLS \
- && segment->p_type != PT_PHDR)) \
+#define ELF_SECTION_IN_SEGMENT_1(sec_hdr, segment, check_vma) \
+ ((((((sec_hdr)->sh_flags & SHF_TLS) != 0) \
+ && ((segment)->p_type == PT_TLS \
+ || (segment)->p_type == PT_GNU_RELRO \
+ || (segment)->p_type == PT_LOAD)) \
+ || (((sec_hdr)->sh_flags & SHF_TLS) == 0 \
+ && (segment)->p_type != PT_TLS \
+ && (segment)->p_type != PT_PHDR)) \
/* Any section besides one of type SHT_NOBITS must have a file \
offset within the segment. */ \
- && (sec_hdr->sh_type == SHT_NOBITS \
- || ((bfd_vma) sec_hdr->sh_offset >= segment->p_offset \
- && (sec_hdr->sh_offset + ELF_SECTION_SIZE(sec_hdr, segment) \
- <= segment->p_offset + segment->p_filesz))) \
+ && ((sec_hdr)->sh_type == SHT_NOBITS \
+ || ((bfd_vma) (sec_hdr)->sh_offset >= (segment)->p_offset \
+ && ((sec_hdr)->sh_offset + ELF_SECTION_SIZE(sec_hdr, segment) \
+ <= (segment)->p_offset + (segment)->p_filesz))) \
/* SHF_ALLOC sections must have VMAs within the segment. Be \
careful about segments right at the end of memory. */ \
- && ((sec_hdr->sh_flags & SHF_ALLOC) == 0 \
- || (sec_hdr->sh_addr >= segment->p_vaddr \
- && (sec_hdr->sh_addr - segment->p_vaddr \
- + ELF_SECTION_SIZE(sec_hdr, segment) <= segment->p_memsz))))
-
-/* 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 \
- && ELF_IS_SECTION_IN_SEGMENT (sec_hdr, segment))
-
-/* Decide if the given sec_hdr is in the given segment in memory. */
-#define ELF_IS_SECTION_IN_SEGMENT_MEMORY(sec_hdr, segment) \
- (ELF_SECTION_SIZE(sec_hdr, segment) > 0 \
- && ELF_IS_SECTION_IN_SEGMENT (sec_hdr, segment))
+ && (!(check_vma) \
+ || ((sec_hdr)->sh_flags & SHF_ALLOC) == 0 \
+ || ((sec_hdr)->sh_addr >= (segment)->p_vaddr \
+ && ((sec_hdr)->sh_addr - (segment)->p_vaddr \
+ + ELF_SECTION_SIZE(sec_hdr, segment) <= (segment)->p_memsz))))
+
+#define ELF_SECTION_IN_SEGMENT(sec_hdr, segment) \
+ (ELF_SECTION_IN_SEGMENT_1 (sec_hdr, segment, 1))
#endif /* _ELF_INTERNAL_H */