summaryrefslogtreecommitdiff
path: root/usr.bin/elfdump
diff options
context:
space:
mode:
authorSimon J. Gerraty <sjg@FreeBSD.org>2012-11-04 02:52:03 +0000
committerSimon J. Gerraty <sjg@FreeBSD.org>2012-11-04 02:52:03 +0000
commit23090366f729c56cab62de74c7a51792357e98a9 (patch)
treec511c885796e28ec571b5267e8f11f3b103d35e9 /usr.bin/elfdump
parent7750ad47a9a7dbc83f87158464170c8640723293 (diff)
parent22ff74b2f44234d31540b1f7fd6c91489c37cad3 (diff)
downloadsrc-test2-23090366f729c56cab62de74c7a51792357e98a9.tar.gz
src-test2-23090366f729c56cab62de74c7a51792357e98a9.zip
Notes
Diffstat (limited to 'usr.bin/elfdump')
-rw-r--r--usr.bin/elfdump/elfdump.c111
1 files changed, 58 insertions, 53 deletions
diff --git a/usr.bin/elfdump/elfdump.c b/usr.bin/elfdump/elfdump.c
index 99ae8bf07ab8..f966f84b458c 100644
--- a/usr.bin/elfdump/elfdump.c
+++ b/usr.bin/elfdump/elfdump.c
@@ -83,7 +83,7 @@ enum elf_member {
typedef enum elf_member elf_member_t;
-int elf32_offsets[] = {
+static int elf32_offsets[] = {
0,
offsetof(Elf32_Dyn, d_tag), offsetof(Elf32_Dyn, d_un.d_ptr),
@@ -124,7 +124,7 @@ int elf32_offsets[] = {
offsetof(Elf32_Rela, r_addend)
};
-int elf64_offsets[] = {
+static int elf64_offsets[] = {
0,
offsetof(Elf64_Dyn, d_tag), offsetof(Elf64_Dyn, d_un.d_ptr),
@@ -266,23 +266,23 @@ e_machines(u_int mach)
return (machdesc);
}
-const char *e_types[] = {
+static const char *e_types[] = {
"ET_NONE", "ET_REL", "ET_EXEC", "ET_DYN", "ET_CORE"
};
-const char *ei_versions[] = {
+static const char *ei_versions[] = {
"EV_NONE", "EV_CURRENT"
};
-const char *ei_classes[] = {
+static const char *ei_classes[] = {
"ELFCLASSNONE", "ELFCLASS32", "ELFCLASS64"
};
-const char *ei_data[] = {
+static const char *ei_data[] = {
"ELFDATANONE", "ELFDATA2LSB", "ELFDATA2MSB"
};
-const char *ei_abis[256] = {
+static const char *ei_abis[256] = {
"ELFOSABI_SYSV", "ELFOSABI_HPUX", "ELFOSABI_NETBSD", "ELFOSABI_LINUX",
"ELFOSABI_HURD", "ELFOSABI_86OPEN", "ELFOSABI_SOLARIS", "ELFOSABI_AIX",
"ELFOSABI_IRIX", "ELFOSABI_FREEBSD", "ELFOSABI_TRU64",
@@ -290,12 +290,12 @@ const char *ei_abis[256] = {
[255] = "ELFOSABI_STANDALONE"
};
-const char *p_types[] = {
+static const char *p_types[] = {
"PT_NULL", "PT_LOAD", "PT_DYNAMIC", "PT_INTERP", "PT_NOTE",
"PT_SHLIB", "PT_PHDR", "PT_TLS"
};
-const char *p_flags[] = {
+static const char *p_flags[] = {
"", "PF_X", "PF_W", "PF_X|PF_W", "PF_R", "PF_X|PF_R", "PF_W|PF_R",
"PF_X|PF_W|PF_R"
};
@@ -339,44 +339,47 @@ sh_types(u_int64_t sht) {
}
}
-const char *sh_flags[] = {
+static const char *sh_flags[] = {
"", "SHF_WRITE", "SHF_ALLOC", "SHF_WRITE|SHF_ALLOC", "SHF_EXECINSTR",
"SHF_WRITE|SHF_EXECINSTR", "SHF_ALLOC|SHF_EXECINSTR",
"SHF_WRITE|SHF_ALLOC|SHF_EXECINSTR"
};
-const char *st_types[] = {
+static const char *st_types[] = {
"STT_NOTYPE", "STT_OBJECT", "STT_FUNC", "STT_SECTION", "STT_FILE"
};
-const char *st_bindings[] = {
+static const char *st_bindings[] = {
"STB_LOCAL", "STB_GLOBAL", "STB_WEAK"
};
-char *dynstr;
-char *shstrtab;
-char *strtab;
-FILE *out;
-
-u_int64_t elf_get_byte(Elf32_Ehdr *e, void *base, elf_member_t member);
-u_int64_t elf_get_quarter(Elf32_Ehdr *e, void *base, elf_member_t member);
-u_int64_t elf_get_half(Elf32_Ehdr *e, void *base, elf_member_t member);
-u_int64_t elf_get_word(Elf32_Ehdr *e, void *base, elf_member_t member);
-u_int64_t elf_get_quad(Elf32_Ehdr *e, void *base, elf_member_t member);
-
-void elf_print_ehdr(Elf32_Ehdr *e);
-void elf_print_phdr(Elf32_Ehdr *e, void *p);
-void elf_print_shdr(Elf32_Ehdr *e, void *sh);
-void elf_print_symtab(Elf32_Ehdr *e, void *sh, char *str);
-void elf_print_dynamic(Elf32_Ehdr *e, void *sh);
-void elf_print_rel(Elf32_Ehdr *e, void *r);
-void elf_print_rela(Elf32_Ehdr *e, void *ra);
-void elf_print_interp(Elf32_Ehdr *e, void *p);
-void elf_print_got(Elf32_Ehdr *e, void *sh);
-void elf_print_hash(Elf32_Ehdr *e, void *sh);
-void elf_print_note(Elf32_Ehdr *e, void *sh);
-
-void usage(void);
+static char *dynstr;
+static char *shstrtab;
+static char *strtab;
+static FILE *out;
+
+static u_int64_t elf_get_byte(Elf32_Ehdr *e, void *base, elf_member_t member);
+static u_int64_t elf_get_quarter(Elf32_Ehdr *e, void *base,
+ elf_member_t member);
+#if 0
+static u_int64_t elf_get_half(Elf32_Ehdr *e, void *base, elf_member_t member);
+#endif
+static u_int64_t elf_get_word(Elf32_Ehdr *e, void *base, elf_member_t member);
+static u_int64_t elf_get_quad(Elf32_Ehdr *e, void *base, elf_member_t member);
+
+static void elf_print_ehdr(Elf32_Ehdr *e);
+static void elf_print_phdr(Elf32_Ehdr *e, void *p);
+static void elf_print_shdr(Elf32_Ehdr *e, void *sh);
+static void elf_print_symtab(Elf32_Ehdr *e, void *sh, char *str);
+static void elf_print_dynamic(Elf32_Ehdr *e, void *sh);
+static void elf_print_rel(Elf32_Ehdr *e, void *r);
+static void elf_print_rela(Elf32_Ehdr *e, void *ra);
+static void elf_print_interp(Elf32_Ehdr *e, void *p);
+static void elf_print_got(Elf32_Ehdr *e, void *sh);
+static void elf_print_hash(Elf32_Ehdr *e, void *sh);
+static void elf_print_note(Elf32_Ehdr *e, void *sh);
+
+static void usage(void);
int
main(int ac, char **av)
@@ -551,7 +554,7 @@ main(int ac, char **av)
return 0;
}
-void
+static void
elf_print_ehdr(Elf32_Ehdr *e)
{
u_int64_t class;
@@ -606,7 +609,7 @@ elf_print_ehdr(Elf32_Ehdr *e)
fprintf(out, "\te_shstrndx: %jd\n", (intmax_t)shstrndx);
}
-void
+static void
elf_print_phdr(Elf32_Ehdr *e, void *p)
{
u_int64_t phentsize;
@@ -648,7 +651,7 @@ elf_print_phdr(Elf32_Ehdr *e, void *p)
}
}
-void
+static void
elf_print_shdr(Elf32_Ehdr *e, void *sh)
{
u_int64_t shentsize;
@@ -696,7 +699,7 @@ elf_print_shdr(Elf32_Ehdr *e, void *sh)
}
}
-void
+static void
elf_print_symtab(Elf32_Ehdr *e, void *sh, char *str)
{
u_int64_t offset;
@@ -735,7 +738,7 @@ elf_print_symtab(Elf32_Ehdr *e, void *sh, char *str)
}
}
-void
+static void
elf_print_dynamic(Elf32_Ehdr *e, void *sh)
{
u_int64_t offset;
@@ -795,7 +798,7 @@ elf_print_dynamic(Elf32_Ehdr *e, void *sh)
}
}
-void
+static void
elf_print_rela(Elf32_Ehdr *e, void *sh)
{
u_int64_t offset;
@@ -827,7 +830,7 @@ elf_print_rela(Elf32_Ehdr *e, void *sh)
}
}
-void
+static void
elf_print_rel(Elf32_Ehdr *e, void *sh)
{
u_int64_t offset;
@@ -856,7 +859,7 @@ elf_print_rel(Elf32_Ehdr *e, void *sh)
}
}
-void
+static void
elf_print_interp(Elf32_Ehdr *e, void *p)
{
u_int64_t offset;
@@ -868,7 +871,7 @@ elf_print_interp(Elf32_Ehdr *e, void *p)
fprintf(out, "\t%s\n", s);
}
-void
+static void
elf_print_got(Elf32_Ehdr *e, void *sh)
{
u_int64_t offset;
@@ -891,12 +894,12 @@ elf_print_got(Elf32_Ehdr *e, void *sh)
}
}
-void
+static void
elf_print_hash(Elf32_Ehdr *e __unused, void *sh __unused)
{
}
-void
+static void
elf_print_note(Elf32_Ehdr *e, void *sh)
{
u_int64_t offset;
@@ -922,7 +925,7 @@ elf_print_note(Elf32_Ehdr *e, void *sh)
}
}
-u_int64_t
+static u_int64_t
elf_get_byte(Elf32_Ehdr *e, void *base, elf_member_t member)
{
u_int64_t val;
@@ -942,7 +945,7 @@ elf_get_byte(Elf32_Ehdr *e, void *base, elf_member_t member)
return val;
}
-u_int64_t
+static u_int64_t
elf_get_quarter(Elf32_Ehdr *e, void *base, elf_member_t member)
{
u_int64_t val;
@@ -982,7 +985,8 @@ elf_get_quarter(Elf32_Ehdr *e, void *base, elf_member_t member)
return val;
}
-u_int64_t
+#if 0
+static u_int64_t
elf_get_half(Elf32_Ehdr *e, void *base, elf_member_t member)
{
u_int64_t val;
@@ -1021,8 +1025,9 @@ elf_get_half(Elf32_Ehdr *e, void *base, elf_member_t member)
return val;
}
+#endif
-u_int64_t
+static u_int64_t
elf_get_word(Elf32_Ehdr *e, void *base, elf_member_t member)
{
u_int64_t val;
@@ -1062,7 +1067,7 @@ elf_get_word(Elf32_Ehdr *e, void *base, elf_member_t member)
return val;
}
-u_int64_t
+static u_int64_t
elf_get_quad(Elf32_Ehdr *e, void *base, elf_member_t member)
{
u_int64_t val;
@@ -1102,7 +1107,7 @@ elf_get_quad(Elf32_Ehdr *e, void *base, elf_member_t member)
return val;
}
-void
+static void
usage(void)
{
fprintf(stderr, "usage: elfdump -a | -cdeGhinprs [-w file] file\n");