This is the mail archive of the
binutils@sources.redhat.com
mailing list for the binutils project.
Linking n64 code for irix (part 1/2)
- From: Richard Sandiford <rsandifo at redhat dot com>
- To: binutils at sources dot redhat dot com
- Date: 13 Oct 2003 20:17:51 +0100
- Subject: Linking n64 code for irix (part 1/2)
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 ----
Index: crtstuff.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/crtstuff.c,v
retrieving revision 1.62
diff -c -d -p -F^\([(a-zA-Z0-9_]\|#define\) -r1.62 crtstuff.c
*** crtstuff.c 7 Jun 2003 17:30:32 -0000 1.62
--- crtstuff.c 13 Oct 2003 18:14:39 -0000
*************** __do_global_dtors (void)
*** 378,391 ****
#endif
}
- #if defined(USE_EH_FRAME_REGISTRY) || defined(JCR_SECTION_NAME)
- /* A helper function for __do_global_ctors, which is in crtend.o. Here
- in crtbegin.o, we can reference a couple of symbols not visible there.
- Plus, since we're before libgcc.a, we have no problems referencing
- functions from there. */
void
! __do_global_ctors_1(void)
{
#ifdef USE_EH_FRAME_REGISTRY
static struct object object;
if (__register_frame_info)
--- 378,387 ----
#endif
}
void
! __do_global_ctors (void)
{
+ func_ptr *p;
#ifdef USE_EH_FRAME_REGISTRY
static struct object object;
if (__register_frame_info)
*************** __do_global_ctors_1(void)
*** 395,402 ****
if (__JCR_LIST__[0] && _Jv_RegisterClasses)
_Jv_RegisterClasses (__JCR_LIST__);
#endif
}
- #endif /* USE_EH_FRAME_REGISTRY || JCR_SECTION_NAME */
#else /* ! INIT_SECTION_ASM_OP && ! HAS_INIT_SECTION */
#error "What are you doing with crtstuff.c, then?"
--- 391,401 ----
if (__JCR_LIST__[0] && _Jv_RegisterClasses)
_Jv_RegisterClasses (__JCR_LIST__);
#endif
+ for (p = __CTOR_LIST__ + 1; *p; p++)
+ continue;
+ for (p--; *p != (func_ptr) -1; p--)
+ (*p) ();
}
#else /* ! INIT_SECTION_ASM_OP && ! HAS_INIT_SECTION */
#error "What are you doing with crtstuff.c, then?"
*************** asm (TEXT_SECTION_ASM_OP);
*** 508,526 ****
#elif defined(HAS_INIT_SECTION) /* ! INIT_SECTION_ASM_OP */
/* This case is used by the Irix 6 port, which supports named sections but
! not an SVR4-style .init section. __do_global_ctors can be non-static
! in this case because we protect it with -hidden_symbol. */
! extern void __do_global_ctors_1(void);
! void
! __do_global_ctors (void)
! {
! func_ptr *p;
! #if defined(USE_EH_FRAME_REGISTRY) || defined(JCR_SECTION_NAME)
! __do_global_ctors_1();
! #endif
! for (p = __CTOR_END__ - 1; *p != (func_ptr) -1; p--)
! (*p) ();
! }
#else /* ! INIT_SECTION_ASM_OP && ! HAS_INIT_SECTION */
#error "What are you doing with crtstuff.c, then?"
--- 507,513 ----
#elif defined(HAS_INIT_SECTION) /* ! INIT_SECTION_ASM_OP */
/* This case is used by the Irix 6 port, which supports named sections but
! not an SVR4-style .init section. Everything is done in crtbegin. */
#else /* ! INIT_SECTION_ASM_OP && ! HAS_INIT_SECTION */
#error "What are you doing with crtstuff.c, then?"