ldmain.c revision 1d9df23bbf4124f12ca7832d6eaaa600e0aa8eda
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright (c) 1988 AT&T
* All Rights Reserved
*
* Copyright 2008 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
/*
* Processing of relocatable objects and shared objects.
*/
/*
*/
#include <string.h>
#include <stdio.h>
#include <locale.h>
#include <stdarg.h>
#include <debug.h>
#include "msg.h"
#include "_libld.h"
/*
* All target specific code is referenced via this global variable, which
* is initialized in ld_main(). This allows the linker to function as
* a cross linker, by vectoring to the target-specific code for the
* current target machine.
*/
/*
* A default library search path is used if one was not supplied on the command
* line. Note: these strings can not use MSG_ORIG() since they are modified as
* part of the path processing.
*/
#if defined(_ELF64)
static char def_Plibpath[] = "/lib/64:/usr/lib/64";
#else
#endif
/*
* A default elf header provides for simplifying diagnostic processing.
*/
EV_CURRENT };
/*
* Establish the global state necessary to link the desired machine
* target, as reflected by the ld_targ global variable.
*/
int
{
switch (mach) {
case EM_386:
case EM_AMD64:
ld_targ = *ld_targ_init_x86();
break;
case EM_SPARC:
case EM_SPARC32PLUS:
case EM_SPARCV9:
ld_targ = *ld_targ_init_sparc();
break;
default:
{
return (1);
}
}
return (0);
}
/*
* The main program
*/
int
{
char *sgs_support; /* SGS_SUPPORT environment string */
int suplib = 0;
/*
* Initialize signal handlers, and output file variables. Establish a
* default output ELF header to satisfy diagnostic requirements.
*/
return (1);
/* Initilize target state */
return (1);
/*
* Set up the output ELF header, and initialize the machine
* and class details.
*/
/*
* Build up linker version string
*/
return (1);
/*
* Argument pass one. Get all the input flags (skip any files) and
* check for consistency. After this point any map file processing
* would have been completed and the entrance criteria and segment
* descriptor lists will be complete.
*/
return (1);
return (1);
}
/*
* At this point a call such as ld -V is considered complete.
*/
return (0);
/*
* Determine whether any support libraries been loaded (either through
* By default the support library libldstab.so.1 is loaded provided the
* user hasn't specified their own -S libraries.
*/
#if defined(_LP64)
#else
#endif
char *lib;
char *lasts;
do {
MSG_ORIG(MSG_FIL_LIBSTAB)) == 0) {
if (suplib++)
continue;
}
}
}
if (lib_support.head) {
char *lib;
}
} else {
if (suplib == 0) {
}
}
/*
* The objscnt and soscnt variables were used to estimate the expected
* input files, and size the symbol hash buckets accordingly. Reset
* these values now, so as to gain an accurate count from pass two, for
* later statistics diagnostics.
*/
/*
* Determine whether we can create the file before going any further.
*/
/*
* 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.
*/
char *rpath;
}
/*
* Argument pass two. Input all libraries and objects.
*/
/*
* Call ld_start() with the etype of our output file and the
* output file name.
*/
else
/*
* Process all input files.
*/
}
/*
* If there were any partially initialized symbol,
* do preparation works.
*/
}
/*
* Before validating all symbols count the number of relocation entries.
* If copy relocations exist, COMMON symbols must be generated which are
* assigned to the executables .bss. During sym_validate() the actual
* size and alignment of the .bss is calculated. Doing things in this
* order reduces the number of symbol table traversals required (however
* it does take a little longer for the user to be told of any undefined
* symbol errors).
*/
/*
* Now that all symbol processing is complete see if any undefined
* references still remain. If we observed undefined symbols the
* FLG_OF_FATAL bit will be set: If creating a static executable, or a
* dynamic executable or shared object with the -zdefs flag set, this
* condition is fatal. If creating a shared object with the -Bsymbolic
* flag set, this condition is simply a warning.
*/
/*
* Generate any necessary sections.
*/
/*
* Now that all sections have been added to the output file, check to
* see if any section ordering was specified and if so give a warning
* if any ordering directives were not matched.
* Also, if SHF_ORDERED sections exist, set up sort key values.
*/
/*
* Having collected all the input data create the initial output file
* image, assign virtual addresses to the image, and generate a load
* map if the user requested one.
*/
/*
* Build relocation sections and perform any relocation updates.
*/
#if defined(_ELF64)
/*
* Fill in contents for Unwind Header
*/
#endif
/*
* Finally create the files elf checksum.
*/
if (ofl->ofl_checksum)
/*
* If this is a cross link to a target with a different byte
* order than the linker, swap the data to the target byte order.
*/
}
/*
* We're done, so make sure the updates are flushed to the output file.
*/
}
ld_sup_atexit(ofl, 0);
/*
* For performance reasons we don't actually free up the memory we've
* allocated, it will be freed when we exit.
*
* our memory consumption and freeing are doing. We should be able to
* free all the memory that has been allocated as part of the link-edit
* process.
*
* ofl_cleanup(ofl);
*/
return (0);
}
/*
* Cleanup an Ifl_desc.
*/
static void
{
}
/*
* Cleanup all memory that has been dynamically allocated during libld
* processing and elf_end() all Elf descriptors that are still open.
*/
void
{
/*
* Null out all entries to this member so
* that we don't attempt to elf_end() it again.
*/
}
}
}
if (php)
}
if (php)
ld_heap = 0;
}