H.J. Lu
2018-09-20 18:03:30 UTC
We shouldn't include zero size sections at start of PT_NOTE segment,
similar to PT_DYNAMIC segment.
PR binutils/23694
* include/elf/internal.h (ELF_SECTION_IN_SEGMENT_1): Don't
include zero size sections at start of PT_NOTE segment.
---
include/elf/internal.h | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)
diff --git a/include/elf/internal.h b/include/elf/internal.h
index 05f9fab89c..0d96f0c196 100644
--- a/include/elf/internal.h
+++ b/include/elf/internal.h
@@ -311,8 +311,8 @@ struct elf_segment_map
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. Regardless of STRICT and CHECK_VMA, zero size
- sections won't match at the start or end of PT_DYNAMIC, unless
- PT_DYNAMIC is itself zero sized. */
+ sections won't match at the start or end of PT_DYNAMIC nor PT_NOTE,
+ unless PT_DYNAMIC and PT_NOTE are themselves zero sized. */
#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. */ \
@@ -352,8 +352,10 @@ struct elf_segment_map
&& (((sec_hdr)->sh_addr - (segment)->p_vaddr \
+ ELF_SECTION_SIZE(sec_hdr, segment)) \
<= (segment)->p_memsz))) \
- /* No zero size sections at start or end of PT_DYNAMIC. */ \
- && ((segment)->p_type != PT_DYNAMIC \
+ /* No zero size sections at start or end of PT_DYNAMIC nor \
+ PT_NOTE. */ \
+ && (((segment)->p_type != PT_DYNAMIC \
+ && (segment)->p_type != PT_NOTE) \
|| (sec_hdr)->sh_size != 0 \
|| (segment)->p_memsz == 0 \
|| (((sec_hdr)->sh_type == SHT_NOBITS \
similar to PT_DYNAMIC segment.
PR binutils/23694
* include/elf/internal.h (ELF_SECTION_IN_SEGMENT_1): Don't
include zero size sections at start of PT_NOTE segment.
---
include/elf/internal.h | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)
diff --git a/include/elf/internal.h b/include/elf/internal.h
index 05f9fab89c..0d96f0c196 100644
--- a/include/elf/internal.h
+++ b/include/elf/internal.h
@@ -311,8 +311,8 @@ struct elf_segment_map
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. Regardless of STRICT and CHECK_VMA, zero size
- sections won't match at the start or end of PT_DYNAMIC, unless
- PT_DYNAMIC is itself zero sized. */
+ sections won't match at the start or end of PT_DYNAMIC nor PT_NOTE,
+ unless PT_DYNAMIC and PT_NOTE are themselves zero sized. */
#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. */ \
@@ -352,8 +352,10 @@ struct elf_segment_map
&& (((sec_hdr)->sh_addr - (segment)->p_vaddr \
+ ELF_SECTION_SIZE(sec_hdr, segment)) \
<= (segment)->p_memsz))) \
- /* No zero size sections at start or end of PT_DYNAMIC. */ \
- && ((segment)->p_type != PT_DYNAMIC \
+ /* No zero size sections at start or end of PT_DYNAMIC nor \
+ PT_NOTE. */ \
+ && (((segment)->p_type != PT_DYNAMIC \
+ && (segment)->p_type != PT_NOTE) \
|| (sec_hdr)->sh_size != 0 \
|| (segment)->p_memsz == 0 \
|| (((sec_hdr)->sh_type == SHT_NOBITS \
--
2.17.1
2.17.1