order.c revision 7c478bd95313f5f23a4c958a745db2134aa03244
/*
* 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 2004 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
/*
* Processing of SHF_ORDERED sections.
*/
#include <stdio.h>
#include <string.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);
keylink = 0;
if (shflags & SHF_ORDERED)
else if (shflags & SHF_LINK_ORDER)
}
/*
* If SHF_ORDERED is in effect - the we search for
* our desitination section based off of sh_link else
* we follow the default rules for the desitination section.
*/
if (shflags & SHF_ORDERED) {
}
} else {
/*
* SHF_LINK_ORDER coelsces into default sections - so
* we 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);
}
}
}
/*
* 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
{
int key = 1;
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.
*/
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);
}