From 022c1ffc94282eb8937145b07ac22e0995d749b5 Mon Sep 17 00:00:00 2001 From: "H.J. Lu" Date: Thu, 1 Jun 2006 05:40:24 +0000 Subject: include/elf/ 2006-05-31 H.J. Lu * internal.h (ELF_SECTION_SIZE): New. (ELF_IS_SECTION_IN_SEGMENT): Likewise. (ELF_IS_SECTION_IN_SEGMENT_FILE): Updated. (ELF_IS_SECTION_IN_SEGMENT_MEMORY): Likewise. ld/testsuite/ 2006-05-31 H.J. Lu * ld-elf/binutils.exp: Make it Linux only. (strip_test): Renamed to binutils_test. Check for unsupported options. Add more tests. * ld-elf/commonpage1.d: Make it Linux only. * ld-elf/maxpage1.d: Likewise. * ld-elf/maxpage1.s: Add main, start and __start. * ld-elf/maxpage2.d: New file. * ld-elf/tbss1.s: Likewise. * ld-elf/tbss2.s: Likewise. * ld-elf/tdata1.s: Likewise. * ld-elf/tdata2.s: Likewise. --- include/elf/ChangeLog | 7 +++++++ include/elf/internal.h | 43 ++++++++++++++++++++++++++++--------------- 2 files changed, 35 insertions(+), 15 deletions(-) (limited to 'include/elf') diff --git a/include/elf/ChangeLog b/include/elf/ChangeLog index fb3476cf6..285457ed9 100644 --- a/include/elf/ChangeLog +++ b/include/elf/ChangeLog @@ -1,3 +1,10 @@ +2006-05-31 H.J. Lu + + * internal.h (ELF_SECTION_SIZE): New. + (ELF_IS_SECTION_IN_SEGMENT): Likewise. + (ELF_IS_SECTION_IN_SEGMENT_FILE): Updated. + (ELF_IS_SECTION_IN_SEGMENT_MEMORY): Likewise. + 2006-05-27 H.J. Lu * internal.h (struct elf_segment_map): Add p_align and p_align_valid. diff --git a/include/elf/internal.h b/include/elf/internal.h index ff27c88bd..d368a3fa6 100644 --- a/include/elf/internal.h +++ b/include/elf/internal.h @@ -256,29 +256,42 @@ 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) \ +/* .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) + +/* Decide if the given sec_hdr is in the given segment. PT_TLS segment + contains only SHF_TLS sections. Only PT_LOAD 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_LOAD)) \ + || ((sec_hdr->sh_flags & SHF_TLS) == 0 \ + && segment->p_type != PT_TLS)) \ /* 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) \ + && (sec_hdr->sh_addr \ + + ELF_SECTION_SIZE(sec_hdr, segment) \ + <= segment->p_vaddr + segment->p_memsz)) \ : ((bfd_vma) sec_hdr->sh_offset >= segment->p_offset \ - && (sec_hdr->sh_offset + sec_hdr->sh_size \ + && (sec_hdr->sh_offset \ + + ELF_SECTION_SIZE(sec_hdr, segment) \ <= segment->p_offset + segment->p_filesz)))) +/* 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_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)) + (ELF_SECTION_SIZE(sec_hdr, segment) > 0 \ + && ELF_IS_SECTION_IN_SEGMENT (sec_hdr, segment)) #endif /* _ELF_INTERNAL_H */ -- cgit v1.2.3