aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorH. Peter Anvin <hpa@linux.intel.com>2012-05-18 12:52:01 -0400
committerH. Peter Anvin <hpa@linux.intel.com>2012-05-18 22:50:02 -0400
commit24ab82bd9bf18f3efc69a131d73577940941e1b7 (patch)
treefaa36566df66c2273fa202c28c46d6ea41c9c82f
parenta3e854d95a76862cd37937e0b0438f540536771a (diff)
x86, relocs: When printing an error, say relative or absolute
When the relocs tool throws an error, let the error message say if it is an absolute or relative symbol. This should make it a lot more clear what action the programmer needs to take and should help us find the reason if additional symbol bugs show up. Signed-off-by: H. Peter Anvin <hpa@zytor.com> Cc: <stable@vger.kernel.org>
-rw-r--r--arch/x86/tools/relocs.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/arch/x86/tools/relocs.c b/arch/x86/tools/relocs.c
index c3cfbb2d4a1d..b43cfcd9bf40 100644
--- a/arch/x86/tools/relocs.c
+++ b/arch/x86/tools/relocs.c
@@ -563,10 +563,14 @@ static void walk_relocs(void (*visit)(Elf32_Rel *rel, Elf32_Sym *sym),
563 Elf32_Sym *sym; 563 Elf32_Sym *sym;
564 unsigned r_type; 564 unsigned r_type;
565 const char *symname; 565 const char *symname;
566 int shn_abs;
567
566 rel = &sec->reltab[j]; 568 rel = &sec->reltab[j];
567 sym = &sh_symtab[ELF32_R_SYM(rel->r_info)]; 569 sym = &sh_symtab[ELF32_R_SYM(rel->r_info)];
568 r_type = ELF32_R_TYPE(rel->r_info); 570 r_type = ELF32_R_TYPE(rel->r_info);
569 571
572 shn_abs = sym->st_shndx == SHN_ABS;
573
570 switch (r_type) { 574 switch (r_type) {
571 case R_386_NONE: 575 case R_386_NONE:
572 case R_386_PC32: 576 case R_386_PC32:
@@ -582,7 +586,7 @@ static void walk_relocs(void (*visit)(Elf32_Rel *rel, Elf32_Sym *sym),
582 symname = sym_name(sym_strtab, sym); 586 symname = sym_name(sym_strtab, sym);
583 if (!use_real_mode) 587 if (!use_real_mode)
584 goto bad; 588 goto bad;
585 if (sym->st_shndx == SHN_ABS) { 589 if (shn_abs) {
586 if (is_reloc(S_ABS, symname)) 590 if (is_reloc(S_ABS, symname))
587 break; 591 break;
588 else if (!is_reloc(S_SEG, symname)) 592 else if (!is_reloc(S_SEG, symname))
@@ -598,7 +602,7 @@ static void walk_relocs(void (*visit)(Elf32_Rel *rel, Elf32_Sym *sym),
598 602
599 case R_386_32: 603 case R_386_32:
600 symname = sym_name(sym_strtab, sym); 604 symname = sym_name(sym_strtab, sym);
601 if (sym->st_shndx == SHN_ABS) { 605 if (shn_abs) {
602 if (is_reloc(S_ABS, symname)) 606 if (is_reloc(S_ABS, symname))
603 break; 607 break;
604 else if (!is_reloc(S_REL, symname)) 608 else if (!is_reloc(S_REL, symname))
@@ -616,7 +620,8 @@ static void walk_relocs(void (*visit)(Elf32_Rel *rel, Elf32_Sym *sym),
616 break; 620 break;
617 bad: 621 bad:
618 symname = sym_name(sym_strtab, sym); 622 symname = sym_name(sym_strtab, sym);
619 die("Invalid %s relocation: %s\n", 623 die("Invalid %s %s relocation: %s\n",
624 shn_abs ? "absolute" : "relative",
620 rel_type(r_type), symname); 625 rel_type(r_type), symname);
621 } 626 }
622 } 627 }