sections.c revision 69112edd987c28fa551d4f8d9362a84a45365f17
/*
* 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 2010 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#include <stdio.h>
#include "msg.h"
#include "_debug.h"
#include "libld.h"
#include "_string_table.h"
/*
* Format an input section descriptor name for output, in the format
* [ndx]name
* If possible, a user supplied fixed size buffer is used. Failing that,
* dynamic memory is allocated, which must be freed by the caller.
*
* entry:
* [dbg_fmt_isec_name2]: name, scnndx - Name and section index
* [dbg_fmt_isec_name]: isp - Input section descriptor giving name
* and index.
*
* buf - Caller supplied buffer
* alloc_mem - Address of pointer to be set to address of allocated
* memory, or NULL if no memory is allocated.
*
* exit:
* A pointer to the formatted string is returned. If the supplied buffer
* was sufficient, *alloc_mem is set to NULL. If memory was allocated,
* *alloc_mem references it. The caller must free this memory after use.
*/
const char *
char **alloc_mem)
{
int cnt;
/*
* If the section index is 0, it's not a real section.
* Just use the name as is.
*/
if (scnndx == 0) {
return (name);
}
/* Format into the fixed buffer */
/*
* If the name was too long, try to allocate a dynamic buffer.
* Failing that, fall through and use the clipped one already
* formatted into buf, as that's better than nothing.
*/
if ((cnt >= sizeof (dbg_isec_name_buf_t)) &&
return (*alloc_mem);
}
/* Return the caller supplied buffer */
return (buf);
}
const char *
{
alloc_mem));
}
void
{
if (DBG_NOTCLASS(DBG_C_STRTAB))
return;
if (!osp)
return;
else
if ((DBG_NOTDETAIL()) ||
return;
stp->st_hbckcnt);
continue;
while (strhash) {
if (stroff == 0) {
} else {
}
}
}
}
void
{
if (DBG_NOTCLASS(DBG_C_SECTIONS))
return;
}
void
{
char *alloc_mem;
const char *str;
if (DBG_NOTCLASS(DBG_C_SECTIONS))
return;
/*
* We can only merge string table sections with single byte
* (char) characters. For any other (wide) character types,
* issue a message so the user will understand why these
* sections are not being picked up.
*/
}
}
void
{
if (DBG_NOTCLASS(DBG_C_SECTIONS))
return;
}
void
{
if (DBG_NOTCLASS(DBG_C_SECTIONS))
return;
/*
* This section was generated because we have 1 or
* more SHF_MERGE|SHF_STRINGS input sections that we
* wish to merge. This new section will ultimately
* end up replacing those sections once it has been filled
* with their strings (merged and compressed) and relocations
* have been redirected.
*/
/* Generated input section */
} else {
/* Standard input section */
char *alloc_mem;
}
}
void
{
if (DBG_NOTCLASS(DBG_C_SECTIONS))
return;
}
void
{
if (DBG_NOTCLASS(DBG_C_SECTIONS))
return;
}
void
{
return;
/*
* This SHF_MERGE|SHF_STRINGS input section is being
* discarded in favor of the generated merged string section.
*/
char *alloc_mem;
} else {
/* Generic section discard */
char *alloc_mem1, *alloc_mem2;
if (alloc_mem1 != NULL)
if (alloc_mem2 != NULL)
}
}
void
{
char *alloc_mem;
if (DBG_NOTCLASS(DBG_C_SECTIONS))
return;
else
} else {
}
}
}
void
{
const char *str;
if (DBG_NOTCLASS(DBG_C_SECTIONS))
return;
if (DBG_NOTDETAIL())
return;
/*
* If the flag == 0, then the routine is called before sorting.
*/
if (flag == 0)
else
int os_isdescs_idx;
char *alloc_mem;
const char *isp1_str;
const char *msg;
/*
* An output segment that requires ordering might have
* as little as two sorted input sections. For example,
* the crt's can provide a SHN_BEGIN and SHN_AFTER, and
* only these two sections must be processed. Thus, if
* a input section is unordered, move on. Diagnosing
* any unsorted section can produce way too much noise.
*/
continue;
} else { /* SHF_LINK_ORDER */
}
if (link == SHN_BEFORE) {
} else {
}
}
}
}
/*
* Error message string table.
*/
static const Msg order_errors[] = {
MSG_ORD_ERR_INFORANGE, /* MSG_INTL(MSG_ORD_ERR_INFORANGE) */
MSG_ORD_ERR_ORDER, /* MSG_INTL(MSG_ORD_ERR_ORDER) */
MSG_ORD_ERR_LINKRANGE, /* MSG_INTL(MSG_ORD_ERR_LINKRANGE) */
MSG_ORD_ERR_FLAGS, /* MSG_INTL(MSG_ORD_ERR_FLAGS) */
MSG_ORD_ERR_CYCLIC, /* MSG_INTL(MSG_ORD_ERR_CYCLIC) */
MSG_ORD_ERR_LINKINV /* MSG_INTL(MSG_ORD_ERR_LINKINV) */
};
void
{
char *alloc_mem;
if (DBG_NOTCLASS(DBG_C_SECTIONS))
return;
if (DBG_NOTDETAIL())
return;
if (error == 0)
return;
if (error)
}
void
{
char *alloc_mem;
if (DBG_NOTCLASS(DBG_C_SECTIONS))
return;
}
void
{
char *alloc_mem;
const char *fmt;
if (DBG_NOTCLASS(DBG_C_SECTIONS))
return;
else if (comdat)
else
}