This is the mail archive of the binutils@sourceware.org mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

RFA: Allow .rdata to be writable on mips-wrs-vxworks


The VxWorks libraries use .rdata as the read-only data section.
The linker normally places it as an orphan next to .rodata, and
things work as expected.

Unfortunately, one of the objects in libdl.a has a _writable_ .rdata
section.  The orphan placement code creates the .rdata output section
statement when it finds the first input .rdata section, and this first
input section will usually be read-only.  The code therefore places
the output section statement on the assumption that it too will be
read-only, so we then end up with a writable text segment.

This was always less than ideal, but worked.  However, in older
binutils, the data segment was aligned to 0x40000 -- much greater than
MAXPAGESIZE -- and so we would usually still have 2 segments.  The data
segment is now aligned only to MAXPAGESIZE (which seems like a good thing)
and so we end up with a single RWE segment.  This appears to crash the
loader.  (It also screws up the calculation of DT_TEXTREL, and I wondered
at first if that was causing the loader problem.  Forcing DT_TEXTREL to be
added didn't cure the crash though.)

Although binutils could probably cope more gracefully with this situation,
I don't want to clutter it with target-independent workarounds for what is
basically an OS bug.  I'd therefore like to apply the VxWorks-specific
patch below.

Tested on mips-wrs-vxworks.  OK to install?

Richard


ld/
	* emulparams/elf32ebmipvxworks.sh (OTHER_READONLY_SECTIONS)
	(OTHER_READWRITE_SECTIONS): Define.  Add .rdata sections.

Index: ld/emulparams/elf32ebmipvxworks.sh
===================================================================
RCS file: /cvs/src/src/ld/emulparams/elf32ebmipvxworks.sh,v
retrieving revision 1.1
diff -u -p -r1.1 elf32ebmipvxworks.sh
--- ld/emulparams/elf32ebmipvxworks.sh	22 Mar 2006 09:28:13 -0000	1.1
+++ ld/emulparams/elf32ebmipvxworks.sh	14 May 2007 12:53:04 -0000
@@ -3,6 +3,15 @@
 OUTPUT_FORMAT="elf32-bigmips-vxworks"
 BIG_OUTPUT_FORMAT="elf32-bigmips-vxworks"
 LITTLE_OUTPUT_FORMAT="elf32-littlemips-vxworks"
+# VxWorks .rdata sections are normally read-only, but one of the objects
+# in libdl.a (the dynamic loader) is actually read-write.  Explicitly
+# place the section in the appropriate segment for its flags.
+OTHER_READONLY_SECTIONS="
+  .rdata ${RELOCATING-0} : ONLY_IF_RO { *(.rdata) }
+"
+OTHER_READWRITE_SECTIONS="
+  .rdata ${RELOCATING-0} : ONLY_IF_RW { *(.rdata) }
+"
 unset OTHER_GOT_SYMBOLS
 SHLIB_TEXT_START_ADDR=0
 unset TEXT_DYNAMIC


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]