This is the mail archive of the libc-alpha@sources.redhat.com mailing list for the glibc 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] |
This patch introduces support for the n32 and n64 ABIs in the mips port, and makes a few tweaks such that o32 works when include/asm points to asm-mips64. The idea is to be able to install the three ABIs on the same runtime environment, n32 being the default ABI, in /lib32, o32 the backward-compatibility one, in /lib, supposed to be fully compatible with mips-linux-gnu, and n64 being the 64-bit ABI, in /lib64. Header files were adjusted such that a single /usr/include tree can be used, such that a single toolchain can build applications for all 3 ABIs present on a mips64-linux system. In addition to changes to the existing mips port, this patch contains a number of fixes to generic code that happened to be triggered by issues specific to the new ABIs. The most common problem was in n32, that has 128-bit wide long doubles (following IEEE quad format, departing from IRIX's weird format per recommendation of MIPS), 64-bit registers but only 32-bit wide longs and pointers. Other than the difference in long double format, we've tried to follow IRIX's practice as closely as possible. In particular, the environment variables used by IRIX 6 for LD_LIBRARY_PATH are (or should be) modeled in this implementation, which also took some changes in generic code. This patch was developed and tested against a 2.3.1 code base. I've done a bit of effort of bringing it up to mainline, but that meant basically moving the new inline syscalls implementation on mips to a different header, tweaking it for n32 and n64, realizing it was broken even for o32 in certain cases (say $a2 is not marked as clobbered on a syscall with 2 arguments, so gcc might well thing it can save something there, just to find out it was clobbered). I have a fix in mind, but it's going to be a while until I can actually test it, so I thought I'd post this as-is. Since Uli has voiced his opinion a number of times about not willing to accept a patch because it attempts to introduce an environment that supports building and running code for multiple ABIs on a single system, something he opposes on grounds I don't understand, with the aggravation that it's MIPS we're talking about, I don't really have much hope of getting this accepted. But I have the obligation to post it, so I'm posting it as a single unit, so that whoever is interested in picking it up may do so. If there are minor issues to be fixed, that don't get in the way of the goal of being able to have a single system running o32, n32 and n64 applications, and a single toolchain that can support all of them (the patch for gcc that completes the entire port will be posted in the next few minutes), I'll do my best to fix them. If there are demands that break this goal, I'll have to drop the patch and leave it alone, in the hopes that someone some day picks it up. This would be sad, because I've put a lot of effort into this port. That said, it's certainly not perfect. There's still ongoing work in the kernel to support the new ABIs, and some issues are yet to be determined, such as how to do 64-bit file access in n32 (*stat* syscalls in particular appear to be limited to 32 bits in the kernel sources I have). There are probably a number of bugs. It would obviously help if the patch could go in, since a patch this big is totally unmanageable. BTW, Uli asked me to split it into pieces. I'll do it and send pieces in private to reviewers who request them, but I wanted to have the entire patch archived, in case none of it goes in, as it appears to me that is likely to happen, so whoever picks it up doesn't have to collect too many pieces to get it. Enough rambling, here's the patch. I enclose the ChangeLog entries in plain text, outside the patch, such that interested reviewers can easily quote them in replies in which they ask for the pieces of the patch they're interested in. Index: ChangeLog from Alexandre Oliva <aoliva@redhat.com> * configure.in (flags_for_cc): New variable, appended to CC. Set on mips64*. (machine): Set to mips/mips32 for mips-linux. * configure: Rebuilt. * elf/cache.c (print_entry): Handle mips64 n32 and n64. * elf/dl-conflict.c: Don't compile _dl_resolve_conflicts if ELF_MACHINE_NO_RELA is set. * elf/dl-load.c: Lose if there are no loadable sections. * elf/rtld.c (dl_main): No prelink support for REL-only. (process_envvars): Handle EXTRA_LD_PROCESS_ENVVARS_DECLS, EXTRA_LD_LEN14_ENVVARS and EXTRA_LD_AFTER_PROCESS_ENVVARS. * include/gmp.h: Include/gmp-mparam.h. * stdio-common/_itoa.c (_itoa_base_table): Make 64-bit literals long long. * stdlib/fpioconst.c: Likewise. * stdlib/fpioconst.h: Include gmp.h with angle brackets. * stdlib/strtod.c: Include gmp-mparam.h after gmp.h and gmp-impl.h. Make 64-bit literals long long. * sysdeps/generic/ldconfig.h (FLAG_MIPS64_LIBN32, FLAG_MIPS64_LIBN64): Define. * sysdeps/ieee754/dbl-64/dbl2mpn.c (__mpn_extract_double): Cast shifted values that may be too narrow to mp_limb_t. * sysdeps/ieee754/dbl-64/mpn2dbl.c (__mpn_construct_double): Likewise. * sysdeps/ieee754/flt-32/mpn2flt.c (__mpn_construct_float): Likewise. * sysdeps/ieee754/ldbl-128/ldbl2mpn.c (__mpn_extract_long_double): Likewise. * sysdeps/ieee754/ldbl-128/mpn2ldbl.c (__mpn_construct_long_double): Likewise. * sysdeps/ieee754/ldbl-96/ldbl2mpn.c (__mpn_extract_long_double): Likewise. * sysdeps/ieee754/ldbl-96/mpn2ldbl.c (__mpn_construct_long_double): Likewise. * sysdeps/mips/Implies: Moved wordsize-32 to... * sysdeps/mips/mips32/Implies: New file. * sysdeps/mips/add_n.S: Use L macro for local labels. * sysdeps/mips/addmul_1.S: Likewise. * sysdeps/mips/lshift.S: Likewise. * sysdeps/mips/mul_1.S: Likewise. * sysdeps/mips/rshift.S: Likewise. * sysdeps/mips/sub_n.S: Likewise. * sysdeps/mips/submul_1.S: Likewise. * sysdeps/mips/mips64/add_n.S: Likewise. * sysdeps/mips/mips64/addmul_1.S: Likewise. * sysdeps/mips/mips64/lshift.S: Likewise. * sysdeps/mips/mips64/mul_1.S: Likewise. * sysdeps/mips/mips64/rshift.S: Likewise. * sysdeps/mips/mips64/sub_n.S: Likewise. * sysdeps/mips/mips64/submul_1.S: Likewise. * sysdeps/unis/mips/wait.S: Likewise. * sysdeps/mips/memcpy.S: Likewise. Map t0-3 to a4-7 on new abis. * sysdeps/mips/memset.S: Likewise. * sysdeps/mips/atomicity.h (exchange_and_add, atomic_add): Don't .set mips2 on new abi. (compare_and_swap): Likewise. Support 64-bit longs on n64. * sysdeps/mips/dl-machine.h: Include sys/asm.h. (elf_machine_matches_host): Prevent linking of o32 and n32 together. (elf_machine_dynamic): Document assumption on $gp. (STRINGXP, STRINGXV, STRINGV_): New macros. (elf_machine_load_address): Use them to stringize PTR_LA and PTR_SUBU. (ELF_DL_FRAME_SIZE, ELF_DL_SAVE_ARG_REGS, ELF_DL_RESTORE_ARG_REGS, IFABIO32): New macros used in... (_dl_runtime_resolve): Adjust it for all 3 ABIs. (__dl_runtime_resolve): Cast the symtab initializer to the right type. (RTLD_START): Use it. Adjust it for all 3 ABIs. (ELF_MACHINE_NO_RELA): Adjust comment to new abi. (elf_machine_rel): Mark as always_inline in RTLD_BOOTSTRAP. Handle 64-bit R_MIPS_REL composite relocation. Document assumption regarding local GOT entries. (elf_machine_rela, elf_machine_rela_relative, elf_machine_lazy_rela): Define, even though unused and #ifed out. * sysdeps/mips/ieee754.h: New file. * sysdeps/mips/setjmp_aux.c (STRINGXP, REGS, PTRS): New macros. (__sigsetjmp_aux): Use them. Adjust for all 3 ABIs. * sysdeps/mips/bits/setjmp.h (__jmp_buf): Adjust for all 3 ABIs. * sysdeps/mips/bits/wordsize.h: New file. * sysdeps/mips/elf/start.S: Include sys/asm.h. Adjust for all 3 ABIs. * sysdeps/mips/fpu/bits/mathdef.h: New. (__NO_LONG_DOUBLE_MATH): Define for o32. * sysdeps/mips/mips32/lldiv.c: New file. * sysdeps/mips/mipsel/bits/endian.h: Moved to... * sysdeps/mips/mips32/el/bits/endian.h. * sysdeps/mips/mips64/Implies: Move wordsize-64 to... * sysdeps/mips/mips64/n64/Implies: New file. * sysdeps/mips/mips64/bsd-_setjmp.S: Adjust for all 3 ABIs. * sysdeps/mips/mips64/bsd-setjmp.S: Likewise. * sysdeps/mips/mips64/dl-machine.h: Deleted, obsolete. * sysdeps/mips/mips64/gmp-mparam.h: New file. Define BITS_PER_LONGINT to __WORDSIZE, to match all 3 ABIs. * sysdeps/mips/mips64/setjmp.S: Adjust for new ABIs. * sysdeps/mips/mips64/bits/setjmp.h: Deleted, obsolete. * sysdeps/mips/mips64/n32/Implies: New file. * sysdeps/mips/mips64/n32/Makefile: New file. * sysdeps/mips/mips64/n32/lldiv.c: New file. * sysdeps/mips/mips64/n32/el/bits/endian.h: New file. * sysdeps/mips/mips64/n64/Makefile: New file. * sysdeps/mips/mips64/n64/el/bits/endian.h: New file. * sysdeps/mips/mips64/soft-fp-sfp-machine.h: Use long long for 64-bit types. * sysdeps/mips/sys/asm.h (PTR, PTRSIZE, PTRLOG): Adjust for all 3 ABIs. (CPADD): Define for all of them. (SETUP_GP, SETUP_GPX, SETUP_GPX_L, SAVE_GP, SETUP_GP64, SETUP_GPX64, SETUP_GPX64_L, RESTORE_GP64, USE_ALT_CP, NARGSAVE): Define per ABI spec. (END): Don't redefine. (LONG_SLL, LONG_SLLV, LONG_SRL, LONG_SRLV, LONG_SRA, LONG_SRAV): Don't define. (PTR_ADD, PTR_ADDI, PTR_ADDU, PTR_ADDIU, PTR_SUB, PTR_SUBI, PTR_SUBU, PTR_SUBIU, PTR_L, PTR_S, PTR_SLL, PTR_SLLV, PTR_SRL, PTR_SRLV, PTR_SRA, PTR_SRAV, PTR_SCALESHIFT): Define for n32. (PTR_LA): Define for all 3 ABIs. * sysdeps/mips/sys/regdef.h: Alias a4-7 or t0-3 to $8-11 depending on the ABI. * sysdeps/mips/sys/ucontext.h: Adjust for all 3 ABIs. * sysdeps/unix/mips/brk.S: Likewise. * sysdeps/unix/mips/sysdep.S: Use L() for local labels. Define L() according to ABI conventions. Define END as in sys/asm.h. * sysdeps/unix/mips/mips64/n32/sysdep.h: New file. * sysdeps/unix/mips/mips64/n64/sysdep.h: New file. * sysdeps/unix/sysv/linux/configure.in (libc_cv_slibdir): Use lib64 for mips64/n64 and lib32 for mips64/n32. (ldd_rewrite_script): Needed for all mips64 configurations. * sysdeps/unix/sysv/linux/umount.S: Don't assume at least one of oldumount and umount must exist. * sysdeps/unix/sysv/linux/mips/Makefile: Do custom processing of syscall list. * sysdeps/unix/sysv/linux/mips/clone.S: Don't include asm/unistd.h. Adjust for all 3 ABIs. Use L() for local labels. * sysdeps/unix/sysv/linux/mips/configure.in: Pre-process asm/unistd.h into asm-unistd.h. * sysdeps/unix/sysv/linux/mips/configure: Rebuilt. * sysdeps/unix/sysv/linux/mips/kernel_sigaction.h (_KERNEL_NSIG_BPW): Define in terms of _MIPS_SZLONG. * sysdeps/unix/sysv/linux/mips/kernel_stat.h: Define for n64. * sysdeps/unix/sysv/linux/mips/pread.c: Don't break up offset into high and low halves on n64. * sysdeps/unix/sysv/linux/mips/pread64.c: Likewise. * sysdeps/unix/sysv/linux/mips/pwrite.c: Likewise. * sysdeps/unix/sysv/linux/mips/pwrite64.c: Likewise. * sysdeps/unix/sysv/linux/mips/ptrace.c: New file. Use long long type for registers on n32. * sysdeps/unix/sysv/linux/mips/readelflib.c: New file. * sysdeps/unix/sysv/linux/mips/sigaction.c: Define restore and restore_rt functions. Use them. * sysdeps/unix/sysv/linux/mips/syscalls.list: Make s_execve EXTRA. Move recv, send, s_llseek and s_ipc to... * sysdeps/unix/sysv/linux/mips/mips32/syscalls.list: New file. * sysdeps/unix/sysv/linux/mips/sysdep.h: Move to... * sysdeps/unix/sysv/linux/mips/mips32/sysdep.h: New file. * sysdeps/unix/sysv/linux/mips/bits/fcntl.h: Adjust for all 3 ABIs. * sysdeps/unix/sysv/linux/mips/bits/stat.h: Likewise. * sysdeps/unix/sysv/linux/mips/mips32/kern64/sysdep.h: New file. * sysdeps/unix/sysv/linux/mips/mips64/Dist: New file. * sysdeps/unix/sysv/linux/mips/mips64/ldconfig.h: New file. * sysdeps/unix/sysv/linux/mips/mips64/ldd-rewrite.sed: New file. * sysdeps/unix/sysv/linux/mips/mips64/llseek.c: New file. * sysdeps/unix/sysv/linux/mips/mips64/recv.c: New file. * sysdeps/unix/sysv/linux/mips/mips64/send.c: New file. * sysdeps/unix/sysv/linux/mips/mips64/syscall.S: New file. * sysdeps/unix/sysv/linux/mips/mips64/syscalls.list: New file. * sysdeps/unix/sysv/linux/mips/mips64/n32/dl-librecon.h: New file. * sysdeps/unix/sysv/linux/mips/mips64/n32/sysdep.h: New file. * sysdeps/unix/sysv/linux/mips/mips64/n64/dl-librecon.h: New file. * sysdeps/unix/sysv/linux/mips/mips64/n64/glob64.c: New file. * sysdeps/unix/sysv/linux/mips/mips64/n64/sysdep.h: New file. * sysdeps/unix/sysv/linux/mips/sys/profcs.h: Adjust for all 3 ABI.s * sysdeps/unix/sysv/linux/mips/sys/ptrace.h: New file. * sysdeps/unix/sysv/linux/mips/sys/syscall.h: New file. * sysdeps/unix/sysv/linux/mips/sys/tas.h (_test_and_set): Dont .set mips2 on new abis. * sysdeps/unix/sysv/linux/mips/sys/ucontext.h: Adjust for all 3 ABIs. * sysdeps/unix/sysv/linux/powerpc/powerpc64/syscalls.list: Make s_execve EXTRA. * sysdeps/wordsize-32/lldiv.c (DONT_USE_DIVDI3_INTERNAL): Obey. Index: linuxthreads/ChangeLog from Alexandre Oliva <aoliva@redhat.com> * sysdeps/mips/pspinlock.c (__pthread_spin_lock): Don't .set mips2 on new abi. * sysdeps/mips/pt-machine.h (__compare_and_swap): Likewise. Handle 64-bit longs on n64.
Attachment:
net-glibc-mips64.patch.bz2
Description: BZip2 compressed data
-- Alexandre Oliva Enjoy Guarana', see http://www.ic.unicamp.br/~oliva/ Red Hat GCC Developer aoliva@{redhat.com, gcc.gnu.org} CS PhD student at IC-Unicamp oliva@{lsd.ic.unicamp.br, gnu.org} Free Software Evangelist Professional serial bug killer
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |