Linking n64 code for irix (part 1/2)

Richard Sandiford rsandifo@redhat.com
Mon Oct 13 19:17:00 GMT 2003


I've been trying to get GNU ld to work with irix/n64.  This patch
(the first of two) deals with ld emulation side.  The changes are:

  1. Define a nonzero start address for DSOs.  (FYI, the value I've
     used here is the one that MIPSpro uses for very small objects.)

  2. Fix the definition of __elf_header for position-independent code.

  3. Put .dynamic into the text segment for all n32/n64 emulations.
     At the moment we only do this for elf32[bl]tsmipn32.

  4. Likewise .MIPS.options and elf64[bt]smip.

     [ Although gas uses .reginfo rather than .MIPS.options for n32,
       objects created by MIPSpro have both.  This includes the n32
       crt and C library.

       Since most links will include at least one MIPSpro object, n32
       output will usually have a .MIPS.options section.  At the moment
       it will be placed as an orphan and end up in the data segment. ]

I bootstrapped & tested gcc on mips-sgi-irix6.5 and mips64{,el}-linux-gnu
(testing all the multilibs for each config).  The irix results are as good
as they are with the native tools and there were no regressions for
mips*-linux-gnu.  FYI, I used the attached gcc patch for irix.

Also tested against the binutils testsuite for mips64-linux-gnu,
mipsisa64-elf and mips-sgi-irix6.5.  OK to install?

Richard


	* emulparams/elf32bmipn32-defs.sh (INITIAL_READONLY_SECTIONS): Move
	definition from elf64btsmip.sh.
	(TEXT_DYNAMIC): Likewise elf32btsmipn32.sh.
	* emulparams/elf32btsmipn32.sh (TEXT_DYNAMIC): Remove.
	* emulparams/elf64btsmip.sh: (INITIAL_READONLY_SECTIONS): Remove.
	* emulparams/elf64bmip.sh (SHLIB_TEXT_START_ADDR): Define.
	(EXECUTABLE_SYMBOLS): Set __elf_header correctly for shared objects.
	Define __program_header_table in terms of __elf_header.

Index: ld/emulparams/elf32bmipn32-defs.sh
===================================================================
RCS file: /cvs/src/src/ld/emulparams/elf32bmipn32-defs.sh,v
retrieving revision 1.4
diff -c -d -p -F^\([(a-zA-Z0-9_]\|#define\) -r1.4 elf32bmipn32-defs.sh
*** ld/emulparams/elf32bmipn32-defs.sh	6 Jan 2003 16:13:59 -0000	1.4
--- ld/emulparams/elf32bmipn32-defs.sh	10 Oct 2003 18:20:04 -0000
*************** TEXT_START_SYMBOLS='_ftext = . ;'
*** 50,55 ****
--- 50,56 ----
  DATA_START_SYMBOLS='_fdata = . ;'
  OTHER_BSS_SYMBOLS='_fbss = .;'
  
+ INITIAL_READONLY_SECTIONS=".MIPS.options : { *(.MIPS.options) }"
  OTHER_SECTIONS="
    .MIPS.events.text ${RELOCATING-0} :
      {
*************** OTHER_SECTIONS="
*** 75,77 ****
--- 76,80 ----
      {
         *(.MIPS.content.rodata${RELOCATING+ .MIPS.content.gnu.linkonce.r*})
      }"
+ 
+ TEXT_DYNAMIC=
Index: ld/emulparams/elf32btsmipn32.sh
===================================================================
RCS file: /cvs/src/src/ld/emulparams/elf32btsmipn32.sh,v
retrieving revision 1.4
diff -c -d -p -F^\([(a-zA-Z0-9_]\|#define\) -r1.4 elf32btsmipn32.sh
*** ld/emulparams/elf32btsmipn32.sh	7 Nov 2002 00:46:59 -0000	1.4
--- ld/emulparams/elf32btsmipn32.sh	10 Oct 2003 18:20:04 -0000
*************** OTHER_SECTIONS='
*** 12,16 ****
    .gptab.sdata : { *(.gptab.data) *(.gptab.sdata) }
    .gptab.sbss : { *(.gptab.bss) *(.gptab.sbss) }
  '
- 
- TEXT_DYNAMIC=
--- 12,14 ----
Index: ld/emulparams/elf64bmip.sh
===================================================================
RCS file: /cvs/src/src/ld/emulparams/elf64bmip.sh,v
retrieving revision 1.7
diff -c -d -p -F^\([(a-zA-Z0-9_]\|#define\) -r1.7 elf64bmip.sh
*** ld/emulparams/elf64bmip.sh	22 Oct 2002 22:13:26 -0000	1.7
--- ld/emulparams/elf64bmip.sh	10 Oct 2003 18:20:04 -0000
***************
*** 2,13 ****
  OUTPUT_FORMAT="elf64-bigmips"
  BIG_OUTPUT_FORMAT="elf64-bigmips"
  LITTLE_OUTPUT_FORMAT="elf64-littlemips"
  
  # IRIX6 defines these symbols.  0x40 is the size of the ELF header.
  EXECUTABLE_SYMBOLS="
    __dso_displacement = 0;
!   __elf_header = ${TEXT_START_ADDR};
!   __program_header_table = ${TEXT_START_ADDR} + 0x40;
  "
  
  # There are often dynamic relocations against the .rodata section.
--- 2,16 ----
  OUTPUT_FORMAT="elf64-bigmips"
  BIG_OUTPUT_FORMAT="elf64-bigmips"
  LITTLE_OUTPUT_FORMAT="elf64-littlemips"
+ SHLIB_TEXT_START_ADDR=0x3ffffe0000
  
  # IRIX6 defines these symbols.  0x40 is the size of the ELF header.
  EXECUTABLE_SYMBOLS="
    __dso_displacement = 0;
!   ${CREATE_SHLIB-${CREATE_PIE-__elf_header = ${TEXT_START_ADDR};}}
!   ${CREATE_SHLIB+__elf_header = ${SHLIB_TEXT_START_ADDR};}
!   ${CREATE_PIE+__elf_header = ${SHLIB_TEXT_START_ADDR};}
!   __program_header_table = __elf_header + 0x40;
  "
  
  # There are often dynamic relocations against the .rodata section.
Index: ld/emulparams/elf64btsmip.sh
===================================================================
RCS file: /cvs/src/src/ld/emulparams/elf64btsmip.sh,v
retrieving revision 1.10
diff -c -d -p -F^\([(a-zA-Z0-9_]\|#define\) -r1.10 elf64btsmip.sh
*** ld/emulparams/elf64btsmip.sh	26 May 2003 11:56:26 -0000	1.10
--- ld/emulparams/elf64btsmip.sh	10 Oct 2003 18:20:04 -0000
*************** BIG_OUTPUT_FORMAT="elf64-tradbigmips"
*** 7,13 ****
  LITTLE_OUTPUT_FORMAT="elf64-tradlittlemips"
  
  # Magic sections.
- INITIAL_READONLY_SECTIONS='.MIPS.options : { *(.MIPS.options) }'
  OTHER_TEXT_SECTIONS='*(.mips16.fn.*) *(.mips16.call.*)'
  OTHER_SECTIONS='
    .gptab.sdata : { *(.gptab.data) *(.gptab.sdata) }
--- 7,12 ----
*************** OTHER_SECTIONS='
*** 15,18 ****
  '
  
  TEXT_START_ADDR="0x120000000"
- TEXT_DYNAMIC=
--- 14,16 ----


-------------- next part --------------
A non-text attachment was scrubbed...
Name: gcc-crtstuff.diff
Type: text/x-patch
Size: 2768 bytes
Desc: not available
URL: <https://sourceware.org/pipermail/binutils/attachments/20031013/acf6c5fd/attachment.bin>


More information about the Binutils mailing list