This is the mail archive of the
newlib@sourceware.org
mailing list for the newlib project.
RFA: RX: Move init functions into .text section
- From: Nick Clifton <nickc at redhat dot com>
- To: dj at redhat dot com
- Cc: newlib at sourceware dot org
- Date: Wed, 04 Nov 2015 16:25:28 +0000
- Subject: RFA: RX: Move init functions into .text section
- Authentication-results: sourceware.org; auth=none
Hi DJ,
Current the RX linker script in libgloss/rx puts the language
initialisation arrays into the .data section. The patch below moves
them into the .text section. This matters when running on an RX in
big-endian-data mode since byte swapping is different for data and
code.
OK to apply ?
Cheers
Nick
libgloss/ChangeLog
2015-11-04 Nick Clifton <nickc@redhat.com>
* rx/rx-sim.ld: Move init and fini arrays into .text section.
diff --git a/libgloss/rx/rx-sim.ld b/libgloss/rx/rx-sim.ld
index a9bbf1f..89b5a95 100644
--- a/libgloss/rx/rx-sim.ld
+++ b/libgloss/rx/rx-sim.ld
@@ -61,6 +61,25 @@ SECTIONS
. = ALIGN(4);
KEEP (*(.init))
KEEP (*(.fini))
+ KEEP (*(.tm_clone_table))
+
+ /* NB: init_array and friends are marked as EXECUTABLE, so they
+ must be placed in the .text section not the .data section. If
+ they are placed in the .data section then section will inherit
+ the EXECUTABLE attribute and so become subject to weird byte
+ swapping protocols in big-endian data mode. */
+ PROVIDE (__preinit_array_start = .);
+ KEEP (*(.preinit_array))
+ PROVIDE (__preinit_array_end = .);
+ PROVIDE (__init_array_start = .);
+ KEEP (*(SORT(.init_array.*)))
+ KEEP (*(.init_array))
+ PROVIDE (__init_array_end = .);
+ PROVIDE (__fini_array_start = .);
+ KEEP (*(.fini_array))
+ KEEP (*(SORT(.fini_array.*)))
+ PROVIDE (__fini_array_end = .);
+ LONG(0); /* Sentinel. */
} > RAM
.rodata : {
@@ -78,19 +97,6 @@ SECTIONS
.data : {
. = ALIGN(4);
PROVIDE (__datastart = .);
- PROVIDE (__preinit_array_start = .);
- KEEP (*(.preinit_array))
- PROVIDE (__preinit_array_end = .);
- PROVIDE (__init_array_start = .);
- KEEP (*(SORT(.init_array.*)))
- KEEP (*(.init_array))
- PROVIDE (__init_array_end = .);
- PROVIDE (__fini_array_start = .);
- KEEP (*(.fini_array))
- KEEP (*(SORT(.fini_array.*)))
- PROVIDE (__fini_array_end = .);
- LONG(0); /* Sentinel. */
-
/* gcc uses crtbegin.o to find the start of the constructors, so
we make sure it is first. Because this is a wildcard, it
doesn't matter if the user does not actually link against