bfd_vma high = sec->vma + sec->size;
unsigned alignment;
- if (!c64_valid_cap_range (&low, &high, &alignment))
+ if (!c64_valid_cap_range (&low, &high, &alignment)
+ || sec->alignment_power < alignment)
queue_section_padding (queue, sec);
}
if (!c64_valid_cap_range (&low, &high, &align))
{
- if (queue->sec->alignment_power < align)
- queue->sec->alignment_power = align;
-
padding = high - low - queue->sec->size;
if (queue->sec != pcc_high_sec)
padding = 0;
}
}
+ if (queue->sec->alignment_power < align)
+ queue->sec->alignment_power = align;
/* If we have crossed all sections within the PCC range, set up alignment
and padding for the PCC range. */
if (!c64_valid_cap_range (&pcc_low, &pcc_high, &align))
{
- if (pcc_low_sec->alignment_power < align)
- pcc_low_sec->alignment_power = align;
-
bfd_vma current_length =
(pcc_high_sec->vma + pcc_high_sec->size) - pcc_low_sec->vma;
bfd_vma desired_length = (pcc_high - pcc_low);
padding = desired_length - current_length;
c64_pad_section (pcc_high_sec, padding);
}
+ if (pcc_low_sec->alignment_power < align)
+ pcc_low_sec->alignment_power = align;
}
(*htab->layout_sections_again) ();
--- /dev/null
+#as: -march=morello+c64
+#ld: -static -T morello-sec-round-adjust.ld
+#objdump: -x
+#...
+Sections:
+Idx Name Size VMA LMA File off Algn
+#...
+ 0 \.text 00000100 0000000000000080 [0-9a-f]+ [0-9a-f]+ 2\*\*4
+ CONTENTS, ALLOC, LOAD, READONLY, CODE
+ 1 \.data\.rel\.ro 00008000 0000000000000180 [0-9a-f]+ [0-9a-f]+ 2\*\*4
+ CONTENTS, ALLOC, LOAD, DATA
+ 2 \.got 00000030 0000000000008180 [0-9a-f]+ [0-9a-f]+ 2\*\*4
+ CONTENTS, ALLOC, LOAD, DATA
+ 3 \.got\.plt 00000030 00000000000081b0 [0-9a-f]+ [0-9a-f]+ 2\*\*4
+ CONTENTS, ALLOC, LOAD, DATA
+ 4 \.rela\.dyn 000000b8 00000000000081e0 [0-9a-f]+ [0-9a-f]+ 2\*\*3
+ CONTENTS, ALLOC, LOAD, READONLY, DATA
+#pass
+
+
--- /dev/null
+SECTIONS {
+ . = SIZEOF_HEADERS;
+ .text :
+ {
+ *(.text)
+ }
+ .data.rel.ro :
+ {
+ __data_rel_ro_startsym = .;
+ *(.data.rel.ro)
+ }
+ .got : { *(.got) }
+ .iplt : { *(.iplt) }
+ .data : { *(.data) }
+ .rela.dyn : { *(.rela.dyn) }
+ .interp : { *(.interp) }
+}
--- /dev/null
+.text
+__start:
+ # Use a GOT relocation because the linker currently doesn't do the
+ # padding and alignment unless we have GOT relocations. This is
+ # another linker bug that we need to fix.
+ adrp c0, :got:__data_rel_ro_startsym
+ ret
+.zero 0x0f8
+.section .data.rel.ro,"aw",@progbits
+# We use a linker defined symbol that points into .data.rel.ro so that the
+# linker will need to ensure this section is aligned and padded so that its
+# bounds can be precisely represented by a capability. This is done in the
+# linker script.
+#
+# Here we ensure that the size of the section is large enough that it will need
+# padding.
+.zero 0x8000
+.section .got,"aw",@progbits
+.capinit __data_rel_ro_startsym
+.xword 0
+.xword 0
+