diff options
Diffstat (limited to 'arch/x86/tools')
-rw-r--r-- | arch/x86/tools/relocs.c | 30 | ||||
-rw-r--r-- | arch/x86/tools/relocs.h | 7 | ||||
-rw-r--r-- | arch/x86/tools/relocs_common.c | 16 |
3 files changed, 45 insertions, 8 deletions
diff --git a/arch/x86/tools/relocs.c b/arch/x86/tools/relocs.c index 11f9285a2ff6..cfbdbdb4e173 100644 --- a/arch/x86/tools/relocs.c +++ b/arch/x86/tools/relocs.c | |||
@@ -1025,6 +1025,29 @@ static void emit_relocs(int as_text, int use_real_mode) | |||
1025 | } | 1025 | } |
1026 | } | 1026 | } |
1027 | 1027 | ||
1028 | /* | ||
1029 | * As an aid to debugging problems with different linkers | ||
1030 | * print summary information about the relocs. | ||
1031 | * Since different linkers tend to emit the sections in | ||
1032 | * different orders we use the section names in the output. | ||
1033 | */ | ||
1034 | static int do_reloc_info(struct section *sec, Elf_Rel *rel, ElfW(Sym) *sym, | ||
1035 | const char *symname) | ||
1036 | { | ||
1037 | printf("%s\t%s\t%s\t%s\n", | ||
1038 | sec_name(sec->shdr.sh_info), | ||
1039 | rel_type(ELF_R_TYPE(rel->r_info)), | ||
1040 | symname, | ||
1041 | sec_name(sym->st_shndx)); | ||
1042 | return 0; | ||
1043 | } | ||
1044 | |||
1045 | static void print_reloc_info(void) | ||
1046 | { | ||
1047 | printf("reloc section\treloc type\tsymbol\tsymbol section\n"); | ||
1048 | walk_relocs(do_reloc_info); | ||
1049 | } | ||
1050 | |||
1028 | #if ELF_BITS == 64 | 1051 | #if ELF_BITS == 64 |
1029 | # define process process_64 | 1052 | # define process process_64 |
1030 | #else | 1053 | #else |
@@ -1032,7 +1055,8 @@ static void emit_relocs(int as_text, int use_real_mode) | |||
1032 | #endif | 1055 | #endif |
1033 | 1056 | ||
1034 | void process(FILE *fp, int use_real_mode, int as_text, | 1057 | void process(FILE *fp, int use_real_mode, int as_text, |
1035 | int show_absolute_syms, int show_absolute_relocs) | 1058 | int show_absolute_syms, int show_absolute_relocs, |
1059 | int show_reloc_info) | ||
1036 | { | 1060 | { |
1037 | regex_init(use_real_mode); | 1061 | regex_init(use_real_mode); |
1038 | read_ehdr(fp); | 1062 | read_ehdr(fp); |
@@ -1050,5 +1074,9 @@ void process(FILE *fp, int use_real_mode, int as_text, | |||
1050 | print_absolute_relocs(); | 1074 | print_absolute_relocs(); |
1051 | return; | 1075 | return; |
1052 | } | 1076 | } |
1077 | if (show_reloc_info) { | ||
1078 | print_reloc_info(); | ||
1079 | return; | ||
1080 | } | ||
1053 | emit_relocs(as_text, use_real_mode); | 1081 | emit_relocs(as_text, use_real_mode); |
1054 | } | 1082 | } |
diff --git a/arch/x86/tools/relocs.h b/arch/x86/tools/relocs.h index 07cdb1eca4fa..f59590645b68 100644 --- a/arch/x86/tools/relocs.h +++ b/arch/x86/tools/relocs.h | |||
@@ -29,8 +29,9 @@ enum symtype { | |||
29 | }; | 29 | }; |
30 | 30 | ||
31 | void process_32(FILE *fp, int use_real_mode, int as_text, | 31 | void process_32(FILE *fp, int use_real_mode, int as_text, |
32 | int show_absolute_syms, int show_absolute_relocs); | 32 | int show_absolute_syms, int show_absolute_relocs, |
33 | int show_reloc_info); | ||
33 | void process_64(FILE *fp, int use_real_mode, int as_text, | 34 | void process_64(FILE *fp, int use_real_mode, int as_text, |
34 | int show_absolute_syms, int show_absolute_relocs); | 35 | int show_absolute_syms, int show_absolute_relocs, |
35 | 36 | int show_reloc_info); | |
36 | #endif /* RELOCS_H */ | 37 | #endif /* RELOCS_H */ |
diff --git a/arch/x86/tools/relocs_common.c b/arch/x86/tools/relocs_common.c index 44d396823a53..acab636bcb34 100644 --- a/arch/x86/tools/relocs_common.c +++ b/arch/x86/tools/relocs_common.c | |||
@@ -11,12 +11,13 @@ void die(char *fmt, ...) | |||
11 | 11 | ||
12 | static void usage(void) | 12 | static void usage(void) |
13 | { | 13 | { |
14 | die("relocs [--abs-syms|--abs-relocs|--text|--realmode] vmlinux\n"); | 14 | die("relocs [--abs-syms|--abs-relocs|--reloc-info|--text|--realmode]" \ |
15 | " vmlinux\n"); | ||
15 | } | 16 | } |
16 | 17 | ||
17 | int main(int argc, char **argv) | 18 | int main(int argc, char **argv) |
18 | { | 19 | { |
19 | int show_absolute_syms, show_absolute_relocs; | 20 | int show_absolute_syms, show_absolute_relocs, show_reloc_info; |
20 | int as_text, use_real_mode; | 21 | int as_text, use_real_mode; |
21 | const char *fname; | 22 | const char *fname; |
22 | FILE *fp; | 23 | FILE *fp; |
@@ -25,6 +26,7 @@ int main(int argc, char **argv) | |||
25 | 26 | ||
26 | show_absolute_syms = 0; | 27 | show_absolute_syms = 0; |
27 | show_absolute_relocs = 0; | 28 | show_absolute_relocs = 0; |
29 | show_reloc_info = 0; | ||
28 | as_text = 0; | 30 | as_text = 0; |
29 | use_real_mode = 0; | 31 | use_real_mode = 0; |
30 | fname = NULL; | 32 | fname = NULL; |
@@ -39,6 +41,10 @@ int main(int argc, char **argv) | |||
39 | show_absolute_relocs = 1; | 41 | show_absolute_relocs = 1; |
40 | continue; | 42 | continue; |
41 | } | 43 | } |
44 | if (strcmp(arg, "--reloc-info") == 0) { | ||
45 | show_reloc_info = 1; | ||
46 | continue; | ||
47 | } | ||
42 | if (strcmp(arg, "--text") == 0) { | 48 | if (strcmp(arg, "--text") == 0) { |
43 | as_text = 1; | 49 | as_text = 1; |
44 | continue; | 50 | continue; |
@@ -67,10 +73,12 @@ int main(int argc, char **argv) | |||
67 | rewind(fp); | 73 | rewind(fp); |
68 | if (e_ident[EI_CLASS] == ELFCLASS64) | 74 | if (e_ident[EI_CLASS] == ELFCLASS64) |
69 | process_64(fp, use_real_mode, as_text, | 75 | process_64(fp, use_real_mode, as_text, |
70 | show_absolute_syms, show_absolute_relocs); | 76 | show_absolute_syms, show_absolute_relocs, |
77 | show_reloc_info); | ||
71 | else | 78 | else |
72 | process_32(fp, use_real_mode, as_text, | 79 | process_32(fp, use_real_mode, as_text, |
73 | show_absolute_syms, show_absolute_relocs); | 80 | show_absolute_syms, show_absolute_relocs, |
81 | show_reloc_info); | ||
74 | fclose(fp); | 82 | fclose(fp); |
75 | return 0; | 83 | return 0; |
76 | } | 84 | } |