Before this they would span sections which are SEC_CODE or some specific known sections like the GOT and PLT.
This is not enough, since the compiler can want to access .rodata via relative offsets to PCC. Hence we need to include READONLY sections.
Similarly, we want to include .data.rel.ro sections in the PCC bounds so that they can be accessed via PCC -- this allows the capability indirection table to be accessed.
We have not been noticing this until now because the default linker script happens to order sections such that the PCC being required to span .got and .text happens to end up including these problematic sections.
RELRO sections are a bit interesting since the fact they are RELRO is not recorded anywhere on the section itself. Rather it is stored in the fact that the section is covered by the RELRO segment.
This means that we need to check if the sections VMA is within the relevant range rather than just look at the section. This turns out to be pretty easy since we have a structure containing the RELRO range, however we do need to ensure that we don't mix up the uses of the section VMA and the RELRO start and end around calls of layout_sections_again since this call can change both.
############### Attachment also inlined for ease of reply ###############
diff --git a/bfd/elfnn-aarch64.c b/bfd/elfnn-aarch64.c index c44e7aa458e2d28f2fefe1ec754482923c448d69..f33388629164b59e07cdbac7bb4bce82e2f62b8b 100644 --- a/bfd/elfnn-aarch64.c +++ b/bfd/elfnn-aarch64.c @@ -4997,12 +4997,16 @@ elfNN_c64_resize_sections (bfd *output_bfd, struct bfd_link_info *info,
#define NOT_OP_SECTION(s) ((s) == NULL || (s)->output_section != sec)
- if ((sec->flags & SEC_CODE) == 0 + if ((sec->flags & SEC_READONLY) == 0 && NOT_OP_SECTION (htab->root.sgotplt) && NOT_OP_SECTION (htab->root.igotplt) && NOT_OP_SECTION (htab->root.sgot) && NOT_OP_SECTION (htab->root.splt) - && NOT_OP_SECTION (htab->root.iplt)) + && NOT_OP_SECTION (htab->root.iplt) + && (sec->vma < info->relro_start + || sec->vma >= info->relro_end)) + continue; + if ((sec->flags & SEC_ALLOC) == 0) continue;
if (sec->vma < low)
gnu-morello@op-lists.linaro.org