Detect standard (always to be included) sections via their section
header type. The standard sections: ".shstrtab", ".symtab", ".strtab"
are either of type SHT_SYMTAB or SHT_STRTAB.
Signed-off-by: Pawel Wieczorkiewicz <wipawel@amazon.de>
Reviewed-by: Andra-Irina Paraschiv <andraprs@amazon.com>
Reviewed-by: Bjoern Doebel <doebel@amazon.de>
Reviewed-by: Norbert Manthey <nmanthey@amazon.de>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
+#include <stdbool.h>
#include <gelf.h>
#include "list.h"
return !strncmp(name, ".debug_", 7);
}
+int is_standard_section(struct section *sec)
+{
+ switch (sec->sh.sh_type) {
+ case SHT_STRTAB:
+ case SHT_SYMTAB:
+ return true;
+ default:
+ return false;
+ }
+}
+
/* returns the offset of the string in the string table */
int offset_of_string(struct list_head *list, char *name)
{
int is_text_section(struct section *sec);
int is_debug_section(struct section *sec);
int is_rela_section(struct section *sec);
+int is_standard_section(struct section *sec);
int is_local_sym(struct symbol *sym);
void rela_insn(struct section *sec, struct rela *rela, struct insn *insn);
list_for_each_entry(sec, &kelf->sections, list) {
/* include these sections even if they haven't changed */
- if (!strcmp(sec->name, ".shstrtab") ||
- !strcmp(sec->name, ".strtab") ||
- !strcmp(sec->name, ".symtab") ||
+ if (is_standard_section(sec) ||
should_include_str_section(sec->name)) {
sec->include = 1;
if (sec->secsym)