|
Packit Service |
97d2fb |
/* Create new subsection section in given section.
|
|
Packit Service |
97d2fb |
Copyright (C) 2002 Red Hat, Inc.
|
|
Packit Service |
97d2fb |
This file is part of elfutils.
|
|
Packit Service |
97d2fb |
Written by Ulrich Drepper <drepper@redhat.com>, 2002.
|
|
Packit Service |
97d2fb |
|
|
Packit Service |
97d2fb |
This file is free software; you can redistribute it and/or modify
|
|
Packit Service |
97d2fb |
it under the terms of either
|
|
Packit Service |
97d2fb |
|
|
Packit Service |
97d2fb |
* the GNU Lesser General Public License as published by the Free
|
|
Packit Service |
97d2fb |
Software Foundation; either version 3 of the License, or (at
|
|
Packit Service |
97d2fb |
your option) any later version
|
|
Packit Service |
97d2fb |
|
|
Packit Service |
97d2fb |
or
|
|
Packit Service |
97d2fb |
|
|
Packit Service |
97d2fb |
* the GNU General Public License as published by the Free
|
|
Packit Service |
97d2fb |
Software Foundation; either version 2 of the License, or (at
|
|
Packit Service |
97d2fb |
your option) any later version
|
|
Packit Service |
97d2fb |
|
|
Packit Service |
97d2fb |
or both in parallel, as here.
|
|
Packit Service |
97d2fb |
|
|
Packit Service |
97d2fb |
elfutils is distributed in the hope that it will be useful, but
|
|
Packit Service |
97d2fb |
WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
Packit Service |
97d2fb |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
Packit Service |
97d2fb |
General Public License for more details.
|
|
Packit Service |
97d2fb |
|
|
Packit Service |
97d2fb |
You should have received copies of the GNU General Public License and
|
|
Packit Service |
97d2fb |
the GNU Lesser General Public License along with this program. If
|
|
Packit Service |
97d2fb |
not, see <http://www.gnu.org/licenses/>. */
|
|
Packit Service |
97d2fb |
|
|
Packit Service |
97d2fb |
#ifdef HAVE_CONFIG_H
|
|
Packit Service |
97d2fb |
# include <config.h>
|
|
Packit Service |
97d2fb |
#endif
|
|
Packit Service |
97d2fb |
|
|
Packit Service |
97d2fb |
#include <stdlib.h>
|
|
Packit Service |
97d2fb |
|
|
Packit Service |
97d2fb |
#include <libasmP.h>
|
|
Packit Service |
97d2fb |
#include <system.h>
|
|
Packit Service |
97d2fb |
|
|
Packit Service |
97d2fb |
|
|
Packit Service |
97d2fb |
AsmScn_t *
|
|
Packit Service |
97d2fb |
asm_newsubscn (AsmScn_t *asmscn, unsigned int nr)
|
|
Packit Service |
97d2fb |
{
|
|
Packit Service |
97d2fb |
AsmScn_t *runp;
|
|
Packit Service |
97d2fb |
AsmScn_t *newp;
|
|
Packit Service |
97d2fb |
|
|
Packit Service |
97d2fb |
/* Just return if no section is given. The error must have been
|
|
Packit Service |
97d2fb |
somewhere else. */
|
|
Packit Service |
97d2fb |
if (asmscn == NULL)
|
|
Packit Service |
97d2fb |
return NULL;
|
|
Packit Service |
97d2fb |
|
|
Packit Service |
97d2fb |
/* Determine whether there is already a subsection with this number. */
|
|
Packit Service |
97d2fb |
runp = asmscn->subsection_id == 0 ? asmscn : asmscn->data.up;
|
|
Packit Service |
97d2fb |
while (1)
|
|
Packit Service |
97d2fb |
{
|
|
Packit Service |
97d2fb |
if (runp->subsection_id == nr)
|
|
Packit Service |
97d2fb |
/* Found it. */
|
|
Packit Service |
97d2fb |
return runp;
|
|
Packit Service |
97d2fb |
|
|
Packit Service |
97d2fb |
if (runp->subnext == NULL || runp->subnext->subsection_id > nr)
|
|
Packit Service |
97d2fb |
break;
|
|
Packit Service |
97d2fb |
|
|
Packit Service |
97d2fb |
runp = runp->subnext;
|
|
Packit Service |
97d2fb |
}
|
|
Packit Service |
97d2fb |
|
|
Packit Service |
97d2fb |
newp = (AsmScn_t *) malloc (sizeof (AsmScn_t));
|
|
Packit Service |
97d2fb |
if (newp == NULL)
|
|
Packit Service |
97d2fb |
return NULL;
|
|
Packit Service |
97d2fb |
|
|
Packit Service |
97d2fb |
/* Same assembler context than the original section. */
|
|
Packit Service |
97d2fb |
newp->ctx = runp->ctx;
|
|
Packit Service |
97d2fb |
|
|
Packit Service |
97d2fb |
/* User provided the subsectio nID. */
|
|
Packit Service |
97d2fb |
newp->subsection_id = nr;
|
|
Packit Service |
97d2fb |
|
|
Packit Service |
97d2fb |
/* Inherit the parent's type. */
|
|
Packit Service |
97d2fb |
newp->type = runp->type;
|
|
Packit Service |
97d2fb |
|
|
Packit Service |
97d2fb |
/* Pointer to the zeroth subsection. */
|
|
Packit Service |
97d2fb |
newp->data.up = runp->subsection_id == 0 ? runp : runp->data.up;
|
|
Packit Service |
97d2fb |
|
|
Packit Service |
97d2fb |
/* We start at offset zero. */
|
|
Packit Service |
97d2fb |
newp->offset = 0;
|
|
Packit Service |
97d2fb |
/* And generic alignment. */
|
|
Packit Service |
97d2fb |
newp->max_align = 1;
|
|
Packit Service |
97d2fb |
|
|
Packit Service |
97d2fb |
/* No output yet. */
|
|
Packit Service |
97d2fb |
newp->content = NULL;
|
|
Packit Service |
97d2fb |
|
|
Packit Service |
97d2fb |
/* Inherit the fill pattern from the section this one is derived from. */
|
|
Packit Service |
97d2fb |
newp->pattern = asmscn->pattern;
|
|
Packit Service |
97d2fb |
|
|
Packit Service |
97d2fb |
/* Enqueue at the right position in the list. */
|
|
Packit Service |
97d2fb |
newp->subnext = runp->subnext;
|
|
Packit Service |
97d2fb |
runp->subnext = newp;
|
|
Packit Service |
97d2fb |
|
|
Packit Service |
97d2fb |
return newp;
|
|
Packit Service |
97d2fb |
}
|