This is the mail archive of the
newlib@sourceware.org
mailing list for the newlib project.
RFA: Fix RX linker script for big-endian data
- From: Nick Clifton <nickc at redhat dot com>
- To: newlib at sourceware dot org
- Date: Tue, 23 Dec 2014 17:21:02 +0000
- Subject: RFA: Fix RX linker script for big-endian data
- Authentication-results: sourceware.org; auth=none
Hi Guys,
The patch below fixes a bug in the rx-sim.ld linker script when
running in big-endian-data mode. The problem was that some of the
startup code was being placed into the .data section, which meant that
it acquired the SHF_EXECINSTR section header flag, since the startup
code contains executable instructions. This in turn meant that the
.data section was not being subject to the byte swapping shenanigans
that go on when loading big-endian-data and so the program fails to
run.
The fix is to move all of the startup code into the .text section and
then everything works.
OK to apply ?
Cheers
Nick
libgloss/ChangeLog
2014-12-23 Nick Clifton <nickc@redhat.com>
* rx/rx-sim.ld (.preinit_array): Move into the .text section.
(.init_array, .fini_array): Likewise.
Index: libgloss/rx/rx-sim.ld
===================================================================
RCS file: /cvs/src/src/libgloss/rx/rx-sim.ld,v
retrieving revision 1.3
diff -u -3 -p -r1.3 rx-sim.ld
--- libgloss/rx/rx-sim.ld 30 Aug 2012 21:08:14 -0000 1.3
+++ libgloss/rx/rx-sim.ld 23 Dec 2014 17:15:02 -0000
@@ -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