+2018-02-19 Alan Modra <amodra@gmail.com>
+
+ PR 22845
+ * elf.c (IS_TBSS): Define.
+ (_bfd_elf_map_sections_to_segments): Use IS_TBSS.
+ (assign_file_positions_for_non_load_sections): Revert last change.
+ Properly calculate load segment limits to compare against relro limits.
+
2018-02-17 Alan Modra <amodra@gmail.com>
PR 22845
return TRUE;
}
+#define IS_TBSS(s) \
+ ((s->flags & (SEC_THREAD_LOCAL | SEC_LOAD)) == SEC_THREAD_LOCAL)
+
/* Set up a mapping from BFD sections to program segments. */
bfd_boolean
executable = TRUE;
last_hdr = hdr;
/* .tbss sections effectively have zero size. */
- if ((hdr->flags & (SEC_THREAD_LOCAL | SEC_LOAD))
- != SEC_THREAD_LOCAL)
- last_size = hdr->size;
- else
- last_size = 0;
+ last_size = !IS_TBSS (hdr) ? hdr->size : 0;
continue;
}
last_hdr = hdr;
/* .tbss sections effectively have zero size. */
- if ((hdr->flags & (SEC_THREAD_LOCAL | SEC_LOAD)) != SEC_THREAD_LOCAL)
- last_size = hdr->size;
- else
- last_size = 0;
+ last_size = !IS_TBSS (hdr) ? hdr->size : 0;
phdr_index = i;
phdr_in_segment = FALSE;
}
for .tbss. */
if (last_hdr != NULL
&& (i - phdr_index != 1
- || ((last_hdr->flags & (SEC_THREAD_LOCAL | SEC_LOAD))
- != SEC_THREAD_LOCAL)))
+ || !IS_TBSS (last_hdr)))
{
m = make_mapping (abfd, sections, phdr_index, i, phdr_in_segment);
if (m == NULL)
lm = lm->next, lp++)
{
if (lp->p_type == PT_LOAD
- && lp->p_memsz != 0
&& lm->count != 0
- && lm->sections[lm->count - 1]->vma >= start
+ && (lm->sections[lm->count - 1]->vma
+ + (!IS_TBSS (lm->sections[lm->count - 1])
+ ? lm->sections[lm->count - 1]->size
+ : 0)) > start
&& lm->sections[0]->vma < end)
break;
}