place.c revision 54d82594cac34899a52710db0b8235a171e83e31
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (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 2005 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
/*
* Map file parsing and input section to output segment mapping.
*/
#include <stdio.h>
#include <string.h>
#include "debug.h"
#include "msg.h"
#include "_libld.h"
/*
* Each time a section is placed, the function set_addralign()
* is called. This function performs:
* *) if the section is from an external file,
* check if this is empty or not. If not,
* we know the segment this section will belong
* needs a program header. (Of course, the program
* needed only if this section falls into a
* loadable segment.)
* *) compute the Least Common Multiplier for setting
* the segment alignment.
*/
static void
{
/*
* If this section has data or will be assigned data
* later, mark this segment not-empty.
*/
return;
shdr->sh_addralign);
}
/*
* Determine if section ordering is turned on. If so, return the appropriate
* os_txtndx. This information is derived from the Sg_desc->sg_segorder
* list that was built up from the Mapfile.
*/
int
{
}
}
return (0);
}
/*
* Place a section into the appropriate segment.
*/
Os_desc *
{
int os_ndx;
Group_desc * gdesc;
if (gdesc) {
/*
* If this group is marked as discarded, then this
* section needs to be discarded.
*/
return ((Os_desc *)0);
}
}
/*
* SHT_GROUP sections can only be included into relocatable
* objects.
*/
return ((Os_desc *)0);
}
}
}
/*
* Always assign SHF_TLS sections to the DATA segment (and then the
* PT_TLS embedded inside of there).
*/
/*
* Traverse the entrance criteria list searching for a segment that
* matches the input section we have. If an entrance criterion is set
* then there must be an exact match. If we complete the loop without
* finding a segment, then sgp will be NULL.
*/
if (enp->ec_segment &&
continue;
continue;
if (enp->ec_attrmask &&
/* LINTED */
continue;
continue;
char *file;
int found = 0;
continue;
if (file[0] == '*') {
const char *basename;
basename++;
found++;
break;
}
} else {
found++;
break;
}
}
}
if (!found)
continue;
}
break;
}
/*
* Strip out the % from the section name in all cases except when '-r'
* is used without '-M', and '-r' is used with '-M' without
* the ?O flag.
*/
char *cp;
char *name;
*cp = '\0';
}
}
/*
* Assign the is_namehash value now that we've settled
* on the final name for the section.
*/
/*
* If the link is not 0, then the isp is going to be appened
* to the output section where the input section pointed by
* link is placed.
*/
if (link != 0) {
/*
* If this is a COMDAT section, then see if this
* be discarded.
*/
cisp->is_basename) == 0) {
return (0);
}
}
/*
* This is a new COMDAT section - so keep it.
*/
}
/*
* Set alignment
*/
return (osp);
}
/*
* call the function set_os_txtndx() to set the
* os_txtndx field based upon the sg_segorder list that
* was built from a Mapfile. If there is no match then
* os_txtndx will be set to 0.
*
* for now this value will be held in os_ndx.
*/
/*
* Setup the masks to flagout when matching sections
*/
/*
* Traverse the input section list for the output section we have been
* assigned. If we find a matching section simply add this new section.
*/
if ((ident == osp->os_scnsymndx) &&
((shflags & ~shflagmask) ==
/*
* If this is a COMDAT section, then see if this
* be discarded.
*/
cisp->is_basename) == 0) {
cisp));
return (0);
}
}
/*
* This is a new COMDAT section - so keep it.
*/
}
/*
* Set alignment
*/
/*
* If this section is a non-empty TLS section indicate
* that a PT_TLS program header is required.
*/
/*
* If is_txtndx is 0 then this section was not
* seen in mapfile, so put it at the end.
* If is_txtndx is not 0 and ?O is turned on
* then check to see where this section should
* be inserted.
*/
} else {
isp) == 0)
}
} else
/*
* If this input section and file is associated to an
* artificially referenced output section, make sure
* they are marked as referenced also. This insures this
* input section and file isn't eliminated when -zignore
* is in effect.
* See -zignore comments when creating a new output
* section below.
*/
dbg_mask) &&
if (ifl)
}
return (osp);
}
/*
* check to see if we need to worry about section
* ordering.
*/
if (os_ndx) {
/* insert section here. */
break;
else {
continue;
}
} else {
/* insert section here. */
break;
}
continue;
}
/*
* If the new sections identifier is less than that of the
* present input section we need to insert the new section
* at this point.
*/
if (ident < osp->os_scnsymndx)
break;
}
/*
* We are adding a new output section. Update the section header
* count and associated string size.
*/
ofl->ofl_shdrcnt++;
/*
* Create a new output section descriptor.
*/
/*
* We convert COMDAT sections to PROGBITS if this is the first
* section of a output section.
*/
}
/*
* Trying to preserved the possibly intended meaning of
* in update.c.
*/
}
/*
* When -zignore is in effect, sections and files that are not
* referenced * from other sections, will be eliminated from the
* object being produced. Some sections, although unreferenced,
* are special, and must not be eliminated. Determine if this new
* output section is one of those special sections, and if so mark
* it artificially as referenced.
* Any input section and file associated to this output section
* will also be marked as referenced, and thus won't be eliminated
* from the final output.
*/
if (ifl)
}
}
/*
* Setions of SHT_GROUP are added to the ofl->ofl_osgroups
* list - so that they can be updated as a group later.
*/
}
/*
* If this section is a non-empty TLS section indicate that a PT_TLS
* program header is required.
*/
/*
* If a non-allocatable section is going to be put into a loadable
* segment then turn on the allocate bit for this section and warn the
* user that we have done so. This could only happen through the use
* of a mapfile.
*/
}
}
/*
* Retain this sections identifier for future comparisons when placing
* a section (after all sections have been processed this variable will
* be used to hold the sections symbol index as we don't need to retain
* the identifier any more).
*/
osp->os_scnsymndx = ident;
/*
* Set alignment
*/
if (lnp2) {
} else {
}
return (osp);
}