Mercurial > illumos > illumos-gate
changeset 8501:e544a13d2b41
6789925 64-bit applications with SF1_SUNW_ADDR32 require non-default starting address
author | Rod Evans <Rod.Evans@Sun.COM> |
---|---|
date | Wed, 07 Jan 2009 15:27:19 -0800 |
parents | 59dbef052725 |
children | 4b8a96523461 |
files | usr/src/cmd/sgs/include/debug.h usr/src/cmd/sgs/include/i386/machdep_x86.h usr/src/cmd/sgs/include/libld.h usr/src/cmd/sgs/include/sparc/machdep_sparc.h usr/src/cmd/sgs/libld/common/_libld.h usr/src/cmd/sgs/libld/common/files.c usr/src/cmd/sgs/libld/common/ldmain.c usr/src/cmd/sgs/libld/common/machrel.amd.c usr/src/cmd/sgs/libld/common/machrel.intel.c usr/src/cmd/sgs/libld/common/machrel.sparc.c usr/src/cmd/sgs/libld/common/outfile.c usr/src/cmd/sgs/libld/common/update.c usr/src/cmd/sgs/liblddbg/common/cap.c usr/src/cmd/sgs/liblddbg/common/llib-llddbg usr/src/cmd/sgs/packages/common/SUNWonld-README |
diffstat | 15 files changed, 79 insertions(+), 45 deletions(-) [+] |
line wrap: on
line diff
--- a/usr/src/cmd/sgs/include/debug.h Wed Jan 07 16:30:55 2009 -0500 +++ b/usr/src/cmd/sgs/include/debug.h Wed Jan 07 15:27:19 2009 -0800 @@ -20,7 +20,7 @@ */ /* - * Copyright 2008 Sun Microsystems, Inc. All rights reserved. + * Copyright 2009 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ @@ -661,7 +661,7 @@ extern void Dbg_cap_hw_filter(Lm_list *, const char *, Rt_map *); extern void Dbg_cap_mapfile(Lm_list *, Xword, Xword, Half); extern void Dbg_cap_sec_entry(Lm_list *, uint_t, Xword, Xword, Half); -extern void Dbg_cap_sec_title(Ofl_desc *); +extern void Dbg_cap_sec_title(Lm_list *, const char *); extern void Dbg_cap_val_hw1(Lm_list *, Xword, Half); extern const char *
--- a/usr/src/cmd/sgs/include/i386/machdep_x86.h Wed Jan 07 16:30:55 2009 -0500 +++ b/usr/src/cmd/sgs/include/i386/machdep_x86.h Wed Jan 07 15:27:19 2009 -0800 @@ -23,7 +23,7 @@ * Copyright (c) 1988 AT&T * All Rights Reserved * - * Copyright 2008 Sun Microsystems, Inc. All rights reserved. + * Copyright 2009 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. * * Global include file for all sgs ia32 based machine dependent macros, @@ -117,15 +117,21 @@ #define M_BIND_ADJ 1 /* adjustment for end of */ /* elf_rtbndr() address */ #ifdef _ELF64 +/* + * Provide default starting addresses. 64-bit programs can also be restricted + * to a 32-bit address space (SF1_SUNW_ADDR32), and these programs provide an + * alternative origin. + */ +#define M_SEGM_ORIGIN (Addr)0x400000ULL /* default 1st segment origin */ +#define M_SEGM_AORIGIN (Addr)0x10000ULL /* alternative 1st segment */ + /* origin */ #define M_WORD_ALIGN 8 -#define M_SEGM_ORIGIN (Addr)0x00400000 /* default first segment offset */ #else - -#define M_WORD_ALIGN 4 - #define M_STACK_GAP (0x08000000) #define M_STACK_PGS (0x00048000) #define M_SEGM_ORIGIN (Addr)(M_STACK_GAP + M_STACK_PGS) +#define M_SEGM_AORIGIN M_SEGM_ORIGIN +#define M_WORD_ALIGN 4 #endif
--- a/usr/src/cmd/sgs/include/libld.h Wed Jan 07 16:30:55 2009 -0500 +++ b/usr/src/cmd/sgs/include/libld.h Wed Jan 07 15:27:19 2009 -0800 @@ -23,7 +23,7 @@ * Copyright (c) 1988 AT&T * All Rights Reserved * - * Copyright 2008 Sun Microsystems, Inc. All rights reserved. + * Copyright 2009 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ @@ -193,7 +193,6 @@ Sym_desc *ofl_dtracesym; /* ld -zdtrace= */ ofl_flag_t ofl_flags; /* various state bits, args etc. */ ofl_flag_t ofl_flags1; /* more flags */ - Xword ofl_segorigin; /* segment origin (start) */ void *ofl_entry; /* entry point (-e and Sym_desc *) */ char *ofl_filtees; /* shared objects we are a filter for */ const char *ofl_soname; /* (-h option) output file name for */
--- a/usr/src/cmd/sgs/include/sparc/machdep_sparc.h Wed Jan 07 16:30:55 2009 -0500 +++ b/usr/src/cmd/sgs/include/sparc/machdep_sparc.h Wed Jan 07 15:27:19 2009 -0800 @@ -23,7 +23,7 @@ * Copyright (c) 1988 AT&T * All Rights Reserved * - * Copyright 2008 Sun Microsystems, Inc. All rights reserved. + * Copyright 2009 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. * * Global include file for all sgs SPARC machine dependent macros, constants @@ -167,15 +167,21 @@ #ifdef _ELF64 #define M_SEGM_ALIGN ELF_SPARCV9_MAXPGSZ /* - * Put 64-bit programs above 4 gigabytes to help insure correctness, - * so any 64-bit programs that truncate pointers will fault now instead of - * corrupting itself and dying mysteriously. + * Put default 64-bit programs above 4 gigabytes to help insure correctness, so + * that any 64-bit programs that truncate pointers will fault now instead of + * corrupting itself and dying mysteriously. 64-bit programs can also be + * restricted to a 32-bit address space (SF1_SUNW_ADDR32), and these programs + * provide an alternative origin. */ -#define M_SEGM_ORIGIN (Addr)0x100000000ULL /* default first segment offset */ +#define M_SEGM_ORIGIN (Addr)0x100000000ULL /* default 1st segment origin */ +#define M_SEGM_AORIGIN (Addr)0x100000ULL /* alternative 1st segment */ + /* origin */ #define M_WORD_ALIGN 8 #else #define M_SEGM_ALIGN ELF_SPARC_MAXPGSZ -#define M_SEGM_ORIGIN (Addr)0x10000 /* default first segment offset */ +#define M_SEGM_ORIGIN (Addr)0x10000 /* default 1st segment origin */ +#define M_SEGM_AORIGIN M_SEGM_ORIGIN /* alternative 1st segment */ + /* origin */ #define M_WORD_ALIGN 4 #endif
--- a/usr/src/cmd/sgs/libld/common/_libld.h Wed Jan 07 16:30:55 2009 -0500 +++ b/usr/src/cmd/sgs/libld/common/_libld.h Wed Jan 07 15:27:19 2009 -0800 @@ -23,7 +23,7 @@ * Copyright (c) 1988 AT&T * All Rights Reserved * - * Copyright 2008 Sun Microsystems, Inc. All rights reserved. + * Copyright 2009 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ @@ -65,7 +65,8 @@ uchar_t m_data; /* Target byte order */ Xword m_segm_align; /* segment alignment */ - Xword m_segm_origin; /* Default 1st segment offset */ + Xword m_segm_origin; /* Default 1st segment origin */ + Xword m_segm_aorigin; /* Alternative 1st segment origin */ Word m_dataseg_perm; /* data segment permission mask */ Word m_word_align; /* alignment to use for Word sections */ const char *m_def_interp; /* Def. interpreter for dyn objects */
--- a/usr/src/cmd/sgs/libld/common/files.c Wed Jan 07 16:30:55 2009 -0500 +++ b/usr/src/cmd/sgs/libld/common/files.c Wed Jan 07 15:27:19 2009 -0800 @@ -23,7 +23,7 @@ * Copyright (c) 1988 AT&T * All Rights Reserved * - * Copyright 2008 Sun Microsystems, Inc. All rights reserved. + * Copyright 2009 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ @@ -391,7 +391,7 @@ Cap *cdata; Word ndx, cnum; - DBG_CALL(Dbg_cap_sec_title(ofl)); + DBG_CALL(Dbg_cap_sec_title(ofl->ofl_lml, ifl->ifl_name)); /* * The capabilities are supposed to be terminated with a CA_SUNW_NULL
--- a/usr/src/cmd/sgs/libld/common/ldmain.c Wed Jan 07 16:30:55 2009 -0500 +++ b/usr/src/cmd/sgs/libld/common/ldmain.c Wed Jan 07 15:27:19 2009 -0800 @@ -23,7 +23,7 @@ * Copyright (c) 1988 AT&T * All Rights Reserved * - * Copyright 2008 Sun Microsystems, Inc. All rights reserved. + * Copyright 2009 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ @@ -226,8 +226,7 @@ /* * If the user didn't supply a library path supply a default. And, if * no run-path has been specified (-R), see if the environment variable - * is in use (historic). Also assign a default starting address. - * Don't use MSG_ORIG() for these strings, they're written to later. + * is in use (historic). */ if (Plibpath == NULL) Plibpath = def_Plibpath; @@ -238,8 +237,6 @@ (strcmp((const char *)rpath, MSG_ORIG(MSG_STR_EMPTY)))) ofl->ofl_rpath = rpath; } - if (ofl->ofl_flags & FLG_OF_EXEC) - ofl->ofl_segorigin = ld_targ.t_m.m_segm_origin; /* * Argument pass two. Input all libraries and objects.
--- a/usr/src/cmd/sgs/libld/common/machrel.amd.c Wed Jan 07 16:30:55 2009 -0500 +++ b/usr/src/cmd/sgs/libld/common/machrel.amd.c Wed Jan 07 15:27:19 2009 -0800 @@ -20,7 +20,7 @@ */ /* - * Copyright 2008 Sun Microsystems, Inc. All rights reserved. + * Copyright 2009 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ @@ -1562,6 +1562,7 @@ M_SEGM_ALIGN, /* m_segm_align */ M_SEGM_ORIGIN, /* m_segm_origin */ + M_SEGM_AORIGIN, /* m_segm_aorigin */ M_DATASEG_PERM, /* m_dataseg_perm */ M_WORD_ALIGN, /* m_word_align */ MSG_ORIG(MSG_PTH_RTLD_AMD64), /* m_def_interp */
--- a/usr/src/cmd/sgs/libld/common/machrel.intel.c Wed Jan 07 16:30:55 2009 -0500 +++ b/usr/src/cmd/sgs/libld/common/machrel.intel.c Wed Jan 07 15:27:19 2009 -0800 @@ -24,7 +24,7 @@ * Copyright (c) 1988 AT&T * All Rights Reserved * - * Copyright 2008 Sun Microsystems, Inc. All rights reserved. + * Copyright 2009 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ @@ -1638,6 +1638,7 @@ M_SEGM_ALIGN, /* m_segm_align */ M_SEGM_ORIGIN, /* m_segm_origin */ + M_SEGM_AORIGIN, /* m_segm_aorigin */ M_DATASEG_PERM, /* m_dataseg_perm */ M_WORD_ALIGN, /* m_word_align */ MSG_ORIG(MSG_PTH_RTLD), /* m_def_interp */
--- a/usr/src/cmd/sgs/libld/common/machrel.sparc.c Wed Jan 07 16:30:55 2009 -0500 +++ b/usr/src/cmd/sgs/libld/common/machrel.sparc.c Wed Jan 07 15:27:19 2009 -0800 @@ -23,7 +23,7 @@ * Copyright (c) 1988 AT&T * All Rights Reserved * - * Copyright 2008 Sun Microsystems, Inc. All rights reserved. + * Copyright 2009 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ @@ -2209,6 +2209,7 @@ M_SEGM_ALIGN, /* m_segm_align */ M_SEGM_ORIGIN, /* m_segm_origin */ + M_SEGM_AORIGIN, /* m_segm_aorigin */ M_DATASEG_PERM, /* m_dataseg_perm */ M_WORD_ALIGN, /* m_word_align */ /* m_def_interp */
--- a/usr/src/cmd/sgs/libld/common/outfile.c Wed Jan 07 16:30:55 2009 -0500 +++ b/usr/src/cmd/sgs/libld/common/outfile.c Wed Jan 07 15:27:19 2009 -0800 @@ -23,7 +23,7 @@ * Copyright (c) 1988 AT&T * All Rights Reserved * - * Copyright 2008 Sun Microsystems, Inc. All rights reserved. + * Copyright 2009 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ @@ -362,10 +362,9 @@ Sg_desc *sgp; Listnode *lnp1, *lnp2; Word cnt = 0; - Is_desc *isp; - Os_desc *osp; - Aliste idx; - + Is_desc *isp; + Os_desc *osp; + Aliste idx; /* * This code must be kept in sync with the similar code @@ -552,11 +551,17 @@ } /* - * If the first loadable segment has the ?N flag, - * then ?N will be on. + * Establish any processing unique to the first loadable + * segment. */ if ((ptype == PT_LOAD) && (ptloadidx == 0)) { ptloadidx++; + + /* + * If the first loadable segment has the ?N flag then + * alignments of following segments need to be fixed, + * plus a .dynamic FLAGS1 setting is required. + */ if (sgp->sg_flags & FLG_SG_NOHDR) { fixalign = TRUE; ofl->ofl_dtflags_1 |= DF_1_NOHDR;
--- a/usr/src/cmd/sgs/libld/common/update.c Wed Jan 07 16:30:55 2009 -0500 +++ b/usr/src/cmd/sgs/libld/common/update.c Wed Jan 07 15:27:19 2009 -0800 @@ -23,7 +23,7 @@ * Copyright (c) 1988 AT&T * All Rights Reserved * - * Copyright 2008 Sun Microsystems, Inc. All rights reserved. + * Copyright 2009 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ @@ -3252,7 +3252,7 @@ uintptr_t ld_update_outfile(Ofl_desc *ofl) { - Addr size, etext, vaddr = ofl->ofl_segorigin; + Addr size, etext, vaddr; Listnode *lnp1, *lnp2; Sg_desc *sgp, *dtracesgp = 0, *capsgp = 0; Os_desc *osp; @@ -3269,6 +3269,24 @@ Aliste idx; /* + * Initialize the starting address for the first segment. Executables + * have different starting addresses depending upon the target ABI, + * where as shared objects have a starting address of 0. If this is + * a 64-bit executable that is being constructed to run in a restricted + * address space, use an alternative origin that will provide more free + * address space for the the eventual process. + */ + if (ofl->ofl_flags & FLG_OF_EXEC) { +#if defined(_ELF64) + if (ofl->ofl_sfcap_1 & SF1_SUNW_ADDR32) + vaddr = ld_targ.t_m.m_segm_aorigin; + else +#endif + vaddr = ld_targ.t_m.m_segm_origin; + } else + vaddr = 0; + + /* * Loop through the segment descriptors and pick out what we need. */ DBG_CALL(Dbg_seg_title(ofl->ofl_lml));
--- a/usr/src/cmd/sgs/liblddbg/common/cap.c Wed Jan 07 16:30:55 2009 -0500 +++ b/usr/src/cmd/sgs/liblddbg/common/cap.c Wed Jan 07 15:27:19 2009 -0800 @@ -20,10 +20,9 @@ */ /* - * Copyright 2007 Sun Microsystems, Inc. All rights reserved. + * Copyright 2009 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ -#pragma ident "%Z%%M% %I% %E% SMI" #include <stdio.h> #include <debug.h> @@ -98,15 +97,13 @@ } void -Dbg_cap_sec_title(Ofl_desc *ofl) +Dbg_cap_sec_title(Lm_list *lml, const char *name) { - Lm_list *lml = ofl->ofl_lml; - if (DBG_NOTCLASS(DBG_C_CAP)) return; Dbg_util_nl(lml, DBG_NL_STD); - dbg_print(lml, MSG_INTL(MSG_CAP_SEC_TITLE), ofl->ofl_name); + dbg_print(lml, MSG_INTL(MSG_CAP_SEC_TITLE), name); } void
--- a/usr/src/cmd/sgs/liblddbg/common/llib-llddbg Wed Jan 07 16:30:55 2009 -0500 +++ b/usr/src/cmd/sgs/liblddbg/common/llib-llddbg Wed Jan 07 15:27:19 2009 -0800 @@ -22,7 +22,7 @@ /* PROTOLIB1 */ /* - * Copyright 2008 Sun Microsystems, Inc. All rights reserved. + * Copyright 2009 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ @@ -74,8 +74,8 @@ Elf32_Half); void Dbg64_cap_sec_entry(Lm_list *, uint_t, Elf64_Xword, Elf64_Xword, Elf64_Half); -void Dbg32_cap_sec_title(Ofl_desc *); -void Dbg64_cap_sec_title(Ofl_desc *); +void Dbg32_cap_sec_title(Lm_list *, const char *); +void Dbg64_cap_sec_title(Lm_list *, const char *); void Dbg32_cap_val_hw1(Lm_list *, Elf32_Word, Elf32_Half); void Dbg64_cap_val_hw1(Lm_list *, Elf64_Xword, Elf64_Half);
--- a/usr/src/cmd/sgs/packages/common/SUNWonld-README Wed Jan 07 16:30:55 2009 -0500 +++ b/usr/src/cmd/sgs/packages/common/SUNWonld-README Wed Jan 07 15:27:19 2009 -0800 @@ -1416,3 +1416,5 @@ 6778453 RTLD_GROUP prevents use of application defined malloc 6782597 32-bit ld.so.1 needs to accept objects with large inode number 6786744 32-bit dbx failed with unknown rtld_db.so error on snv_104 +6789925 64-bit applications with SF1_SUNW_ADDR32 require non-default starting + address