Commit: --rosegment: Restore alignment of text segment

Nick Clifton nickc@redhat.com
Tue Jun 18 08:14:49 GMT 2024


Hi Guys,

  *sigh* I have found another snafu with my --rosegment feature.
  I had disabled the alignment of the text segment in the on-disk
  image, on the assumption that the loader would be able to load
  a partial page into memory.  In turns out however that this is
  not correct, and that data following the text segment in the
  on-disk image can be loaded into the executable segment in
  memory.

  So I am checking in this patch to restore the alignment of the
  text segment in the on-disk image.  Which means that the file
  size increase when using '-z separate-code' is not alleviated
  as much. (It can still be slightly improved since --rosegment
  reduces the number of data segments).

Cheers
  Nick

diff --git a/ld/scripttempl/elf.sc b/ld/scripttempl/elf.sc
index f1a61e7bcee..54716110b61 100644
--- a/ld/scripttempl/elf.sc
+++ b/ld/scripttempl/elf.sc
@@ -372,7 +372,7 @@ if test -z "$TINY_READONLY_SECTION"; then
     *ro*textonly*)
       ALL_TEXT_BEFORE_RO=" "
       SEPARATE_TEXT=" "
-      TEXT_SEGMENT_ALIGN=
+      TEXT_SEGMENT_ALIGN=". = ALIGN(${MAXPAGESIZE});"
       ;;
     *textonly*)
       SEPARATE_TEXT=" "



More information about the Binutils mailing list