1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172
|
/*
Copyright (C) 2017-2018 David Anderson. All Rights Reserved.
This program is free software; you can redistribute it and/or
modify it under the terms of version 2 of the GNU General
Public License as published by the Free Software Foundation.
This program is distributed in the hope that it would be
useful, but WITHOUT ANY WARRANTY; without even the implied
warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE.
Further, this software is distributed without any warranty
that it is free of the rightful claim of any third person
regarding infringement or the like. Any license provided
herein, whether implied or otherwise, applies only to this
software file. Patent licenses, if any, provided herein
do not apply to combinations of this program with other
software, or any other product whatsoever.
You should have received a copy of the GNU General Public
License along with this program; if not, write the Free
Software Foundation, Inc., 51 Franklin Street - Fifth Floor,
Boston MA 02110-1301, USA.
*/
#include "globals.h"
/* section_bitmaps.h and .c actually involved bits,
bit shifting, and bit masks,
but now the 'maps' are simple byte arrays.
See reloc_map and section_map in command_options.c */
#include "section_bitmaps.h"
struct section_map_s
map_sectnames[DW_HDR_ARRAY_SIZE] = {
{0,0},
{DW_SECTNAME_DEBUG_INFO, DW_HDR_DEBUG_INFO},
{DW_SECTNAME_DEBUG_INFO_DWO, DW_HDR_DEBUG_INFO_DWO},
{DW_SECTNAME_DEBUG_LINE, DW_HDR_DEBUG_LINE},
{DW_SECTNAME_DEBUG_LINE_DWO, DW_HDR_DEBUG_LINE_DWO},
{DW_SECTNAME_DEBUG_PUBNAMES, DW_HDR_DEBUG_PUBNAMES},
{DW_SECTNAME_DEBUG_ABBREV, DW_HDR_DEBUG_ABBREV},
{DW_SECTNAME_DEBUG_ABBREV_DWO, DW_HDR_DEBUG_ABBREV_DWO},
{DW_SECTNAME_DEBUG_ARANGES, DW_HDR_DEBUG_ARANGES},
{DW_SECTNAME_DEBUG_FRAME, DW_HDR_DEBUG_FRAME},
{DW_SECTNAME_DEBUG_LOC, DW_HDR_DEBUG_LOC},
{DW_SECTNAME_DEBUG_LOCLISTS, DW_HDR_DEBUG_LOCLISTS},
{DW_SECTNAME_DEBUG_LOCLISTS_DWO, DW_HDR_DEBUG_LOCLISTS_DWO},
{DW_SECTNAME_DEBUG_RANGES, DW_HDR_DEBUG_RANGES},
{DW_SECTNAME_DEBUG_RNGLISTS, DW_HDR_DEBUG_RNGLISTS},
{DW_SECTNAME_DEBUG_RNGLISTS_DWO, DW_HDR_DEBUG_RNGLISTS_DWO},
{DW_SECTNAME_DEBUG_STR, DW_HDR_DEBUG_STR},
{DW_SECTNAME_DEBUG_STR_DWO, DW_HDR_DEBUG_STR_DWO},
{DW_SECTNAME_DEBUG_STR_OFFSETS, DW_HDR_DEBUG_STR_OFFSETS},
{DW_SECTNAME_DEBUG_STR_OFFSETS_DWO, DW_HDR_DEBUG_STR_OFFSETS_DWO},
{DW_SECTNAME_DEBUG_PUBTYPES, DW_HDR_DEBUG_PUBTYPES},
{DW_SECTNAME_DEBUG_TYPES, DW_HDR_DEBUG_TYPES},
{DW_SECTNAME_TEXT, DW_HDR_TEXT},
{DW_SECTNAME_GDB_INDEX, DW_HDR_GDB_INDEX},
{DW_SECTNAME_EH_FRAME, DW_HDR_EH_FRAME},
{DW_SECTNAME_DEBUG_MACINFO, DW_HDR_DEBUG_MACINFO},
{DW_SECTNAME_DEBUG_MACRO, DW_HDR_DEBUG_MACRO},
{DW_SECTNAME_DEBUG_MACRO_DWO, DW_HDR_DEBUG_MACRO_DWO},
{DW_SECTNAME_DEBUG_NAMES, DW_HDR_DEBUG_NAMES},
{DW_SECTNAME_DEBUG_CU_INDEX, DW_HDR_DEBUG_CU_INDEX},
{DW_SECTNAME_DEBUG_TU_INDEX, DW_HDR_DEBUG_TU_INDEX},
{"Elf Header", DW_HDR_HEADER},
};
/* See section_bitmaps.c, .h Control section header
printing. (not DWARF printing) */
static char reloc_map[DW_SECTION_REL_ARRAY_SIZE];
static char section_map[DW_HDR_ARRAY_SIZE];
static boolean all_sections_on;
unsigned section_bitmap_array_size(void)
{
unsigned len = sizeof(map_sectnames)/sizeof(struct section_map_s);
return len;
}
boolean
section_name_is_debug_and_wanted(const char *section_name)
{
unsigned i = 1;
if (all_sections_on) {
return TRUE;
}
for ( ; i < DW_HDR_ARRAY_SIZE; ++i) {
if(!strcmp(section_name,map_sectnames[i].name) &&
section_map[map_sectnames[i].value]) {
return TRUE;
}
}
return FALSE;
}
/* For now defaults matches all but .text. */
void
set_all_section_defaults(void)
{
unsigned i = 1;
for ( ; i < DW_HDR_ARRAY_SIZE; ++i) {
section_map[i] = TRUE;
}
}
void
set_all_sections_on(void)
{
unsigned i = 1;
all_sections_on = TRUE;
for ( ; i < DW_HDR_ARRAY_SIZE; ++i) {
section_map[i] = TRUE;
}
}
void set_all_reloc_sections_on(void)
{
unsigned i = 1;
for ( ; i < DW_SECTION_REL_ARRAY_SIZE; ++i) {
reloc_map[i] = TRUE;
}
}
boolean
any_section_header_to_print(void)
{
unsigned i = 1;
for ( ; i < DW_HDR_HEADER; ++i) {
if(section_map[i]) {
return TRUE;
}
}
return FALSE;
}
/* TRUE if the section map entry specified by the index has been enabled. */
boolean
section_map_enabled(unsigned index)
{
if (index <= 0 || index >= DW_HDR_ARRAY_SIZE)
return FALSE;
return section_map[index];
}
void
enable_section_map_entry(unsigned index)
{
if (index > 0 && index < DW_HDR_ARRAY_SIZE) {
section_map[index] = TRUE;
}
}
/* TRUE if the reloc map entry specified by the index has been enabled. */
boolean
reloc_map_enabled(unsigned index)
{
if (index <= 0 || index >= DW_SECTION_REL_ARRAY_SIZE)
return FALSE;
return reloc_map[index];
}
void
enable_reloc_map_entry(unsigned index)
{
if (index > 0 && index < DW_SECTION_REL_ARRAY_SIZE) {
reloc_map[index] = TRUE;
}
}
|