Merge tag 'media/v4.16-4' of git://git.kernel.org/pub/scm/linux/kernel/git/mchehab...
[sfrench/cifs-2.6.git] / tools / objtool / check.c
index 472e64e95891e671b0c13c0d851e6defdc8e5b2c..92b6a2c21631d810cda14a79ef3fa2d906e6cb50 100644 (file)
@@ -925,7 +925,11 @@ static struct rela *find_switch_table(struct objtool_file *file,
                if (find_symbol_containing(file->rodata, text_rela->addend))
                        continue;
 
-               return find_rela_by_dest(file->rodata, text_rela->addend);
+               rodata_rela = find_rela_by_dest(file->rodata, text_rela->addend);
+               if (!rodata_rela)
+                       continue;
+
+               return rodata_rela;
        }
 
        return NULL;
@@ -1112,42 +1116,29 @@ static int read_unwind_hints(struct objtool_file *file)
 
 static int read_retpoline_hints(struct objtool_file *file)
 {
-       struct section *sec, *relasec;
+       struct section *sec;
        struct instruction *insn;
        struct rela *rela;
-       int i;
 
-       sec = find_section_by_name(file->elf, ".discard.retpoline_safe");
+       sec = find_section_by_name(file->elf, ".rela.discard.retpoline_safe");
        if (!sec)
                return 0;
 
-       relasec = sec->rela;
-       if (!relasec) {
-               WARN("missing .rela.discard.retpoline_safe section");
-               return -1;
-       }
-
-       if (sec->len % sizeof(unsigned long)) {
-               WARN("retpoline_safe size mismatch: %d %ld", sec->len, sizeof(unsigned long));
-               return -1;
-       }
-
-       for (i = 0; i < sec->len / sizeof(unsigned long); i++) {
-               rela = find_rela_by_dest(sec, i * sizeof(unsigned long));
-               if (!rela) {
-                       WARN("can't find rela for retpoline_safe[%d]", i);
+       list_for_each_entry(rela, &sec->rela_list, list) {
+               if (rela->sym->type != STT_SECTION) {
+                       WARN("unexpected relocation symbol type in %s", sec->name);
                        return -1;
                }
 
                insn = find_insn(file, rela->sym->sec, rela->addend);
                if (!insn) {
-                       WARN("can't find insn for retpoline_safe[%d]", i);
+                       WARN("bad .discard.retpoline_safe entry");
                        return -1;
                }
 
                if (insn->type != INSN_JUMP_DYNAMIC &&
                    insn->type != INSN_CALL_DYNAMIC) {
-                       WARN_FUNC("retpoline_safe hint not a indirect jump/call",
+                       WARN_FUNC("retpoline_safe hint not an indirect jump/call",
                                  insn->sec, insn->offset);
                        return -1;
                }