|
Packit Service |
97d2fb |
/* Check whether section can be stripped.
|
|
Packit Service |
97d2fb |
Copyright (C) 2005, 2013 Red Hat, Inc.
|
|
Packit Service |
97d2fb |
This file is part of elfutils.
|
|
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 <string.h>
|
|
Packit Service |
97d2fb |
#include "libeblP.h"
|
|
Packit Service |
97d2fb |
|
|
Packit Service |
97d2fb |
|
|
Packit Service |
97d2fb |
bool
|
|
Packit Service |
97d2fb |
ebl_section_strip_p (Ebl *ebl, const GElf_Shdr *shdr,
|
|
Packit Service |
97d2fb |
const char *name, bool remove_comment,
|
|
Packit Service |
97d2fb |
bool only_remove_debug)
|
|
Packit Service |
97d2fb |
{
|
|
Packit Service |
97d2fb |
/* If only debug information should be removed check the name. There
|
|
Packit Service |
97d2fb |
is unfortunately no other way. */
|
|
Packit Service |
97d2fb |
if (unlikely (only_remove_debug))
|
|
Packit Service |
97d2fb |
{
|
|
Packit Service |
97d2fb |
if (ebl_debugscn_p (ebl, name))
|
|
Packit Service |
97d2fb |
return true;
|
|
Packit Service |
97d2fb |
|
|
Packit Service |
97d2fb |
if (shdr->sh_type == SHT_RELA || shdr->sh_type == SHT_REL)
|
|
Packit Service |
97d2fb |
{
|
|
Packit Service |
97d2fb |
Elf_Scn *scn_l = elf_getscn (ebl->elf, (shdr)->sh_info);
|
|
Packit Service |
97d2fb |
GElf_Shdr shdr_mem_l;
|
|
Packit Service |
97d2fb |
GElf_Shdr *shdr_l = gelf_getshdr (scn_l, &shdr_mem_l);
|
|
Packit Service |
97d2fb |
if (shdr_l != NULL)
|
|
Packit Service |
97d2fb |
{
|
|
Packit Service |
97d2fb |
size_t shstrndx;
|
|
Packit Service |
97d2fb |
if (elf_getshdrstrndx (ebl->elf, &shstrndx) != 0)
|
|
Packit Service |
97d2fb |
return false;
|
|
Packit Service |
97d2fb |
const char *s_l = elf_strptr (ebl->elf, shstrndx,
|
|
Packit Service |
97d2fb |
shdr_l->sh_name);
|
|
Packit Service |
97d2fb |
if (s_l != NULL && ebl_debugscn_p (ebl, s_l))
|
|
Packit Service |
97d2fb |
return true;
|
|
Packit Service |
97d2fb |
}
|
|
Packit Service |
97d2fb |
}
|
|
Packit Service |
97d2fb |
|
|
Packit Service |
97d2fb |
return false;
|
|
Packit Service |
97d2fb |
}
|
|
Packit Service |
97d2fb |
|
|
Packit Service |
97d2fb |
return SECTION_STRIP_P (shdr, name, remove_comment);
|
|
Packit Service |
97d2fb |
}
|