This is the mail archive of the binutils@sourceware.cygnus.com 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]

PATCH for elf.sc



On IRIX6, the .rodata section often has to be writable.  (Yes, you
read that right.)  That's because there are .rel.dyn relocations
against it, and because SGI `rld' does not honor DT_TEXTREL.  (That's
supposed to tell it that relocations may occur against the text
segment.)  The consequence is that .rodata must go in the data
segment.  Here's a patch to elf.sc that allows a port to turn on this
behavior.  

Is there an easy way for a BFD back-end to reorder sections depending
on what relocations it has seen?  I couldn't find one, so I came up
with this patch.  OK?

--
Mark Mitchell                   mark@codesourcery.com
CodeSourcery, LLC               http://www.codesourcery.com

1999-06-20  Mark Mitchell  <mark@codesourcery.com>

	* scripttempl/elf.sc (WRITABLE_RODATA): New variable for
	controlling whether or not .rodata is in the data segment or the
	text segment.

Index: ld/scripttempl/elf.sc
===================================================================
RCS file: /cvs/binutils/binutils/ld/scripttempl/elf.sc,v
retrieving revision 1.1.1.1
diff -u -p -r1.1.1.1 elf.sc
--- elf.sc	1999/05/03 07:29:08	1.1.1.1
+++ elf.sc	1999/06/21 03:11:55
@@ -25,6 +25,7 @@
 #	SHLIB_TEXT_START_ADDR - if set, add to SIZEOF_HEADERS to set
 #		start address of shared library.
 #	INPUT_FILES - INPUT command of files to always include
+#	WRITABLE_RODATA - if set, the .rodata section should be writable
 #
 # When adding sections, do note that the names of some sections are used
 # when specifying the start address of the next.
@@ -180,12 +181,12 @@ SECTIONS
   ${RELOCATING+_etext = .;}
   ${RELOCATING+PROVIDE (etext = .);}
   .fini    ${RELOCATING-0} : { KEEP (*(.fini))		} =${NOP-0}
-  .rodata  ${RELOCATING-0} :
-  {
-    *(.rodata)
-    ${RELOCATING+*(.rodata.*)}
-    ${RELOCATING+*(.gnu.linkonce.r*)}
-  }
+  ${WRITABLE_RODATA-.rodata  ${RELOCATING-0} : \
+  { \
+    *(.rodata) \
+    ${RELOCATING+*(.rodata.*)} \
+    ${RELOCATING+*(.gnu.linkonce.r*)} \
+  }}
   .rodata1 ${RELOCATING-0} : { *(.rodata1) }
   ${RELOCATING+${OTHER_READONLY_SECTIONS}}
 
@@ -205,6 +206,12 @@ SECTIONS
   .data1 ${RELOCATING-0} : { *(.data1) }
   .eh_frame : { *(.eh_frame) }
   .gcc_except_table : { *(.gcc_except_table) }
+  ${WRITABLE_RODATA+.rodata  ${RELOCATING-0} : \
+  { \
+    *(.rodata) \
+    ${RELOCATING+*(.rodata.*)} \
+    ${RELOCATING+*(.gnu.linkonce.r*)} \
+  }}
   ${RELOCATING+${OTHER_READWRITE_SECTIONS}}
   ${RELOCATING+${CTOR}}
   ${RELOCATING+${DTOR}}

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