mmix ld: move .init (and _init) first.
authorHans-Peter Nilsson <hp@bitrange.com>
Thu, 16 Jul 2020 22:55:13 +0000 (00:55 +0200)
committerHans-Peter Nilsson <hp@bitrange.com>
Thu, 16 Jul 2020 22:56:17 +0000 (00:56 +0200)
This both makes the section layout more similar to that of the general
default for ELF and fixes (makes true) an assumption that code and
rodata is located between _init and __etext, in
libgcc/config/mmix/crti.S.  Sadly, that's not actually true for ELF
(generally and for elf64mmix), where exception-tables and .rodata is
after _etext; I'm pondering what to do about that.

The original mmix simulator behavior is that memory magically appears
on access, initialized with 0, which is not preferable when chasing
bugs by throwing code the size of the gcc test-suite to the simulator.
The code in crti.S compatibly enables simulator machinery to identify
undefined memory and instead stopping the simulator with an error
(going to interactive mode for interactive runs).  See
http://gcc.gnu.org/legacy-ml/gcc-patches/2012-10/msg01871.html for
more, including the mmix-sim.ch "patch file".

This fixes only one error in the gcc testsuite,
gcc.c-torture/execute/pr20621-1.c with LTO, where for some reason
gcc/lto chooses to move (writable) data that is only used to read 0 to
.rodata.  An access (sufficiently far inside a block) in an
unregistered place is flagged as an invalid access.

The bpo-9m test that I had to adjust, actually exposes a wart: mmo
does not have the notion of symbol types (or sections) and the
test-case now has leading zeros at "Main" eventually leading to it
being misdiagnosed as being outside .text and .data, thus here mapped
to BFD as an absolute symbol.  The test is not intended to check the
mmo symbol-type machinery, so I'm just tweaking it to be
symbol-type-neutral for "Main".

Since you have to jump through hoops to see the problem, I don't think
this commit is worth putting on the 2.35-branch.

ld:
* scripttempt/mmo.sc: Move .init first in .text output section.
* testsuite/ld-mmix/bpo-9m.d: Adjust accordingly.

ld/ChangeLog
ld/scripttempl/mmo.sc
ld/testsuite/ld-mmix/bpo-9m.d

index 3d8b8d663eda0bc5546a5595bf22fd1ad4e4e4c4..32b4616dfad43e763c8226d066c62949289580a1 100644 (file)
@@ -1,3 +1,8 @@
+2020-07-17  Hans-Peter Nilsson  <hp@bitrange.com>
+
+       * scripttempt/mmo.sc: Move .init first in .text output section.
+       * testsuite/ld-mmix/bpo-9m.d: Adjust accordingly.
+
 2020-07-15  Jan Beulich  <jbeulich@suse.com>
 
        * testsuite/ld-i386/ibt-plt-1.d, testsuite/ld-i386/ibt-plt-2a.d,
index c3992788fbead31dc0c4157fa82483849ff8dc41..354a76964e7d35e073bfdd7cfa9635ff646fe81a 100644 (file)
@@ -24,6 +24,12 @@ SECTIONS
 {
   .text ${RELOCATING+ ${TEXT_START_ADDR}}:
   {
+    /* FIXME: Move .init, .fini, .ctors and .dtors to their own sections.  */
+    ${RELOCATING+ PROVIDE (_init_start = .);}
+    ${RELOCATING+ PROVIDE (_init = .);}
+    ${RELOCATING+ KEEP (*(SORT_NONE(.init)))}
+    ${RELOCATING+ PROVIDE (_init_end = .);}
+
     *(.text)
     ${RELOCATING+*(.text.*)}
     ${RELOCATING+*(.gnu.linkonce.t*)}
@@ -31,12 +37,6 @@ SECTIONS
     ${RELOCATING+*(.rodata.*)}
     ${RELOCATING+*(.gnu.linkonce.r*)}
 
-    /* FIXME: Move .init, .fini, .ctors and .dtors to their own sections.  */
-    ${RELOCATING+ PROVIDE (_init_start = .);}
-    ${RELOCATING+ PROVIDE (_init = .);}
-    ${RELOCATING+ KEEP (*(SORT_NONE(.init)))}
-    ${RELOCATING+ PROVIDE (_init_end = .);}
-
     ${RELOCATING+ PROVIDE (_fini_start = .);}
     ${RELOCATING+ PROVIDE (_fini = .);}
     ${RELOCATING+ KEEP (*(SORT_NONE(.fini)))}
index fa3f97c289758bfb3a52a179f2a33304c648d212..eb53f6b57029982f9c3d051adcf6d64b990d0f1e 100644 (file)
 .*:     file format mmo
 
 SYMBOL TABLE:
-0+ g       \.text Main
-0+4 g       \.text x
-0+ g       \.text x2
+0+ g .* Main
+0+14 g       \.text x
+0+10 g       \.text x2
 
 Contents of section \.text:
- 0000 232dfe00 232dfd00 00000000 0000002d  .*
- 0010 00000000 0000002a                    .*
+ 0004 0000003d 00000000 0000003a 232dfe00  .*
+ 0014 232dfd00                             .*
 Contents of section \.MMIX\.reg_contents:
- 07e8 00000000 0000106c 00000000 0000a410  .*
+ 07e8 00000000 0000107c 00000000 0000a420  .*
This page took 0.028123 seconds and 4 git commands to generate.