From 4609ada49f559880e85aecc2f37f377e5bff8696 Mon Sep 17 00:00:00 2001 From: Hans-Peter Nilsson Date: Sun, 19 Jul 2020 06:08:07 +0200 Subject: [PATCH] ld: optionally emit _etext last, before .data So, here's my suggestion for making _init .. __etext cover .text + .rodata (including things like the read-only exception tables) for elf64mmix. A quick web search gives that __etext (and friends) isn't well defined, so each target can interpret the "end of text segment" to their own liking. It seems likely this change is also a better fit than the default for other ports, at least those with .rodata after .text in the same segment. The presence of a separate rodata-segment is optional (and not true for elf64mmix). This is reflected in the name as SEPARATE_TEXT / SEPARATE_CODE isn't considered, to keep it simple; each target has to make sure their settings of variables make sense. ld: * scripttempl/elf.sc (ETEXT_LAST_IN_RODATA_SEGMENT): New variable. * emulparams/elf64mmix.sh (ETEXT_LAST_IN_RODATA_SEGMENT): Define. * testsuite/ld-mmix/sec-1.d: Adjust. --- ld/ChangeLog | 6 ++++++ ld/emulparams/elf64mmix.sh | 4 ++++ ld/scripttempl/elf.sc | 13 ++++++++++--- ld/testsuite/ld-mmix/sec-1.d | 2 +- 4 files changed, 21 insertions(+), 4 deletions(-) diff --git a/ld/ChangeLog b/ld/ChangeLog index 51a4e9c53bd..37a94aa8806 100644 --- a/ld/ChangeLog +++ b/ld/ChangeLog @@ -1,3 +1,9 @@ +2020-07-19 Hans-Peter Nilsson + + * scripttempl/elf.sc (ETEXT_LAST_IN_RODATA_SEGMENT): New variable. + * emulparams/elf64mmix.sh (ETEXT_LAST_IN_RODATA_SEGMENT): Define. + * testsuite/ld-mmix/sec-1.d: Adjust. + 2020-07-19 Alan Modra * emultempl/ppc64elf.em (power10-stubs): Accept optional "auto" arg. diff --git a/ld/emulparams/elf64mmix.sh b/ld/emulparams/elf64mmix.sh index dffc6cc6f7d..75e24be2e2a 100644 --- a/ld/emulparams/elf64mmix.sh +++ b/ld/emulparams/elf64mmix.sh @@ -44,6 +44,10 @@ ${RELOCATING+ PROVIDE (Main = DEFINED (Main) ? Main : (DEFINED (_start) ? _start : _start.)); }" +# We need a symbol at the end of the read-only data, which is +# colocated with the code. We make __etext fit. +ETEXT_LAST_IN_RODATA_SEGMENT=" " + OTHER_SECTIONS=' .MMIX.reg_contents : { diff --git a/ld/scripttempl/elf.sc b/ld/scripttempl/elf.sc index 0b8b32a4407..eb74743e5c3 100644 --- a/ld/scripttempl/elf.sc +++ b/ld/scripttempl/elf.sc @@ -62,6 +62,9 @@ # OTHER_SYMBOLS - symbols to place right at the end of the script. # ETEXT_NAME - name of a symbol for the end of the text section, # normally etext. +# ETEXT_LAST_IN_RODATA_SEGMENT - emit ETEXT_NAME after all sections in +# the read-only data segment (which may or may not be equal to +# the code segment), instead of after just the code parts. # SEPARATE_CODE - if set, .text and similar sections containing # actual machine instructions must be in wholly disjoint # pages from any other data, including headers @@ -526,9 +529,9 @@ cat <