order.c revision 0e233487902b546a8949e2147ff8af45b1afc77c
/*
* 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 2008 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
/*
* Processing of SHF_ORDERED sections.
*/
#include <stdio.h>
#include <fcntl.h>
#include <link.h>
#include <debug.h>
#include "msg.h"
#include "_libld.h"
/*
* Part 1, Input processing.
*/
/*
* Get the head section number
*/
static Word
{
/*
* Range Check
*/
return (DBG_ORDER_LINK_OUTRANGE);
}
/*
* The section pointed by keylink should not be an
* ordered section.
*/
return (DBG_ORDER_INFO_ORDER);
}
}
return (0);
}
static Word
{
int error = 0;
/*
* Check the sh_info of myself.
*/
do {
/*
* Check the validitiy of the link
*/
break;
}
/*
* Pointing to a bad ordered section ?
*/
break;
}
/*
* Check sh_flag
*/
break;
}
/*
* Check the validity of sh_info field.
*/
break;
}
/*
* Can I break ?
*/
break;
/*
* Get the next link
*/
/*
* Cyclic ?
*/
break;
}
/* CONSTANTCONDITION */
} while (1);
if (error != 0) {
ret_link = 0;
}
return (ret_link);
}
/*
* Called from process_elf().
* This routine does the input processing of the ordered sections.
*/
{
int error = 0;
/*
* I might have been checked and marked error already.
*/
return (0);
if (shflags & SHF_ORDERED)
else if (shflags & SHF_LINK_ORDER)
else
keylink = 0;
isp->is_keyident, 0));
}
}
/*
* If SHF_ORDERED is in effect, search for our destination section based
* off of sh_link, otherwise follow the default rules for the
* destination section.
*/
if (shflags & SHF_ORDERED) {
isp->is_keyident, 0));
}
}
} else {
/*
* SHF_LINK_ORDER coalesces into default sections, set dest_ndx
* to NULL to trigger this.
*/
dest_ndx = 0;
}
/*
* Place the section into it's output section.
*/
if (!osp)
return (0);
}
/*
* If the output section is not yet on the ordered
* list - place it on the list.
*/
break;
}
}
/*
* Output section has been found - set up it's
* sorting information.
*/
return (S_ERROR);
}
if (keylink == SHN_BEFORE) {
st->st_beforecnt++;
st->st_aftercnt++;
} else {
st->st_ordercnt++;
return (S_ERROR);
}
/*
* Indicate that this ordered input section will require a sort
* key created. Propagate the key requirement through to the
* associated output section, segment and file, to trigger the
* sort key creation. See ld_sec_validate();
*/
}
}
/*
* Part 2, Sorting processing
*/
/*
* Traverse all segments looking for section ordering information that hasn't
* been used. If found give a warning message to the user. Also, check if
* there are any SHF_ORDERED key sections, and if so set up sort key values.
*/
void
{
}
}
continue;
continue;
}
}
}
}
static int
{
return (0);
/*
* Get memory
*/
if (st->st_beforecnt != 0) {
return (0);
}
if (st->st_ordercnt != 0) {
return (0);
}
if (st->st_aftercnt != 0) {
return (0);
}
/*
* Set info.
*/
continue;
if (keylink == SHN_BEFORE)
else
}
return (1);
}
static int
{
else
else
return (1);
return (-1);
return (0);
}
{
/*
* Sort Sections
*/
int i;
if (setup_sortbuf(osp) == 0)
return (S_ERROR);
/*
* Sorting.
* First Sort the ordered sections.
*/
if (st->st_ordercnt != 0)
/*
* Place SHN_BEFORE at head of list
*/
for (i = 0; i < st->st_beforecnt; i++) {
return (S_ERROR);
}
/*
* Next come 'linked' ordered sections
*/
for (i = 0; i < st->st_ordercnt; i++) {
return (S_ERROR);
}
/*
* Now we list any sections which have no sorting
* specifications - in the order they were input.
*
* We use list_appendc() here instead of ld_append_isp(),
* because these items have already been inserted once, and
* we don't want any duplicate entries in osp->os_mstridescs.
*/
continue;
isp) == 0)
return (S_ERROR);
}
/*
* And the end of the list are the SHN_AFTER sections.
*/
for (i = 0; i < st->st_aftercnt; i++) {
return (S_ERROR);
}
}
return (0);
}